mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
toolbar in cardlist, toggleable suspend&mark, coloured marked cards
This commit is contained in:
parent
957c0b02d8
commit
184afcf4b5
2 changed files with 115 additions and 19 deletions
|
@ -32,6 +32,7 @@ CARD_INTERVAL = 8
|
||||||
CARD_EASE = 9
|
CARD_EASE = 9
|
||||||
CARD_NO = 10
|
CARD_NO = 10
|
||||||
CARD_PRIORITY = 11
|
CARD_PRIORITY = 11
|
||||||
|
CARD_TAGS = 12
|
||||||
|
|
||||||
# Deck editor
|
# Deck editor
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -171,7 +172,8 @@ where cards.factId = facts.id """
|
||||||
try:
|
try:
|
||||||
self.cards[index.row()] = self.deck.s.first("""
|
self.cards[index.row()] = self.deck.s.first("""
|
||||||
select id, question, answer, due, reps, factId, created, modified,
|
select id, question, answer, due, reps, factId, created, modified,
|
||||||
interval, factor, noCount, priority from cards where id = :id""",
|
interval, factor, noCount, priority, (select tags from facts where
|
||||||
|
facts.id = cards.factId) from cards where id = :id""",
|
||||||
id=self.cards[index.row()][0])
|
id=self.cards[index.row()][0])
|
||||||
self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
|
self.emit(SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
|
||||||
index, self.index(index.row(), 1))
|
index, self.index(index.row(), 1))
|
||||||
|
@ -286,6 +288,14 @@ class StatusDelegate(QItemDelegate):
|
||||||
painter.save()
|
painter.save()
|
||||||
painter.fillRect(option.rect, brush)
|
painter.fillRect(option.rect, brush)
|
||||||
painter.restore()
|
painter.restore()
|
||||||
|
elif "Marked" in row[CARD_TAGS]:
|
||||||
|
if index.row() % 2 == 0:
|
||||||
|
brush = QBrush(QColor("#ccccff"))
|
||||||
|
else:
|
||||||
|
brush = QBrush(QColor("#aaaaff"))
|
||||||
|
painter.save()
|
||||||
|
painter.fillRect(option.rect, brush)
|
||||||
|
painter.restore()
|
||||||
return QItemDelegate.paint(self, painter, option, index)
|
return QItemDelegate.paint(self, painter, option, index)
|
||||||
|
|
||||||
class EditDeck(QMainWindow):
|
class EditDeck(QMainWindow):
|
||||||
|
@ -307,6 +317,8 @@ class EditDeck(QMainWindow):
|
||||||
self.dialog.setupUi(self)
|
self.dialog.setupUi(self)
|
||||||
restoreGeom(self, "editor")
|
restoreGeom(self, "editor")
|
||||||
restoreSplitter(self.dialog.splitter, "editor")
|
restoreSplitter(self.dialog.splitter, "editor")
|
||||||
|
self.dialog.toolBar.setIconSize(QSize(self.config['iconSize'],
|
||||||
|
self.config['iconSize']))
|
||||||
# flush all changes before we load
|
# flush all changes before we load
|
||||||
self.deck.s.flush()
|
self.deck.s.flush()
|
||||||
self.model = DeckModel(self.parent, self.parent.deck)
|
self.model = DeckModel(self.parent, self.parent.deck)
|
||||||
|
@ -629,8 +641,8 @@ class EditDeck(QMainWindow):
|
||||||
self.connect(self.dialog.actionCram, SIGNAL("triggered()"), self.cram)
|
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)
|
||||||
self.connect(self.dialog.actionSuspend, SIGNAL("triggered()"), self.onSuspend)
|
self.connect(self.dialog.actionToggleSuspend, SIGNAL("triggered(bool)"), self.onSuspend)
|
||||||
self.connect(self.dialog.actionUnsuspend, SIGNAL("triggered()"), self.onUnsuspend)
|
self.connect(self.dialog.actionToggleMark, SIGNAL("triggered(bool)"), self.onMark)
|
||||||
# edit
|
# edit
|
||||||
self.connect(self.dialog.actionFont, SIGNAL("triggered()"), self.onFont)
|
self.connect(self.dialog.actionFont, SIGNAL("triggered()"), self.onFont)
|
||||||
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
|
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
|
||||||
|
@ -728,6 +740,7 @@ class EditDeck(QMainWindow):
|
||||||
self.editor.setFact(fact, True)
|
self.editor.setFact(fact, True)
|
||||||
self.showCardInfo(self.currentCard)
|
self.showCardInfo(self.currentCard)
|
||||||
self.onEvent()
|
self.onEvent()
|
||||||
|
self.updateToggles()
|
||||||
|
|
||||||
def setupCardInfo(self):
|
def setupCardInfo(self):
|
||||||
self.currentCard = None
|
self.currentCard = None
|
||||||
|
@ -782,29 +795,46 @@ where id in (%s)""" % ",".join([
|
||||||
self.updateSearch()
|
self.updateSearch()
|
||||||
self.updateAfterCardChange()
|
self.updateAfterCardChange()
|
||||||
|
|
||||||
def addTags(self):
|
def addTags(self, tags=None, label=None):
|
||||||
|
if tags is None:
|
||||||
(tags, r) = ui.utils.getTag(self, self.deck, _("Enter tags to add:"))
|
(tags, r) = ui.utils.getTag(self, self.deck, _("Enter tags to add:"))
|
||||||
|
if label is None:
|
||||||
|
label = _("Add Tags")
|
||||||
if tags:
|
if tags:
|
||||||
n = _("Add Tags")
|
|
||||||
self.parent.setProgressParent(self)
|
self.parent.setProgressParent(self)
|
||||||
self.deck.setUndoStart(n)
|
self.deck.setUndoStart(label)
|
||||||
self.deck.addTags(self.selectedFacts(), tags)
|
self.deck.addTags(self.selectedFacts(), tags)
|
||||||
self.deck.setUndoEnd(n)
|
self.deck.setUndoEnd(label)
|
||||||
self.parent.setProgressParent(None)
|
self.parent.setProgressParent(None)
|
||||||
self.updateAfterCardChange(reset=True)
|
self.updateAfterCardChange(reset=True)
|
||||||
|
|
||||||
def deleteTags(self):
|
def deleteTags(self, tags=None, label=None):
|
||||||
|
if tags is None:
|
||||||
(tags, r) = ui.utils.getTag(self, self.deck, _("Enter tags to delete:"))
|
(tags, r) = ui.utils.getTag(self, self.deck, _("Enter tags to delete:"))
|
||||||
|
if label is None:
|
||||||
|
label = _("Delete Tags")
|
||||||
if tags:
|
if tags:
|
||||||
n = _("Delete Tags")
|
|
||||||
self.parent.setProgressParent(self)
|
self.parent.setProgressParent(self)
|
||||||
self.deck.setUndoStart(n)
|
self.deck.setUndoStart(label)
|
||||||
self.deck.deleteTags(self.selectedFacts(), tags)
|
self.deck.deleteTags(self.selectedFacts(), tags)
|
||||||
self.deck.setUndoEnd(n)
|
self.deck.setUndoEnd(label)
|
||||||
self.parent.setProgressParent(None)
|
self.parent.setProgressParent(None)
|
||||||
self.updateAfterCardChange(reset=True)
|
self.updateAfterCardChange(reset=True)
|
||||||
|
|
||||||
def onSuspend(self):
|
def updateToggles(self):
|
||||||
|
self.dialog.actionToggleSuspend.setChecked(self.isSuspended())
|
||||||
|
self.dialog.actionToggleMark.setChecked(self.isMarked())
|
||||||
|
|
||||||
|
def isSuspended(self):
|
||||||
|
return self.currentCard and self.currentCard.priority == -3
|
||||||
|
|
||||||
|
def onSuspend(self, sus):
|
||||||
|
if sus:
|
||||||
|
self._onSuspend()
|
||||||
|
else:
|
||||||
|
self._onUnsuspend()
|
||||||
|
|
||||||
|
def _onSuspend(self):
|
||||||
n = _("Suspend")
|
n = _("Suspend")
|
||||||
self.parent.setProgressParent(self)
|
self.parent.setProgressParent(self)
|
||||||
self.deck.setUndoStart(n)
|
self.deck.setUndoStart(n)
|
||||||
|
@ -813,7 +843,7 @@ where id in (%s)""" % ",".join([
|
||||||
self.parent.setProgressParent(None)
|
self.parent.setProgressParent(None)
|
||||||
self.updateAfterCardChange(reset=True)
|
self.updateAfterCardChange(reset=True)
|
||||||
|
|
||||||
def onUnsuspend(self):
|
def _onUnsuspend(self):
|
||||||
n = _("Unsuspend")
|
n = _("Unsuspend")
|
||||||
self.parent.setProgressParent(self)
|
self.parent.setProgressParent(self)
|
||||||
self.deck.setUndoStart(n)
|
self.deck.setUndoStart(n)
|
||||||
|
@ -822,6 +852,21 @@ where id in (%s)""" % ",".join([
|
||||||
self.parent.setProgressParent(None)
|
self.parent.setProgressParent(None)
|
||||||
self.updateAfterCardChange(reset=True)
|
self.updateAfterCardChange(reset=True)
|
||||||
|
|
||||||
|
def isMarked(self):
|
||||||
|
return self.currentCard and "Marked" in self.currentCard.fact.tags
|
||||||
|
|
||||||
|
def onMark(self, mark):
|
||||||
|
if mark:
|
||||||
|
self._onMark()
|
||||||
|
else:
|
||||||
|
self._onUnmark()
|
||||||
|
|
||||||
|
def _onMark(self):
|
||||||
|
self.addTags(tags="Marked", label=_("Toggle Mark"))
|
||||||
|
|
||||||
|
def _onUnmark(self):
|
||||||
|
self.deleteTags(tags="Marked", label=_("Toggle Mark"))
|
||||||
|
|
||||||
def reschedule(self):
|
def reschedule(self):
|
||||||
n = _("Reschedule")
|
n = _("Reschedule")
|
||||||
d = QDialog(self)
|
d = QDialog(self)
|
||||||
|
|
|
@ -192,14 +192,14 @@
|
||||||
<string>&Actions</string>
|
<string>&Actions</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionAddItems"/>
|
<addaction name="actionAddItems"/>
|
||||||
|
<addaction name="actionAddCards"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAddTag"/>
|
<addaction name="actionAddTag"/>
|
||||||
<addaction name="actionDeleteTag"/>
|
<addaction name="actionDeleteTag"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionSuspend"/>
|
<addaction name="actionToggleSuspend"/>
|
||||||
<addaction name="actionUnsuspend"/>
|
<addaction name="actionToggleMark"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAddCards"/>
|
|
||||||
<addaction name="actionChangeModel"/>
|
<addaction name="actionChangeModel"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionCram"/>
|
<addaction name="actionCram"/>
|
||||||
|
@ -233,6 +233,33 @@
|
||||||
<addaction name="menuJump"/>
|
<addaction name="menuJump"/>
|
||||||
<addaction name="menu_Help"/>
|
<addaction name="menu_Help"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="actionAddItems"/>
|
||||||
|
<addaction name="actionAddCards"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionAddTag"/>
|
||||||
|
<addaction name="actionDeleteTag"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionToggleMark"/>
|
||||||
|
<addaction name="actionToggleSuspend"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionDelete"/>
|
||||||
|
</widget>
|
||||||
<action name="actionDelete">
|
<action name="actionDelete">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../icons.qrc">
|
<iconset resource="../icons.qrc">
|
||||||
|
@ -488,6 +515,30 @@
|
||||||
<string>Ctrl+D</string>
|
<string>Ctrl+D</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionToggleSuspend">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Toggle Suspend</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionToggleMark">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../icons.qrc">
|
||||||
|
<normaloff>:/icons/rating.png</normaloff>:/icons/rating.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Toggle Mark</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc"/>
|
<include location="../icons.qrc"/>
|
||||||
|
|
Loading…
Reference in a new issue