diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py
index c37e749e4..25dccfa12 100644
--- a/ankiqt/ui/cardlist.py
+++ b/ankiqt/ui/cardlist.py
@@ -396,6 +396,7 @@ class EditDeck(QMainWindow):
self.dialog.tableView.horizontalHeader().setResizeMode(2, QHeaderView.ResizeToContents)
def setupMenus(self):
+ # actions
self.connect(self.dialog.actionDelete, SIGNAL("triggered()"), self.deleteCards)
self.connect(self.dialog.actionAddTag, SIGNAL("triggered()"), self.addTags)
self.connect(self.dialog.actionDeleteTag, SIGNAL("triggered()"), self.deleteTags)
@@ -405,6 +406,13 @@ class EditDeck(QMainWindow):
self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection)
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo)
+ # jumps
+ self.connect(self.dialog.actionFirstCard, SIGNAL("triggered()"), self.onFirstCard)
+ self.connect(self.dialog.actionLastCard, SIGNAL("triggered()"), self.onLastCard)
+ self.connect(self.dialog.actionPreviousCard, SIGNAL("triggered()"), self.onPreviousCard)
+ self.connect(self.dialog.actionNextCard, SIGNAL("triggered()"), self.onNextCard)
+ self.connect(self.dialog.actionFind, SIGNAL("triggered()"), self.onFind)
+ self.connect(self.dialog.actionFact, SIGNAL("triggered()"), self.onFact)
runHook('editor.setupMenus', self)
def onClose(self):
@@ -602,6 +610,43 @@ where id in (%s)""" % ",".join([
self.updateSearch()
self.updateAfterCardChange()
+ # Jumping
+ ######################################################################
+
+ def onFirstCard(self):
+ if not self.model.cards:
+ return
+ self.dialog.tableView.selectionModel().clear()
+ self.dialog.tableView.selectRow(0)
+
+ def onLastCard(self):
+ if not self.model.cards:
+ return
+ self.dialog.tableView.selectionModel().clear()
+ self.dialog.tableView.selectRow(len(self.model.cards) - 1)
+
+ def onPreviousCard(self):
+ if not self.model.cards:
+ return
+ row = self.dialog.tableView.currentIndex().row()
+ row = max(0, row - 1)
+ self.dialog.tableView.selectionModel().clear()
+ self.dialog.tableView.selectRow(row)
+
+ def onNextCard(self):
+ if not self.model.cards:
+ return
+ row = self.dialog.tableView.currentIndex().row()
+ row = min(len(self.model.cards) - 1, row + 1)
+ self.dialog.tableView.selectionModel().clear()
+ self.dialog.tableView.selectRow(row)
+
+ def onFind(self):
+ self.dialog.filterEdit.setFocus()
+
+ def onFact(self):
+ self.editor.focusFirst()
+
class AddCardChooser(QDialog):
def __init__(self, parent, cms):
@@ -644,4 +689,3 @@ order by ordinal""" % ids2str(self.cms))
def onHelp(self):
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
"Editor#AddCards"))
-
diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py
index 1f9b64b64..a8ae2b9f5 100644
--- a/ankiqt/ui/facteditor.py
+++ b/ankiqt/ui/facteditor.py
@@ -56,6 +56,10 @@ class FactEditor(object):
self.fontChanged = False
self.deck.setUndoBarrier()
+ def focusFirst(self):
+ if self.focusTarget:
+ self.focusTarget.setFocus()
+
def initMedia(self):
os.chdir(self.deck.mediaDir(create=True))
@@ -229,7 +233,7 @@ class FactEditor(object):
self.fields = {}
self.widgets = {}
n = 0
- first = None
+ first = True
for field in fields:
# label
l = QLabel(field.name)
@@ -251,6 +255,9 @@ class FactEditor(object):
self.onTextChanged)
w.connect(w, SIGNAL("currentCharFormatChanged(QTextCharFormat)"),
lambda w=w: self.formatChanged(w))
+ if first:
+ self.focusTarget = w
+ first = False
n += 1
# tags
self.fieldsGrid.addWidget(QLabel(_("Tags")), n, 0)
diff --git a/designer/cardlist.ui b/designer/cardlist.ui
index b5764844f..05cc217f8 100644
--- a/designer/cardlist.ui
+++ b/designer/cardlist.ui
@@ -6,7 +6,7 @@
0
0
599
- 602
+ 462
@@ -18,7 +18,7 @@
0
23
599
- 579
+ 439
@@ -196,8 +196,21 @@
+
+
@@ -280,6 +293,78 @@
&Invert Selection
+
+
+
+ :/icons/document-preview.png:/icons/document-preview.png
+
+
+ &Find
+
+
+ Ctrl+F
+
+
+
+
+
+ :/icons/Anki_Fact.png:/icons/Anki_Fact.png
+
+
+ F&act
+
+
+ Ctrl+Shift+F
+
+
+
+
+
+ :/icons/arrow-down.png:/icons/arrow-down.png
+
+
+ &Next Card
+
+
+ Ctrl+N
+
+
+
+
+
+ :/icons/arrow-up.png:/icons/arrow-up.png
+
+
+ &Previous Card
+
+
+ Ctrl+P
+
+
+
+
+
+ :/icons/arrow-up-double.png:/icons/arrow-up-double.png
+
+
+ F&irst Card
+
+
+ Ctrl+Home
+
+
+
+
+
+ :/icons/arrow-down-double.png:/icons/arrow-down-double.png
+
+
+ &Last Card
+
+
+ Ctrl+End
+
+
diff --git a/icons.qrc b/icons.qrc
index f2915a5f2..ad2a0a269 100644
--- a/icons.qrc
+++ b/icons.qrc
@@ -1,5 +1,9 @@
+ icons/arrow-down-double.png
+ icons/arrow-up-double.png
+ icons/arrow-down.png
+ icons/arrow-up.png
icons/view-pim-calendar.png
icons/anki-tag.png
icons/edit-redo.png
diff --git a/icons/arrow-down-double.png b/icons/arrow-down-double.png
new file mode 100644
index 000000000..7748c0114
Binary files /dev/null and b/icons/arrow-down-double.png differ
diff --git a/icons/arrow-down.png b/icons/arrow-down.png
new file mode 100644
index 000000000..7c9274f30
Binary files /dev/null and b/icons/arrow-down.png differ
diff --git a/icons/arrow-up-double.png b/icons/arrow-up-double.png
new file mode 100644
index 000000000..843194fa7
Binary files /dev/null and b/icons/arrow-up-double.png differ
diff --git a/icons/arrow-up.png b/icons/arrow-up.png
new file mode 100644
index 000000000..758a0d1af
Binary files /dev/null and b/icons/arrow-up.png differ