dynamic minute limit, study screen updates

This commit is contained in:
Damien Elmes 2009-01-09 15:38:31 +09:00
parent 18cc93ecf1
commit 778e98cc7e
2 changed files with 291 additions and 228 deletions

View file

@ -951,11 +951,18 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
lambda: QDesktopServices.openUrl(QUrl(
ankiqt.appWiki + "StudyOptions")))
self.mainWin.optionsBox.setShown(False)
self.connect(self.mainWin.minuteLimit,
SIGNAL("textChanged(QString)"), self.onMinuteLimitChanged)
def showStudyScreen(self):
self.mainWin.optionsButton.setChecked(self.config['showStudyOptions'])
self.mainWin.optionsBox.setShown(self.config['showStudyOptions'])
self.switchToStudyScreen()
def onMinuteLimitChanged(self, qstr):
try:
self.deck.sessionTimeLimit = float(
self.mainWin.minuteLimit.text()) * 60
except ValueError:
pass
self.updateStudyStats()
def updateStudyStats(self):
initial = self.deck.sessionStartTime == 0
if initial:
# deck just opened, or screen triggered manually
@ -967,9 +974,9 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
# top label
h = {}
s = self.deck.getStats()
h['lapsed'] = '<font color=#990000>%s</font>' % s['failed']
h['ret'] = s['rev']
h['ret'] = '<font color=#0077ff>%s</font>' % (s['rev']+s['failed'])
h['new'] = '<font color=#0000ff>%s</font>' % s['new']
h['newof'] = '%s' % self.deck.newCount
dtoday = s['dTotal']
yesterday = self.deck._dailyStats.day - datetime.timedelta(1)
res = self.deck.s.first("""
@ -979,15 +986,11 @@ day = :d""", d=yesterday)
(dyest, tyest) = res
else:
dyest = 0; tyest = 0
dchange = dtoday - dyest
if dchange >= 0:
dchange = "+%d" % dchange
else:
dchange = str(dchange)
h['repsToday'] = '<font color=#007700>%s</font>' % dtoday
h['repsTodayChg'] = '<font color=#007700>(%s)</font>' % dchange
start = self.deck.sessionStartTime or time.time() - 600
start2 = self.deck.lastSessionStart or start - 600
h['repsTodayChg'] = '<font color=#0000cc>%s</font>' % dyest
limit = self.deck.sessionTimeLimit
start = self.deck.sessionStartTime or time.time() - limit
start2 = self.deck.lastSessionStart or start - limit
last10 = self.deck.s.scalar(
"select count(*) from reviewHistory where time >= :t",
t=start)
@ -995,39 +998,38 @@ day = :d""", d=yesterday)
"select count(*) from reviewHistory where "
"time >= :t and time < :t2",
t=start2, t2=start)
change = last10 - last20
if change >= 0:
change = "+%d" % change
else:
change = str(change)
h['repsIn10'] = '<font color=#007700>%s</font>' % last10
h['repsIn10Chg'] = '<font color=#007700>(%s)</font>' % change
h['repsInSes'] = '<font color=#007700>%s</font>' % last10
h['repsInSesChg'] = '<font color=#0000cc>%s</font>' % last20
ttoday = s['dReviewTime']
change = ttoday - tyest
if change >= 0:
change = "+%s" % anki.utils.fmtTimeSpan(change, short=True, point=1)
else:
change = anki.utils.fmtTimeSpan(change, short=True, point=1)
h['timeToday'] = '<font color=#007700>%s</font>' % (
anki.utils.fmtTimeSpan(ttoday, short=True, point=1))
h['timeTodayChg'] = '<font color=#007700>(%s)</font>' % change
h['timeTodayChg'] = '<font color=#0000cc>%s</font>' % (
anki.utils.fmtTimeSpan(tyest, short=True, point=1))
self.mainWin.optionsLabel.setText(top + _("""\
<p>
<table width=300>
<tr><td>
<table>
<tr><td>Reps (10 mins):&nbsp;&nbsp;</td><td><b>%(repsIn10)s</b></td>
<td align=right>%(repsIn10Chg)s</td></tr>
<tr><td>Reps (today):</td><td><b>%(repsToday)s</b></td>
<td align=right>%(repsTodayChg)s</td></tr>
<tr><td>Time (today):</td><td><b>%(timeToday)s</b></td>
<td align=right>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%(timeTodayChg)s</td></tr>
<table width=150>
<tr><td>Session:&nbsp;&nbsp;</td><td><b>%(repsInSes)s</b></td>
<td>%(repsInSesChg)s</td></tr>
<tr><td>Day:</td><td><b>%(repsToday)s</b></td>
<td>%(repsTodayChg)s</td></tr>
<tr><td>Time:</td><td><b>%(timeToday)s</b></td>
<td>%(timeTodayChg)s</td></tr>
</table></td>
<td><table>
<tr><td>Failed:</td><td align=right><b>%(lapsed)s</b></td></tr>
<tr><td>Review:&nbsp;&nbsp;&nbsp;</td><td align=right><b>%(ret)s</b></td></tr>
<tr><td>New:</td><td align=right><b>%(new)s</b></td></tr>
<tr><td>Review: </td><td align=right><b>%(ret)s</b></td></tr>
<tr><td>New today:</td><td align=right><b>%(new)s</b></td></tr>
<tr><td>New total:</td><td align=right><b>%(newof)s</b></td></tr>
</table></td></tr></table>""") % h)
def showStudyScreen(self):
initial = self.deck.sessionStartTime == 0
self.mainWin.optionsButton.setChecked(self.config['showStudyOptions'])
self.mainWin.optionsBox.setShown(self.config['showStudyOptions'])
self.switchToStudyScreen()
self.updateStudyStats()
# start reviewing button
self.mainWin.buttonStack.setCurrentIndex(3)
self.mainWin.buttonStack.show()
@ -1044,7 +1046,7 @@ day = :d""", d=yesterday)
def setupStudyOptions(self):
self.mainWin.newPerDay.setText(str(self.deck.newCardsPerDay))
self.mainWin.minuteLimit.setText(str(self.deck.sessionTimeLimit/60.0))
self.mainWin.minuteLimit.setText(str(self.deck.sessionTimeLimit/60))
self.mainWin.questionLimit.setText(str(self.deck.sessionRepLimit))
self.mainWin.newCardOrder.setCurrentIndex(self.deck.newCardOrder)
self.mainWin.newCardScheduling.setCurrentIndex(self.deck.newCardSpacing)

