remove inactive tags from dialogs

This commit is contained in:
Damien Elmes 2010-10-29 21:06:45 +09:00
parent cbb538c741
commit d2e454930d
3 changed files with 7 additions and 65 deletions

View file

@ -9,12 +9,11 @@ from ankiqt.ui.utils import saveGeom, restoreGeom
class ActiveTagsChooser(QDialog): class ActiveTagsChooser(QDialog):
def __init__(self, parent, active, inactive): def __init__(self, parent, active):
QDialog.__init__(self, parent, Qt.Window) QDialog.__init__(self, parent, Qt.Window)
self.parent = parent self.parent = parent
self.deck = self.parent.deck self.deck = self.parent.deck
self.active = active self.active = active
self.inactive = inactive
self.dialog = ankiqt.forms.activetags.Ui_Dialog() self.dialog = ankiqt.forms.activetags.Ui_Dialog()
self.dialog.setupUi(self) self.dialog.setupUi(self)
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
@ -27,13 +26,9 @@ class ActiveTagsChooser(QDialog):
self.items = [] self.items = []
self.suspended = {} self.suspended = {}
yes = parseTags(self.deck.getVar(self.active)) yes = parseTags(self.deck.getVar(self.active))
no = parseTags(self.deck.getVar(self.inactive))
yesHash = {} yesHash = {}
noHash = {}
for y in yes: for y in yes:
yesHash[y] = True yesHash[y] = True
for n in no:
noHash[n] = True
groupedTags = [] groupedTags = []
usertags.sort() usertags.sort()
# render models and templates # render models and templates
@ -70,16 +65,6 @@ class ActiveTagsChooser(QDialog):
mode = QItemSelectionModel.Deselect mode = QItemSelectionModel.Deselect
idx = self.dialog.activeList.indexFromItem(item) idx = self.dialog.activeList.indexFromItem(item)
self.dialog.activeList.selectionModel().select(idx, mode) self.dialog.activeList.selectionModel().select(idx, mode)
# inactive
item = QListWidgetItem(icon, t.replace("_", " "))
self.dialog.inactiveList.addItem(item)
if t in noHash:
mode = QItemSelectionModel.Select
self.dialog.inactiveCheck.setChecked(True)
else:
mode = QItemSelectionModel.Deselect
idx = self.dialog.inactiveList.indexFromItem(item)
self.dialog.inactiveList.selectionModel().select(idx, mode)
def accept(self): def accept(self):
self.hide() self.hide()
@ -92,20 +77,10 @@ class ActiveTagsChooser(QDialog):
idx = self.dialog.activeList.indexFromItem(item) idx = self.dialog.activeList.indexFromItem(item)
if self.dialog.activeList.selectionModel().isSelected(idx): if self.dialog.activeList.selectionModel().isSelected(idx):
yes.append(self.tags[c]) yes.append(self.tags[c])
# inactive
item = self.dialog.inactiveList.item(c)
idx = self.dialog.inactiveList.indexFromItem(item)
if self.dialog.inactiveList.selectionModel().isSelected(idx):
no.append(self.tags[c])
if self.dialog.activeCheck.isChecked(): if self.dialog.activeCheck.isChecked():
self.deck.setVar(self.active, joinTags(yes)) self.deck.setVar(self.active, joinTags(yes))
else: else:
self.deck.setVar(self.active, "") self.deck.setVar(self.active, "")
if self.dialog.inactiveCheck.isChecked():
self.deck.setVar(self.inactive, joinTags(no))
else:
self.deck.setVar(self.inactive, "")
self.parent.reset() self.parent.reset()
saveGeom(self, "activeTags") saveGeom(self, "activeTags")
QDialog.accept(self) QDialog.accept(self)
@ -114,6 +89,6 @@ class ActiveTagsChooser(QDialog):
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
"ActiveTags")) "ActiveTags"))
def show(parent, active, inactive): def show(parent, active):
at = ActiveTagsChooser(parent, active, inactive) at = ActiveTagsChooser(parent, active)
at.exec_() at.exec_()

View file

@ -1488,10 +1488,10 @@ later by using File>Close.
self.mainWin.tabWidget.setCurrentIndex(self.config['studyOptionsScreen']) self.mainWin.tabWidget.setCurrentIndex(self.config['studyOptionsScreen'])
def onNewCategoriesClicked(self): def onNewCategoriesClicked(self):
ui.activetags.show(self, "newActive", "newInactive") ui.activetags.show(self, "newActive")
def onRevCategoriesClicked(self): def onRevCategoriesClicked(self):
ui.activetags.show(self, "revActive", "revInactive") ui.activetags.show(self, "revActive")
def onFailedMaxChanged(self): def onFailedMaxChanged(self):
try: try:
@ -1569,12 +1569,12 @@ later by using File>Close.
u"Show All Due Cards", u"Show All Due Cards",
u"Show Chosen Categories" u"Show Chosen Categories"
] ]
if self.deck.getVar("newActive") or self.deck.getVar("newInactive"): if self.deck.getVar("newActive"):
new = labels[1] new = labels[1]
else: else:
new = labels[0] new = labels[0]
self.mainWin.newCategoryLabel.setText(new) self.mainWin.newCategoryLabel.setText(new)
if self.deck.getVar("revActive") or self.deck.getVar("revInactive"): if self.deck.getVar("revActive"):
rev = labels[1] rev = labels[1]
else: else:
rev = labels[0] rev = labels[0]

View file

@ -35,23 +35,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="inactiveCheck">
<property name="text">
<string>Hide cards with these tags:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="inactiveList">
<property name="enabled">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -118,21 +101,5 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>inactiveCheck</sender>
<signal>toggled(bool)</signal>
<receiver>inactiveList</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>146</x>
<y>213</y>
</hint>
<hint type="destinationlabel">
<x>68</x>
<y>276</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>