mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 17:24:20 +02:00
Implement removal of recipes
This commit is contained in:
parent
5449f26cbe
commit
a75549107b
1 changed files with 19 additions and 4 deletions
|
|
@ -144,7 +144,7 @@ class {classname}({base}):
|
|||
max_articles_per_feed=max_articles_per_feed, base='AutomaticNewsRecipe')
|
||||
return src
|
||||
|
||||
class RecipeList(QWidget):
|
||||
class RecipeList(QWidget): # {{{
|
||||
|
||||
edit_recipe = pyqtSignal(object)
|
||||
|
||||
|
|
@ -179,17 +179,22 @@ def __init__(self, parent, model):
|
|||
b.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
||||
b.clicked.connect(self.edit_requested)
|
||||
l.addWidget(b)
|
||||
# TODO: Implement this button
|
||||
self.remove_button = b = QPushButton(QIcon(I('list_remove.png')), _('&Remove this recipe'), w)
|
||||
b.clicked.connect(self.remove)
|
||||
b.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
||||
l.addWidget(b)
|
||||
|
||||
self.select_first()
|
||||
v.selectionModel().currentRowChanged.connect(self.recipe_selected)
|
||||
|
||||
def select_first(self):
|
||||
v = self.view
|
||||
if v.model().rowCount() > 0:
|
||||
idx = v.model().index(0)
|
||||
if idx.isValid():
|
||||
v.selectionModel().select(idx, v.selectionModel().ClearAndSelect)
|
||||
self.recipe_selected(v.currentIndex())
|
||||
v.selectionModel().currentRowChanged.connect(self.recipe_selected)
|
||||
v.setCurrentIndex(idx)
|
||||
self.recipe_selected(idx)
|
||||
|
||||
@property
|
||||
def model(self):
|
||||
|
|
@ -199,6 +204,8 @@ def recipe_selected(self, cur, prev=None):
|
|||
if cur.isValid():
|
||||
self.stacks.setCurrentIndex(1)
|
||||
self.title.setText('<h2 style="text-align:center">%s</h2>' % self.model.title(cur))
|
||||
else:
|
||||
self.stacks.setCurrentIndex(0)
|
||||
|
||||
def edit_requested(self):
|
||||
idx = self.view.currentIndex()
|
||||
|
|
@ -207,6 +214,13 @@ def edit_requested(self):
|
|||
if src is not None:
|
||||
self.edit_recipe.emit(src)
|
||||
|
||||
def remove(self):
|
||||
idx = self.view.currentIndex()
|
||||
if idx.isValid():
|
||||
self.model.remove((idx.row(),))
|
||||
self.select_first()
|
||||
# }}}
|
||||
|
||||
class BasicRecipe(QWidget):
|
||||
|
||||
def __init__(self, parent):
|
||||
|
|
@ -224,6 +238,7 @@ def __init__(self, parent):
|
|||
|
||||
self.title = t = QLineEdit(self)
|
||||
l.addRow(_('Recipe &title:'), t)
|
||||
t.setStyleSheet('QLineEdit { font-weight: bold }')
|
||||
|
||||
self.oldest_article = o = QSpinBox(self)
|
||||
o.setSuffix(' ' + _('day(s)'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue