From 39dbbe4489e6a5b77bc06dbbbf022e3f84f28c1f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 18 Apr 2009 04:46:22 +0900 Subject: [PATCH] add select all/none/invert buttons to active tags dialog --- ankiqt/ui/activetags.py | 24 ++++++++++++++++++++++++ designer/activetags.ui | 40 ++++++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/ankiqt/ui/activetags.py b/ankiqt/ui/activetags.py index a2ec6854b..ca2588dd8 100644 --- a/ankiqt/ui/activetags.py +++ b/ankiqt/ui/activetags.py @@ -14,11 +14,35 @@ class ActiveTagsChooser(QDialog): self.parent = parent self.dialog = ankiqt.forms.activetags.Ui_Dialog() self.dialog.setupUi(self) + self.selectAll = QPushButton(_("Select All")) + self.connect(self.selectAll, SIGNAL("clicked()"), self.onSelectAll) + self.dialog.buttonBox.addButton(self.selectAll, + QDialogButtonBox.ActionRole) + self.selectNone = QPushButton(_("Select None")) + self.connect(self.selectNone, SIGNAL("clicked()"), self.onSelectNone) + self.dialog.buttonBox.addButton(self.selectNone, + QDialogButtonBox.ActionRole) + self.invert = QPushButton(_("Invert")) + self.connect(self.invert, SIGNAL("clicked()"), self.onInvert) + self.dialog.buttonBox.addButton(self.invert, + QDialogButtonBox.ActionRole) self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.onHelp) self.rebuildTagList() restoreGeom(self, "activeTags") + def onSelectAll(self): + self.dialog.list.selectAll() + + def onSelectNone(self): + self.dialog.list.clearSelection() + + def onInvert(self): + sm = self.dialog.list.selectionModel() + sel = sm.selection() + self.dialog.list.selectAll() + sm.select(sel, QItemSelectionModel.Deselect) + def rebuildTagList(self): self.tags = self.parent.deck.allTags() self.items = [] diff --git a/designer/activetags.ui b/designer/activetags.ui index 6915ec8d1..a9501a348 100644 --- a/designer/activetags.ui +++ b/designer/activetags.ui @@ -5,8 +5,8 @@ 0 0 - 248 - 268 + 369 + 393 @@ -16,26 +16,30 @@ - <h1>Select tags to suspend</h1> + Select tags to suspend. Deselect to unsuspend. - - - QAbstractItemView::MultiSelection - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok - - + + + + + QAbstractItemView::MultiSelection + + + + + + + Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + +