improve selective study screen

This commit is contained in:
Damien Elmes 2011-01-25 12:40:37 +09:00
parent 3df8411626
commit 0d72810034
3 changed files with 117 additions and 58 deletions

View file

@ -9,15 +9,25 @@ from ankiqt.ui.utils import saveGeom, restoreGeom
class ActiveTagsChooser(QDialog): class ActiveTagsChooser(QDialog):
def __init__(self, parent, active, inactive, title): def __init__(self, parent, type):
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.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.setWindowTitle(title) if type == "new":
self.active = "newActive"
self.inactive = "newInactive"
else:
self.active = "revActive"
self.inactive = "revInactive"
if (self.deck.getVar("newActive") == self.deck.getVar("revActive") and
self.deck.getVar("newInactive") == self.deck.getVar("revInactive")):
self.dialog.bothButton.click()
elif type == "new":
self.dialog.newButton.click()
else:
self.dialog.revButton.click()
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
self.onHelp) self.onHelp)
self.rebuildTagList() self.rebuildTagList()
@ -98,15 +108,22 @@ class ActiveTagsChooser(QDialog):
idx = self.dialog.inactiveList.indexFromItem(item) idx = self.dialog.inactiveList.indexFromItem(item)
if self.dialog.inactiveList.selectionModel().isSelected(idx): if self.dialog.inactiveList.selectionModel().isSelected(idx):
no.append(self.tags[c]) no.append(self.tags[c])
types = []
if self.dialog.activeCheck.isChecked(): if (self.dialog.newButton.isChecked() or
self.deck.setVar(self.active, joinTags(yes)) self.dialog.bothButton.isChecked()):
else: types.append(["newActive", "newInactive"])
self.deck.setVar(self.active, "") if (self.dialog.revButton.isChecked() or
if self.dialog.inactiveCheck.isChecked(): self.dialog.bothButton.isChecked()):
self.deck.setVar(self.inactive, joinTags(no)) types.append(["revActive", "revInactive"])
else: for (active, inactive) in types:
self.deck.setVar(self.inactive, "") if self.dialog.activeCheck.isChecked():
self.deck.setVar(active, joinTags(yes))
else:
self.deck.setVar(active, "")
if self.dialog.inactiveCheck.isChecked():
self.deck.setVar(inactive, joinTags(no))
else:
self.deck.setVar(inactive, "")
self.parent.reset() self.parent.reset()
saveGeom(self, "activeTags") saveGeom(self, "activeTags")
QDialog.accept(self) QDialog.accept(self)
@ -115,6 +132,6 @@ class ActiveTagsChooser(QDialog):
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
"SelectiveStudy")) "SelectiveStudy"))
def show(parent, active, inactive, title): def show(parent, type):
at = ActiveTagsChooser(parent, active, inactive, title) at = ActiveTagsChooser(parent, type)
at.exec_() at.exec_()

View file

@ -1569,12 +1569,10 @@ not be touched.""") %
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, "new")
_("Limit New Cards"))
def onRevCategoriesClicked(self): def onRevCategoriesClicked(self):
ui.activetags.show(self, "revActive", "revInactive", ui.activetags.show(self, "rev")
_("Limit Reviews"))
def onFailedMaxChanged(self): def onFailedMaxChanged(self):
try: try:

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>387</width> <width>341</width>
<height>396</height> <height>348</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,44 +15,88 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QCheckBox" name="activeCheck">
<property name="text">
<string>Show only cards with any of these tags:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="activeList">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="inactiveCheck">
<property name="text">
<string>Hide cards with any of these tags:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="inactiveList">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QGroupBox" name="groupBox">
<item> <property name="sizePolicy">
<widget class="QCheckBox" name="activeCheck"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<property name="text"> <horstretch>0</horstretch>
<string>Show only cards with any of these tags:</string> <verstretch>0</verstretch>
</property> </sizepolicy>
</widget> </property>
</item> <property name="title">
<item> <string>Change settings for:</string>
<widget class="QListWidget" name="activeList"> </property>
<property name="enabled"> <layout class="QVBoxLayout" name="verticalLayout_3">
<bool>false</bool> <item>
</property> <widget class="QRadioButton" name="newButton">
<property name="selectionMode"> <property name="text">
<enum>QAbstractItemView::MultiSelection</enum> <string>New Cards</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="inactiveCheck"> <widget class="QRadioButton" name="revButton">
<property name="text"> <property name="text">
<string>Hide cards with these tags:</string> <string>Reviews</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QListWidget" name="inactiveList"> <widget class="QRadioButton" name="bothButton">
<property name="enabled"> <property name="text">
<bool>false</bool> <string>Both</string>
</property> </property>
<property name="selectionMode"> </widget>
<enum>QAbstractItemView::MultiSelection</enum> </item>
</property> </layout>
</widget> </widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">