View file

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>536</width>
<height>453</height>
<height>450</height>
</rect>
</property>
<property name="sizePolicy" >
@ -28,7 +28,7 @@
<x>0</x>
<y>69</y>
<width>536</width>
<height>364</height>
<height>361</height>
</rect>
</property>
<property name="sizePolicy" >
@ -155,7 +155,7 @@
<x>0</x>
<y>0</y>
<width>251</width>
<height>305</height>
<height>302</height>
</rect>
</property>
</widget>
@ -208,7 +208,7 @@
<x>0</x>
<y>0</y>
<width>251</width>
<height>305</height>
<height>302</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5" >
@ -216,6 +216,9 @@
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<layout class="QVBoxLayout" name="verticalLayout_11" >
<property name="spacing" >
<number>0</number>
</property>
<property name="topMargin" >
<number>4</number>
</property>
@ -224,6 +227,9 @@
<property name="text" >
<string>&lt;h1>Welcome!&lt;/h1></string>
</property>
<property name="textInteractionFlags" >
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
@ -237,53 +243,201 @@
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>10</height>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line_2" >
<property name="maximumSize" >
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string/>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9" >
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_13" >
<property name="leftMargin" >
<number>2</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="label_20" >
<property name="minimumSize" >
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>&lt;b>Minute limit:&lt;/b></string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="minuteLimit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_21" >
<property name="text" >
<string>&lt;b>Question limit:&lt;/b></string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QLineEdit" name="questionLimit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="3" >
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_22" >
<property name="minimumSize" >
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>&lt;b>New per day:&lt;/b></string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="newPerDay" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1" >
<spacer name="horizontalSpacer_5" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QPushButton" name="optionsButton" >
<property name="text" >
<string>More>></string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<property name="flat" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="optionsHelpButton" >
<property name="text" >
<string>Help</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_12" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QPushButton" name="optionsButton" >
<property name="text" >
<string>&amp;Options>></string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<property name="flat" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="optionsHelpButton" >
<property name="text" >
<string>Help</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="optionsBox" >
<property name="maximumSize" >
@ -295,135 +449,42 @@
<property name="title" >
<string/>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8" >
<property name="topMargin" >
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_13" >
<property name="leftMargin" >
<number>2</number>
<widget class="QComboBox" name="newCardOrder" >
<property name="maximumSize" >
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="spacing" >
<number>0</number>
</widget>
</item>
<item>
<widget class="QComboBox" name="newCardScheduling" >
<property name="maximumSize" >
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="label_20" >
<property name="minimumSize" >
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>Time limit (mins):</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QLineEdit" name="minuteLimit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_21" >
<property name="text" >
<string>Question limit:</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QLineEdit" name="questionLimit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="3" >
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_22" >
<property name="minimumSize" >
<size>
<width>90</width>
<height>0</height>
</size>
</property>
<property name="text" >
<string>New per day</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QLineEdit" name="newPerDay" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1" >
<spacer name="horizontalSpacer_5" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QComboBox" name="newCardOrder" />
</item>
<item>
<widget class="QComboBox" name="newCardScheduling" />
</item>
<item>
<widget class="QComboBox" name="revCardOrder" />
<widget class="QComboBox" name="revCardOrder" >
<property name="maximumSize" >
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="delayLapsedCards" >
@ -481,8 +542,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>66</height>
<width>251</width>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
@ -522,8 +583,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>66</height>
<width>251</width>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
@ -672,8 +733,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>66</height>
<width>251</width>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" >
@ -707,8 +768,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>66</height>
<width>251</width>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6" >
@ -749,8 +810,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>66</height>
<width>251</width>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7" >
@ -1135,7 +1196,7 @@
<property name="geometry" >
<rect>
<x>0</x>
<y>433</y>
<y>430</y>
<width>536</width>
<height>20</height>
</rect>
@ -1734,21 +1795,21 @@
<tabstop>easeButton2</tabstop>
<tabstop>easeButton3</tabstop>
<tabstop>easeButton4</tabstop>
<tabstop>newPerDay</tabstop>
<tabstop>minuteLimit</tabstop>
<tabstop>questionLimit</tabstop>
<tabstop>optionsButton</tabstop>
<tabstop>optionsHelpButton</tabstop>
<tabstop>newCardOrder</tabstop>
<tabstop>newCardScheduling</tabstop>
<tabstop>revCardOrder</tabstop>
<tabstop>delayLapsedCards</tabstop>
<tabstop>optionsHelpButton</tabstop>
<tabstop>newPerDay</tabstop>
<tabstop>optionsButton</tabstop>
<tabstop>minuteLimit</tabstop>
<tabstop>saveEditorButton</tabstop>
<tabstop>help</tabstop>
<tabstop>welcomeText</tabstop>
<tabstop>startReviewingButton</tabstop>
<tabstop>showAnswerButton</tabstop>
<tabstop>typeAnswerField</tabstop>
<tabstop>help</tabstop>
<tabstop>saveEditorButton</tabstop>
<tabstop>welcomeText</tabstop>
</tabstops>
<resources>
<include location="../icons.qrc" />
@ -1761,12 +1822,12 @@
<slot>setShown(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>98</x>
<y>134</y>
<x>87</x>
<y>219</y>
</hint>
<hint type="destinationlabel" >
<x>219</x>
<y>190</y>
<x>211</x>
<y>344</y>
</hint>
</hints>
</connection>