mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
add cram in editor, rename editor to browser
This commit is contained in:
parent
180af193df
commit
14c67e7ab9
5 changed files with 50 additions and 18 deletions
|
@ -518,6 +518,7 @@ class EditDeck(QMainWindow):
|
||||||
self.connect(self.dialog.actionAddTag, SIGNAL("triggered()"), self.addTags)
|
self.connect(self.dialog.actionAddTag, SIGNAL("triggered()"), self.addTags)
|
||||||
self.connect(self.dialog.actionDeleteTag, SIGNAL("triggered()"), self.deleteTags)
|
self.connect(self.dialog.actionDeleteTag, SIGNAL("triggered()"), self.deleteTags)
|
||||||
self.connect(self.dialog.actionReschedule, SIGNAL("triggered()"), self.reschedule)
|
self.connect(self.dialog.actionReschedule, SIGNAL("triggered()"), self.reschedule)
|
||||||
|
self.connect(self.dialog.actionCram, SIGNAL("triggered()"), self.cram)
|
||||||
self.connect(self.dialog.actionAddCards, SIGNAL("triggered()"), self.addCards)
|
self.connect(self.dialog.actionAddCards, SIGNAL("triggered()"), self.addCards)
|
||||||
self.connect(self.dialog.actionChangeModel, SIGNAL("triggered()"), self.onChangeModel)
|
self.connect(self.dialog.actionChangeModel, SIGNAL("triggered()"), self.onChangeModel)
|
||||||
# edit
|
# edit
|
||||||
|
@ -742,6 +743,14 @@ where id in %s""" % ids2str(sf))
|
||||||
self.updateSearch()
|
self.updateSearch()
|
||||||
self.updateAfterCardChange()
|
self.updateAfterCardChange()
|
||||||
|
|
||||||
|
def cram(self):
|
||||||
|
if ui.utils.askUser(
|
||||||
|
_("Cram selected cards in new deck?"),
|
||||||
|
help="CramMode",
|
||||||
|
parent=self):
|
||||||
|
self.close()
|
||||||
|
self.parent.onCram(self.selectedCards())
|
||||||
|
|
||||||
def onChangeModel(self):
|
def onChangeModel(self):
|
||||||
sf = self.selectedFacts()
|
sf = self.selectedFacts()
|
||||||
mods = self.deck.s.column0("""
|
mods = self.deck.s.column0("""
|
||||||
|
@ -872,7 +881,7 @@ where id in %s""" % ids2str(sf))
|
||||||
|
|
||||||
def onFindReplaceHelp(self):
|
def onFindReplaceHelp(self):
|
||||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
||||||
"Editor#FindReplace"))
|
"Browser#FindReplace"))
|
||||||
|
|
||||||
# Jumping
|
# Jumping
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -919,7 +928,7 @@ where id in %s""" % ids2str(sf))
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def onHelp(self):
|
def onHelp(self):
|
||||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + "Editor"))
|
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + "Browser"))
|
||||||
|
|
||||||
# Generate card dialog
|
# Generate card dialog
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -965,7 +974,7 @@ order by ordinal""" % ids2str(self.cms))
|
||||||
|
|
||||||
def onHelp(self):
|
def onHelp(self):
|
||||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
||||||
"Editor#GenerateCards"))
|
"Browser#GenerateCards"))
|
||||||
|
|
||||||
# Change model dialog
|
# Change model dialog
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -1111,4 +1120,4 @@ class ChangeModelDialog(QDialog):
|
||||||
|
|
||||||
def onHelp(self):
|
def onHelp(self):
|
||||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
||||||
"Editor#ChangeModel"))
|
"Browser#ChangeModel"))
|
||||||
|
|
|
@ -1385,31 +1385,36 @@ day = :d""", d=yesterday)
|
||||||
# Cramming & Sharing
|
# Cramming & Sharing
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def _copyToTmpDeck(self, name="cram.anki", tags=""):
|
def _copyToTmpDeck(self, name="cram.anki", tags="", ids=[]):
|
||||||
ndir = tempfile.mkdtemp(prefix="anki")
|
ndir = tempfile.mkdtemp(prefix="anki")
|
||||||
path = os.path.join(ndir, name)
|
path = os.path.join(ndir, name)
|
||||||
from anki.exporting import AnkiExporter
|
from anki.exporting import AnkiExporter
|
||||||
e = AnkiExporter(self.deck)
|
e = AnkiExporter(self.deck)
|
||||||
if tags:
|
if tags:
|
||||||
e.limitTags = parseTags(tags)
|
e.limitTags = parseTags(tags)
|
||||||
|
if ids:
|
||||||
|
e.limitCardIds = ids
|
||||||
path = unicode(path, sys.getfilesystemencoding())
|
path = unicode(path, sys.getfilesystemencoding())
|
||||||
e.exportInto(path)
|
e.exportInto(path)
|
||||||
return (e, path)
|
return (e, path)
|
||||||
|
|
||||||
def onCram(self):
|
def onCram(self, cardIds=[]):
|
||||||
if self.deck.name() == "cram":
|
if self.deck.name() == "cram":
|
||||||
ui.utils.showInfo(
|
ui.utils.showInfo(
|
||||||
_("Already cramming. Please close this deck first."))
|
_("Already cramming. Please close this deck first."))
|
||||||
return
|
return
|
||||||
if not self.save(required=True):
|
if not self.save(required=True):
|
||||||
return
|
return
|
||||||
(s, ret) = ui.utils.getTag(self, self.deck, _("Tags to cram:"),
|
if not cardIds:
|
||||||
help="CramMode", tags="all")
|
(s, ret) = ui.utils.getTag(self, self.deck, _("Tags to cram:"),
|
||||||
if not ret:
|
help="CramMode", tags="all")
|
||||||
return
|
if not ret:
|
||||||
s = unicode(s)
|
return
|
||||||
# open tmp deck
|
s = unicode(s)
|
||||||
(e, path) = self._copyToTmpDeck(tags=s)
|
# open tmp deck
|
||||||
|
(e, path) = self._copyToTmpDeck(tags=s)
|
||||||
|
else:
|
||||||
|
(e, path) = self._copyToTmpDeck(ids=cardIds)
|
||||||
if not e.exportedCards:
|
if not e.exportedCards:
|
||||||
ui.utils.showInfo(_("No cards matched the provided tags."))
|
ui.utils.showInfo(_("No cards matched the provided tags."))
|
||||||
return
|
return
|
||||||
|
|
|
@ -55,12 +55,20 @@ def showText(text, parent=None):
|
||||||
SIGNAL("clicked()"), d.accept)
|
SIGNAL("clicked()"), d.accept)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def askUser(text, parent=None):
|
def askUser(text, parent=None, help=""):
|
||||||
"Show a yes/no question. Return true if yes."
|
"Show a yes/no question. Return true if yes."
|
||||||
if not parent:
|
if not parent:
|
||||||
parent = ankiqt.mw
|
parent = ankiqt.mw
|
||||||
r = QMessageBox.question(parent, "Anki", text,
|
sb = QMessageBox.Yes | QMessageBox.No
|
||||||
QMessageBox.Yes | QMessageBox.No)
|
if help:
|
||||||
|
sb |= QMessageBox.Help
|
||||||
|
while 1:
|
||||||
|
r = QMessageBox.question(parent, "Anki", text, sb,
|
||||||
|
QMessageBox.Yes)
|
||||||
|
if r == QMessageBox.Help:
|
||||||
|
openWikiLink(help)
|
||||||
|
else:
|
||||||
|
break
|
||||||
return r == QMessageBox.Yes
|
return r == QMessageBox.Yes
|
||||||
|
|
||||||
class GetTextDialog(QDialog):
|
class GetTextDialog(QDialog):
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Edit Items</string>
|
<string>Browse Items</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget" >
|
<widget class="QWidget" name="centralwidget" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
|
@ -198,6 +198,7 @@
|
||||||
<addaction name="actionAddCards" />
|
<addaction name="actionAddCards" />
|
||||||
<addaction name="actionChangeModel" />
|
<addaction name="actionChangeModel" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
|
<addaction name="actionCram" />
|
||||||
<addaction name="actionReschedule" />
|
<addaction name="actionReschedule" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="actionDelete" />
|
<addaction name="actionDelete" />
|
||||||
|
@ -409,6 +410,15 @@
|
||||||
<string>Find and Re&place...</string>
|
<string>Find and Re&place...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionCram" >
|
||||||
|
<property name="icon" >
|
||||||
|
<iconset resource="../icons.qrc" >
|
||||||
|
<normaloff>:/icons/view-pim-calendar.png</normaloff>:/icons/view-pim-calendar.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string>&Cram...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc" />
|
<include location="../icons.qrc" />
|
||||||
|
|
|
@ -1496,7 +1496,7 @@
|
||||||
<normaloff>:/icons/find.png</normaloff>:/icons/find.png</iconset>
|
<normaloff>:/icons/find.png</normaloff>:/icons/find.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Edit All...</string>
|
<string>Brows&e Items...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut" >
|
<property name="shortcut" >
|
||||||
<string>Ctrl+F</string>
|
<string>Ctrl+F</string>
|
||||||
|
|
Loading…
Reference in a new issue