mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
merge 'limit to tags' and 'cram' custom study optionts (#584)
This commit is contained in:
parent
ddc85b3a39
commit
1a06402f53
2 changed files with 79 additions and 56 deletions
|
@ -11,9 +11,12 @@ RADIO_NEW = 1
|
||||||
RADIO_REV = 2
|
RADIO_REV = 2
|
||||||
RADIO_FORGOT = 3
|
RADIO_FORGOT = 3
|
||||||
RADIO_AHEAD = 4
|
RADIO_AHEAD = 4
|
||||||
RADIO_RANDOM = 5
|
RADIO_PREVIEW = 5
|
||||||
RADIO_PREVIEW = 6
|
RADIO_CRAM = 6
|
||||||
RADIO_TAGS = 7
|
|
||||||
|
TYPE_NEW = 0
|
||||||
|
TYPE_DUE = 1
|
||||||
|
TYPE_ALL = 2
|
||||||
|
|
||||||
class CustomStudy(QDialog):
|
class CustomStudy(QDialog):
|
||||||
def __init__(self, mw):
|
def __init__(self, mw):
|
||||||
|
@ -35,7 +38,6 @@ class CustomStudy(QDialog):
|
||||||
c(f.radio4, s, lambda: self.onRadioChange(4))
|
c(f.radio4, s, lambda: self.onRadioChange(4))
|
||||||
c(f.radio5, s, lambda: self.onRadioChange(5))
|
c(f.radio5, s, lambda: self.onRadioChange(5))
|
||||||
c(f.radio6, s, lambda: self.onRadioChange(6))
|
c(f.radio6, s, lambda: self.onRadioChange(6))
|
||||||
c(f.radio7, s, lambda: self.onRadioChange(7))
|
|
||||||
|
|
||||||
def onRadioChange(self, idx):
|
def onRadioChange(self, idx):
|
||||||
f = self.form; sp = f.spin
|
f = self.form; sp = f.spin
|
||||||
|
@ -43,6 +45,8 @@ class CustomStudy(QDialog):
|
||||||
post = _("cards")
|
post = _("cards")
|
||||||
tit = ""
|
tit = ""
|
||||||
spShow = True
|
spShow = True
|
||||||
|
typeShow = False
|
||||||
|
ok = _("OK")
|
||||||
def plus(num):
|
def plus(num):
|
||||||
if num == 1000:
|
if num == 1000:
|
||||||
num = "1000+"
|
num = "1000+"
|
||||||
|
@ -66,20 +70,19 @@ class CustomStudy(QDialog):
|
||||||
elif idx == RADIO_AHEAD:
|
elif idx == RADIO_AHEAD:
|
||||||
pre = _("Review ahead by")
|
pre = _("Review ahead by")
|
||||||
post = _("days")
|
post = _("days")
|
||||||
elif idx == RADIO_RANDOM:
|
|
||||||
pre = _("Select")
|
|
||||||
post = _("cards randomly from the deck")
|
|
||||||
sval = 100
|
|
||||||
elif idx == RADIO_PREVIEW:
|
elif idx == RADIO_PREVIEW:
|
||||||
pre = _("Preview new cards added in the last")
|
pre = _("Preview new cards added in the last")
|
||||||
post = _("days")
|
post = _("days")
|
||||||
sval = 1
|
sval = 1
|
||||||
elif idx == RADIO_TAGS:
|
elif idx == RADIO_CRAM:
|
||||||
tit = _("Press OK to choose tags.")
|
pre = _("Select")
|
||||||
|
post = _("cards from the deck")
|
||||||
|
#tit = _("After pressing OK, you can choose which tags to include.")
|
||||||
|
ok = _("Choose Tags")
|
||||||
sval = 100
|
sval = 100
|
||||||
spShow = False
|
typeShow = True
|
||||||
pre = post = ""
|
|
||||||
sp.setVisible(spShow)
|
sp.setVisible(spShow)
|
||||||
|
f.cardType.setVisible(typeShow)
|
||||||
f.title.setText(tit)
|
f.title.setText(tit)
|
||||||
f.title.setVisible(not not tit)
|
f.title.setVisible(not not tit)
|
||||||
f.spin.setMinimum(smin)
|
f.spin.setMinimum(smin)
|
||||||
|
@ -87,6 +90,7 @@ class CustomStudy(QDialog):
|
||||||
f.spin.setValue(sval)
|
f.spin.setValue(sval)
|
||||||
f.preSpin.setText(pre)
|
f.preSpin.setText(pre)
|
||||||
f.postSpin.setText(post)
|
f.postSpin.setText(post)
|
||||||
|
f.buttonBox.button(QDialogButtonBox.Ok).setText(ok)
|
||||||
self.radioIdx = idx
|
self.radioIdx = idx
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
|
@ -103,10 +107,8 @@ class CustomStudy(QDialog):
|
||||||
self.mw.col.sched.extendLimits(0, spin)
|
self.mw.col.sched.extendLimits(0, spin)
|
||||||
self.mw.reset()
|
self.mw.reset()
|
||||||
return QDialog.accept(self)
|
return QDialog.accept(self)
|
||||||
elif i == RADIO_TAGS:
|
elif i == RADIO_CRAM:
|
||||||
tags = self._getTags()
|
tags = self._getTags()
|
||||||
if not tags:
|
|
||||||
return
|
|
||||||
# the rest create a filtered deck
|
# the rest create a filtered deck
|
||||||
cur = self.mw.col.decks.byName(_("Custom Study Session"))
|
cur = self.mw.col.decks.byName(_("Custom Study Session"))
|
||||||
if cur:
|
if cur:
|
||||||
|
@ -131,18 +133,26 @@ class CustomStudy(QDialog):
|
||||||
dyn['delays'] = None
|
dyn['delays'] = None
|
||||||
dyn['terms'][0] = ['prop:due<=%d' % spin, 9999, DYN_DUE]
|
dyn['terms'][0] = ['prop:due<=%d' % spin, 9999, DYN_DUE]
|
||||||
dyn['resched'] = True
|
dyn['resched'] = True
|
||||||
elif i == RADIO_RANDOM:
|
|
||||||
dyn['delays'] = None
|
|
||||||
dyn['terms'][0] = ['', spin, DYN_RANDOM]
|
|
||||||
dyn['resched'] = True
|
|
||||||
elif i == RADIO_PREVIEW:
|
elif i == RADIO_PREVIEW:
|
||||||
dyn['delays'] = None
|
dyn['delays'] = None
|
||||||
dyn['terms'][0] = ['is:new added:%s'%spin, 9999, DYN_OLDEST]
|
dyn['terms'][0] = ['is:new added:%s'%spin, 9999, DYN_OLDEST]
|
||||||
dyn['resched'] = False
|
dyn['resched'] = False
|
||||||
elif i == RADIO_TAGS:
|
elif i == RADIO_CRAM:
|
||||||
dyn['delays'] = None
|
dyn['delays'] = None
|
||||||
dyn['terms'][0] = ["(is:new or is:due) "+tags, 9999, DYN_RANDOM]
|
type = f.cardType.currentRow()
|
||||||
|
if type == TYPE_NEW:
|
||||||
|
terms = "is:new "
|
||||||
|
ord = DYN_ADDED
|
||||||
dyn['resched'] = True
|
dyn['resched'] = True
|
||||||
|
elif type == TYPE_DUE:
|
||||||
|
terms = "is:due "
|
||||||
|
ord = DYN_DUE
|
||||||
|
dyn['resched'] = True
|
||||||
|
else:
|
||||||
|
terms = ""
|
||||||
|
ord = DYN_RANDOM
|
||||||
|
dyn['resched'] = False
|
||||||
|
dyn['terms'][0] = [(terms+tags).strip(), spin, ord]
|
||||||
# add deck limit
|
# add deck limit
|
||||||
dyn['terms'][0][0] = "deck:\"%s\" %s " % (self.deck['name'], dyn['terms'][0][0])
|
dyn['terms'][0][0] = "deck:\"%s\" %s " % (self.deck['name'], dyn['terms'][0][0])
|
||||||
# generate cards
|
# generate cards
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>290</width>
|
<width>332</width>
|
||||||
<height>338</height>
|
<height>380</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -16,31 +16,10 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="5" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QRadioButton" name="radio6">
|
<widget class="QRadioButton" name="radio4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Preview new cards</string>
|
<string>Review ahead</string>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QRadioButton" name="radio5">
|
|
||||||
<property name="text">
|
|
||||||
<string>Study a random selection of cards</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QRadioButton" name="radio2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Increase today's review card limit</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QRadioButton" name="radio1">
|
|
||||||
<property name="text">
|
|
||||||
<string>Increase today's new card limit</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -51,17 +30,31 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QRadioButton" name="radio4">
|
<widget class="QRadioButton" name="radio1">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Review ahead</string>
|
<string>Increase today's new card limit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="radio7">
|
<widget class="QRadioButton" name="radio2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Limit to particular tags</string>
|
<string>Increase today's review card limit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QRadioButton" name="radio6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Study by card state or tag</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QRadioButton" name="radio5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Preview new cards</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -114,6 +107,28 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="cardType">
|
||||||
|
<property name="currentRow">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>New cards only</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Due cards only</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>All cards in random order (cram mode)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -147,9 +162,7 @@
|
||||||
<tabstop>radio2</tabstop>
|
<tabstop>radio2</tabstop>
|
||||||
<tabstop>radio3</tabstop>
|
<tabstop>radio3</tabstop>
|
||||||
<tabstop>radio4</tabstop>
|
<tabstop>radio4</tabstop>
|
||||||
<tabstop>radio5</tabstop>
|
|
||||||
<tabstop>radio6</tabstop>
|
<tabstop>radio6</tabstop>
|
||||||
<tabstop>radio7</tabstop>
|
|
||||||
<tabstop>spin</tabstop>
|
<tabstop>spin</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
|
|
Loading…
Reference in a new issue