mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
dev wip
This commit is contained in:
parent
ca7f27ea93
commit
c5a78d8dbc
8 changed files with 30 additions and 59 deletions
|
@ -364,7 +364,7 @@ class EditDeck(QDialog):
|
||||||
self.setWindowTitle(_("Anki - Edit Items (%(cur)d "
|
self.setWindowTitle(_("Anki - Edit Items (%(cur)d "
|
||||||
"of %(tot)d cards shown)") %
|
"of %(tot)d cards shown)") %
|
||||||
{"cur": len(self.model.cards),
|
{"cur": len(self.model.cards),
|
||||||
"tot": self.deck.cardCount()})
|
"tot": self.deck.cardCount})
|
||||||
|
|
||||||
def filterTextChanged(self):
|
def filterTextChanged(self):
|
||||||
interval = 500
|
interval = 500
|
||||||
|
|
|
@ -257,7 +257,7 @@ class DisplayProperties(QDialog):
|
||||||
else:
|
else:
|
||||||
setattr(field, type + 'FontColour', None)
|
setattr(field, type + 'FontColour', None)
|
||||||
field.model.setModified()
|
field.model.setModified()
|
||||||
self.deck.setModified()
|
self.deck.flushMod()
|
||||||
self.drawQuestionAndAnswer()
|
self.drawQuestionAndAnswer()
|
||||||
|
|
||||||
def chooseColour(self, button, type):
|
def chooseColour(self, button, type):
|
||||||
|
@ -268,18 +268,19 @@ class DisplayProperties(QDialog):
|
||||||
self.saveCard()
|
self.saveCard()
|
||||||
|
|
||||||
def drawQuestionAndAnswer(self):
|
def drawQuestionAndAnswer(self):
|
||||||
|
self.deck.flushMod()
|
||||||
f = self.deck.newFact()
|
f = self.deck.newFact()
|
||||||
f.tags = u""
|
f.tags = u""
|
||||||
for field in f.fields:
|
for field in f.fields:
|
||||||
f[field.name] = field.name
|
f[field.name] = field.name
|
||||||
f.model = self.model
|
f.model = self.model
|
||||||
c = Card(f, self.card)
|
c = Card(f, self.card)
|
||||||
t = "<br><center>" + c.htmlQuestion + "</center>"
|
t = "<br><center>" + c.htmlQuestion() + "</center>"
|
||||||
self.dialog.question.setText(
|
self.dialog.question.setText(
|
||||||
"<style>\n" + c.css() + "</style>\n" + t)
|
"<style>\n" + self.deck.rebuildCSS() + "</style>\n" + t)
|
||||||
t = "<br><center>" + c.htmlAnswer + "</center>"
|
t = "<br><center>" + c.htmlAnswer() + "</center>"
|
||||||
self.dialog.answer.setText(
|
self.dialog.answer.setText(
|
||||||
"<style>\n" + c.css() + "</style>\n" + t)
|
"<style>\n" + self.deck.rebuildCSS() + "</style>\n" + t)
|
||||||
self.main.updateViews(self.main.state)
|
self.main.updateViews(self.main.state)
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
|
|
@ -118,6 +118,7 @@ class AnkiQt(QMainWindow):
|
||||||
self.moveToState("initial")
|
self.moveToState("initial")
|
||||||
|
|
||||||
def moveToState(self, state):
|
def moveToState(self, state):
|
||||||
|
t = time.time()
|
||||||
if state == "initial":
|
if state == "initial":
|
||||||
# reset current card and load again
|
# reset current card and load again
|
||||||
self.currentCard = None
|
self.currentCard = None
|
||||||
|
@ -150,7 +151,7 @@ class AnkiQt(QMainWindow):
|
||||||
ui.dialogs.closeAll()
|
ui.dialogs.closeAll()
|
||||||
elif state == "getQuestion":
|
elif state == "getQuestion":
|
||||||
self.deck._countsDirty = True
|
self.deck._countsDirty = True
|
||||||
if self.deck.cardCount() == 0:
|
if self.deck.isEmpty():
|
||||||
return self.moveToState("deckEmpty")
|
return self.moveToState("deckEmpty")
|
||||||
else:
|
else:
|
||||||
if not self.currentCard:
|
if not self.currentCard:
|
||||||
|
@ -418,8 +419,8 @@ class AnkiQt(QMainWindow):
|
||||||
except (IOError, ImportError):
|
except (IOError, ImportError):
|
||||||
return
|
return
|
||||||
except DeckWrongFormatError, e:
|
except DeckWrongFormatError, e:
|
||||||
self.importOldDeck(deckPath)
|
ui.utils.showMessage(_(
|
||||||
if not self.deck:
|
"Please open this deck with Anki < 0.9.8.7 to upgrade."))
|
||||||
return
|
return
|
||||||
except DeckAccessError, e:
|
except DeckAccessError, e:
|
||||||
if e.data.get('type') == 'inuse':
|
if e.data.get('type') == 'inuse':
|
||||||
|
@ -451,23 +452,6 @@ class AnkiQt(QMainWindow):
|
||||||
return 0
|
return 0
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def importOldDeck(self, deckPath):
|
|
||||||
from anki.importing.anki03 import Anki03Importer
|
|
||||||
# back up the old file
|
|
||||||
newPath = re.sub("\.anki$", ".anki-v3", deckPath)
|
|
||||||
while os.path.exists(newPath):
|
|
||||||
newPath += "-1"
|
|
||||||
os.rename(deckPath, newPath)
|
|
||||||
try:
|
|
||||||
self.deck = DeckStorage.Deck(deckPath)
|
|
||||||
imp = Anki03Importer(self.deck, newPath)
|
|
||||||
imp.doImport()
|
|
||||||
except DeckWrongFormatError, e:
|
|
||||||
ui.utils.showWarning(_(
|
|
||||||
"An error occurred while upgrading:\n%s") % `e.data`)
|
|
||||||
return
|
|
||||||
self.rebuildQueue()
|
|
||||||
|
|
||||||
def maybeLoadLastDeck(self, args):
|
def maybeLoadLastDeck(self, args):
|
||||||
"Open the last deck if possible."
|
"Open the last deck if possible."
|
||||||
# try a command line argument if available
|
# try a command line argument if available
|
||||||
|
@ -1289,8 +1273,8 @@ class AnkiQt(QMainWindow):
|
||||||
" - %(title)s") % {
|
" - %(title)s") % {
|
||||||
"path": deckpath,
|
"path": deckpath,
|
||||||
"title": title,
|
"title": title,
|
||||||
"cards": self.deck.cardCount(),
|
"cards": self.deck.cardCount,
|
||||||
"facts": self.deck.factCount(),
|
"facts": self.deck.factCount,
|
||||||
}
|
}
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ class ModelProperties(QDialog):
|
||||||
self.updateField(card, 'questionInAnswer', self.dialog.questionInAnswer.isChecked())
|
self.updateField(card, 'questionInAnswer', self.dialog.questionInAnswer.isChecked())
|
||||||
if changed:
|
if changed:
|
||||||
# need to generate all question/answers for this card
|
# need to generate all question/answers for this card
|
||||||
self.deck.updateCardsFromModel(self.currentCard)
|
self.deck.updateCardsFromModel(self.m)
|
||||||
self.ignoreCardUpdate = True
|
self.ignoreCardUpdate = True
|
||||||
self.updateCards()
|
self.updateCards()
|
||||||
self.ignoreCardUpdate = False
|
self.ignoreCardUpdate = False
|
||||||
|
|
|
@ -164,17 +164,15 @@ class StatusView(object):
|
||||||
stats['successive1'] = '<font color=#000000>%s</font>' % stats['successive']
|
stats['successive1'] = '<font color=#000000>%s</font>' % stats['successive']
|
||||||
stats['new1'] = '<font color=#0000ff>%s</font>' % stats['new']
|
stats['new1'] = '<font color=#0000ff>%s</font>' % stats['new']
|
||||||
self.remText.setText(remStr % stats)
|
self.remText.setText(remStr % stats)
|
||||||
stats['suspended'] = self.main.deck.suspendedCardCount()
|
|
||||||
stats['spaced'] = self.main.deck.spacedCardCount()
|
stats['spaced'] = self.main.deck.spacedCardCount()
|
||||||
stats['new2'] = self.main.deck.newCardCount()
|
stats['new2'] = self.main.deck.newCount
|
||||||
self.remText.setToolTip(_(
|
self.remText.setToolTip(_(
|
||||||
"<h1>Remaining cards</h1>"
|
"<h1>Remaining cards</h1>"
|
||||||
"<p/>There are <b>%(failed)d</b> failed cards due soon.<br>"
|
"<p/>There are <b>%(failed)d</b> failed cards due soon.<br>"
|
||||||
"There are <b>%(successive)d</b> cards awaiting review.<br>"
|
"There are <b>%(successive)d</b> cards awaiting review.<br>"
|
||||||
"There are <b>%(new)d</b> new cards due today.<br><br>"
|
"There are <b>%(new)d</b> new cards due today.<br><br>"
|
||||||
"There are <b>%(new2)d</b> new cards in total.<br>"
|
"There are <b>%(new2)d</b> new cards in total.<br>"
|
||||||
"There are <b>%(spaced)d</b> spaced cards.<br>"
|
"There are <b>%(spaced)d</b> spaced cards.<br>") % stats)
|
||||||
"There are <b>%(suspended)d</b> suspended cards.") % stats)
|
|
||||||
# eta
|
# eta
|
||||||
self.etaText.setText(_("ETA: <b>%(timeLeft)s</b>") % stats)
|
self.etaText.setText(_("ETA: <b>%(timeLeft)s</b>") % stats)
|
||||||
# retention & progress bars
|
# retention & progress bars
|
||||||
|
|
|
@ -23,7 +23,7 @@ class LatestVersionFinder(QThread):
|
||||||
self.config = main.config
|
self.config = main.config
|
||||||
# calculate stats before we start a new thread
|
# calculate stats before we start a new thread
|
||||||
if self.main.deck != None:
|
if self.main.deck != None:
|
||||||
deckSize = self.main.deck.cardCount()
|
deckSize = self.main.deck.cardCount
|
||||||
stats = anki.stats.globalStats(self.main.deck)
|
stats = anki.stats.globalStats(self.main.deck)
|
||||||
deckRecall = "%0.2f" % (
|
deckRecall = "%0.2f" % (
|
||||||
(stats.matureEase3 + stats.matureEase4) /
|
(stats.matureEase3 + stats.matureEase4) /
|
||||||
|
@ -33,7 +33,7 @@ class LatestVersionFinder(QThread):
|
||||||
stats.matureEase3 +
|
stats.matureEase3 +
|
||||||
stats.matureEase4 + 0.000001) * 100)
|
stats.matureEase4 + 0.000001) * 100)
|
||||||
pending = "(%d, %d)" % (self.main.deck.seenCardCount(),
|
pending = "(%d, %d)" % (self.main.deck.seenCardCount(),
|
||||||
self.main.deck.newCardCount())
|
self.main.deck.newCount)
|
||||||
ct = self.main.deck.created
|
ct = self.main.deck.created
|
||||||
if ct:
|
if ct:
|
||||||
ol = anki.lang.getLang()
|
ol = anki.lang.getLang()
|
||||||
|
|
|
@ -48,7 +48,7 @@ class View(object):
|
||||||
self.clearWindow()
|
self.clearWindow()
|
||||||
self.setBackgroundColour()
|
self.setBackgroundColour()
|
||||||
self.maybeHelp()
|
self.maybeHelp()
|
||||||
if self.main.deck.cardCount():
|
if not self.main.deck.isEmpty():
|
||||||
if not self.main.lastCard or (
|
if not self.main.lastCard or (
|
||||||
not self.main.config['showLastCardContent'] and
|
not self.main.config['showLastCardContent'] and
|
||||||
not self.main.config['showLastCardInterval']):
|
not self.main.config['showLastCardInterval']):
|
||||||
|
@ -70,8 +70,9 @@ class View(object):
|
||||||
def addStyles(self):
|
def addStyles(self):
|
||||||
# card styles
|
# card styles
|
||||||
s = "<style>\n"
|
s = "<style>\n"
|
||||||
if self.main.currentCard:
|
t = time.time()
|
||||||
s += self.main.currentCard.css()
|
if self.main.deck:
|
||||||
|
s += self.main.deck.css
|
||||||
# last card
|
# last card
|
||||||
for base in ("lastCard", "interface"):
|
for base in ("lastCard", "interface"):
|
||||||
family = self.main.config[base + "FontFamily"]
|
family = self.main.config[base + "FontFamily"]
|
||||||
|
@ -112,7 +113,7 @@ class View(object):
|
||||||
|
|
||||||
def drawQuestion(self, nosound=False):
|
def drawQuestion(self, nosound=False):
|
||||||
"Show the question."
|
"Show the question."
|
||||||
q = self.main.currentCard.htmlQuestion
|
q = self.main.currentCard.htmlQuestion()
|
||||||
q = renderLatex(self.main.deck, q)
|
q = renderLatex(self.main.deck, q)
|
||||||
self.write(stripSounds(q))
|
self.write(stripSounds(q))
|
||||||
if self.state != self.oldState and not nosound:
|
if self.state != self.oldState and not nosound:
|
||||||
|
@ -120,7 +121,7 @@ class View(object):
|
||||||
|
|
||||||
def drawAnswer(self):
|
def drawAnswer(self):
|
||||||
"Show the answer."
|
"Show the answer."
|
||||||
a = self.main.currentCard.htmlAnswer
|
a = self.main.currentCard.htmlAnswer()
|
||||||
a = renderLatex(self.main.deck, a)
|
a = renderLatex(self.main.deck, a)
|
||||||
self.write(stripSounds(a))
|
self.write(stripSounds(a))
|
||||||
if self.state != self.oldState:
|
if self.state != self.oldState:
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>710</width>
|
<width>414</width>
|
||||||
<height>655</height>
|
<height>434</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
|
@ -42,12 +42,6 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>400</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
<string>&Search</string>
|
<string>&Search</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -66,14 +60,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="tagList" >
|
<widget class="QComboBox" name="tagList" />
|
||||||
<property name="minimumSize" >
|
|
||||||
<size>
|
|
||||||
<width>150</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -111,7 +98,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="factsButton" >
|
<widget class="QPushButton" name="factsButton" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Facts..</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon" >
|
<property name="icon" >
|
||||||
<iconset resource="../icons.qrc" >
|
<iconset resource="../icons.qrc" >
|
||||||
|
@ -125,7 +112,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="cardsButton" >
|
<widget class="QPushButton" name="cardsButton" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Cards..</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon" >
|
<property name="icon" >
|
||||||
<iconset resource="../icons.qrc" >
|
<iconset resource="../icons.qrc" >
|
||||||
|
|
Loading…
Reference in a new issue