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):
def __init__(self, parent, active, inactive, title):
def __init__(self, parent, type):
QDialog.__init__(self, parent, Qt.Window)
self.parent = parent
self.deck = self.parent.deck
self.active = active
self.inactive = inactive
self.dialog = ankiqt.forms.activetags.Ui_Dialog()
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.onHelp)
self.rebuildTagList()
@ -98,15 +108,22 @@ class ActiveTagsChooser(QDialog):
idx = self.dialog.inactiveList.indexFromItem(item)
if self.dialog.inactiveList.selectionModel().isSelected(idx):
no.append(self.tags[c])
types = []
if (self.dialog.newButton.isChecked() or
self.dialog.bothButton.isChecked()):
types.append(["newActive", "newInactive"])
if (self.dialog.revButton.isChecked() or
self.dialog.bothButton.isChecked()):
types.append(["revActive", "revInactive"])
for (active, inactive) in types:
if self.dialog.activeCheck.isChecked():
self.deck.setVar(self.active, joinTags(yes))
self.deck.setVar(active, joinTags(yes))
else:
self.deck.setVar(self.active, "")
self.deck.setVar(active, "")
if self.dialog.inactiveCheck.isChecked():
self.deck.setVar(self.inactive, joinTags(no))
self.deck.setVar(inactive, joinTags(no))
else:
self.deck.setVar(self.inactive, "")
self.deck.setVar(inactive, "")
self.parent.reset()
saveGeom(self, "activeTags")
QDialog.accept(self)
@ -115,6 +132,6 @@ class ActiveTagsChooser(QDialog):
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
"SelectiveStudy"))
def show(parent, active, inactive, title):
at = ActiveTagsChooser(parent, active, inactive, title)
def show(parent, type):
at = ActiveTagsChooser(parent, type)
at.exec_()

View file

@ -1569,12 +1569,10 @@ not be touched.""") %
self.mainWin.tabWidget.setCurrentIndex(self.config['studyOptionsScreen'])
def onNewCategoriesClicked(self):
ui.activetags.show(self, "newActive", "newInactive",
_("Limit New Cards"))
ui.activetags.show(self, "new")
def onRevCategoriesClicked(self):
ui.activetags.show(self, "revActive", "revInactive",
_("Limit Reviews"))
ui.activetags.show(self, "rev")
def onFailedMaxChanged(self):
try:

View file

@ -6,18 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>387</width>
<height>396</height>
<width>341</width>
<height>348</height>
</rect>
</property>
<property name="windowTitle">
<string>Selective Study</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="activeCheck">
<property name="text">
@ -30,6 +26,12 @@
<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>
@ -38,7 +40,7 @@
<item>
<widget class="QCheckBox" name="inactiveCheck">
<property name="text">
<string>Hide cards with these tags:</string>
<string>Hide cards with any of these tags:</string>
</property>
</widget>
</item>
@ -47,12 +49,54 @@
<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>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Change settings for:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="newButton">
<property name="text">
<string>New Cards</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="revButton">
<property name="text">
<string>Reviews</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bothButton">
<property name="text">
<string>Both</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">