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.parent = parent
self.dialog = ankiqt.forms.activetags.Ui_Dialog() self.dialog = ankiqt.forms.activetags.Ui_Dialog()
self.dialog.setupUi(self) 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.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
self.onHelp) self.onHelp)
self.rebuildTagList() self.rebuildTagList()
restoreGeom(self, "activeTags") 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): def rebuildTagList(self):
self.tags = self.parent.deck.allTags() self.tags = self.parent.deck.allTags()
self.items = [] self.items = []

View file

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