add select all/none/invert buttons to active tags dialog

This commit is contained in:
Damien Elmes 2009-04-18 04:46:22 +09:00
parent bb876ce3ed
commit 39dbbe4489
2 changed files with 46 additions and 18 deletions

View file

@ -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 = []

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>248</width>
<height>268</height>
<width>369</width>
<height>393</height>
</rect>
</property>
<property name="windowTitle" >
@ -16,26 +16,30 @@
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>&lt;h1>Select tags to suspend&lt;/h1></string>
<string>Select tags to suspend. Deselect to unsuspend.</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="list" >
<property name="selectionMode" >
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QListWidget" name="list" >
<property name="selectionMode" >
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>