mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
add jump to deck feature
This commit is contained in:
parent
aa45dd6031
commit
d469428471
4 changed files with 166 additions and 0 deletions
|
@ -814,6 +814,7 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
|
||||||
self.connect(m.actionDocumentation, s, self.onDocumentation)
|
self.connect(m.actionDocumentation, s, self.onDocumentation)
|
||||||
self.connect(m.actionDonate, s, self.onDonate)
|
self.connect(m.actionDonate, s, self.onDonate)
|
||||||
self.connect(m.actionFullSync, s, self.onFullSync)
|
self.connect(m.actionFullSync, s, self.onFullSync)
|
||||||
|
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
||||||
|
|
||||||
def updateTitleBar(self):
|
def updateTitleBar(self):
|
||||||
self.setWindowTitle("Anki")
|
self.setWindowTitle("Anki")
|
||||||
|
@ -946,6 +947,10 @@ Your edits have left some cards empty. Do you want to delete them?"""))
|
||||||
tooltip("Deleted.")
|
tooltip("Deleted.")
|
||||||
diag.close()
|
diag.close()
|
||||||
|
|
||||||
|
def onStudyDeck(self):
|
||||||
|
from aqt.studydeck import StudyDeck
|
||||||
|
StudyDeck(self)
|
||||||
|
|
||||||
# System specific code
|
# System specific code
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
70
aqt/studydeck.py
Normal file
70
aqt/studydeck.py
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from aqt.qt import *
|
||||||
|
import aqt, simplejson
|
||||||
|
from anki.utils import ids2str
|
||||||
|
from aqt.utils import showInfo, showWarning, openHelp, getOnlyText
|
||||||
|
from operator import itemgetter
|
||||||
|
|
||||||
|
class StudyDeck(QDialog):
|
||||||
|
def __init__(self, mw, first=False, search=""):
|
||||||
|
QDialog.__init__(self, mw)
|
||||||
|
self.mw = mw
|
||||||
|
self.form = aqt.forms.studydeck.Ui_Dialog()
|
||||||
|
self.form.setupUi(self)
|
||||||
|
self.form.filter.installEventFilter(self)
|
||||||
|
self.ok = self.form.buttonBox.addButton(
|
||||||
|
_("Study"), QDialogButtonBox.AcceptRole)
|
||||||
|
self.setWindowModality(Qt.WindowModal)
|
||||||
|
self.connect(self.form.buttonBox,
|
||||||
|
SIGNAL("helpRequested()"),
|
||||||
|
lambda: openHelp("studydeck"))
|
||||||
|
self.connect(self.form.filter,
|
||||||
|
SIGNAL("textEdited(QString)"),
|
||||||
|
self.redraw)
|
||||||
|
self.redraw("")
|
||||||
|
self.exec_()
|
||||||
|
|
||||||
|
def eventFilter(self, obj, evt):
|
||||||
|
if evt.type() == QEvent.KeyPress:
|
||||||
|
if evt.key() == Qt.Key_Up:
|
||||||
|
c = self.form.list.count()
|
||||||
|
row = self.form.list.currentRow() - 1
|
||||||
|
if row < 0:
|
||||||
|
row = c - 1
|
||||||
|
self.form.list.setCurrentRow(row)
|
||||||
|
return True
|
||||||
|
elif evt.key() == Qt.Key_Down:
|
||||||
|
c = self.form.list.count()
|
||||||
|
row = self.form.list.currentRow() + 1
|
||||||
|
if row == c:
|
||||||
|
row = 0
|
||||||
|
self.form.list.setCurrentRow(row)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def redraw(self, filt):
|
||||||
|
names = sorted(self.mw.col.decks.allNames())
|
||||||
|
self.names = [n for n in names if self._matches(n, filt)]
|
||||||
|
self.form.list.clear()
|
||||||
|
self.form.list.addItems(self.names)
|
||||||
|
self.form.list.setCurrentRow(0)
|
||||||
|
|
||||||
|
def _matches(self, name, filt):
|
||||||
|
name = name.lower()
|
||||||
|
filt = filt.lower()
|
||||||
|
if not filt:
|
||||||
|
return True
|
||||||
|
for c in filt:
|
||||||
|
if c not in name:
|
||||||
|
return False
|
||||||
|
name = name[name.index(c):]
|
||||||
|
return True
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
name = self.names[self.form.list.currentRow()]
|
||||||
|
self.mw.col.decks.select(self.mw.col.decks.id(name))
|
||||||
|
self.mw.moveToState("overview")
|
||||||
|
QDialog.accept(self)
|
|
@ -101,6 +101,8 @@
|
||||||
<addaction name="menuStartup"/>
|
<addaction name="menuStartup"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<addaction name="actionStudyDeck"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionCstats"/>
|
<addaction name="actionCstats"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionFullDatabaseCheck"/>
|
<addaction name="actionFullDatabaseCheck"/>
|
||||||
|
@ -249,6 +251,14 @@
|
||||||
<string>Full Sync...</string>
|
<string>Full Sync...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionStudyDeck">
|
||||||
|
<property name="text">
|
||||||
|
<string>Study Deck...</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>/</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
81
designer/studydeck.ui
Normal file
81
designer/studydeck.ui
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Study Deck</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Filter:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="filter"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="list"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
Loading…
Reference in a new issue