add quick db check

This commit is contained in:
Damien Elmes 2009-05-16 02:47:27 +09:00
parent 233406f174
commit d205cd7602
2 changed files with 28 additions and 6 deletions

View file

@ -1926,7 +1926,8 @@ Couldn't contact Anki Online. Please check your internet connection.""")
self.connect(m.actionRepeatAudio, s, self.onRepeatAudio)
self.connect(m.actionUndo, s, self.onUndo)
self.connect(m.actionRedo, s, self.onRedo)
self.connect(m.actionCheckDatabaseIntegrity, s, self.onCheckDB)
self.connect(m.actionCheckDatabaseIntegrity, s, self.onQuickCheckDB)
self.connect(m.actionFullDatabaseCheck, s, self.onCheckDB)
self.connect(m.actionOptimizeDatabase, s, self.onOptimizeDB)
self.connect(m.actionCheckMediaDatabase, s, self.onCheckMediaDB)
self.connect(m.actionCram, s, self.onCram)
@ -2316,13 +2317,16 @@ Couldn't contact Anki Online. Please check your internet connection.""")
# Advanced features
##########################################################################
def onCheckDB(self):
def onQuickCheckDB(self):
self.onCheckDB(full=False)
def onCheckDB(self, full=True):
"True if no problems"
if self.errorOccurred:
ui.utils.showWarning(_(
"Please restart Anki before checking the DB."))
return
if not ui.utils.askUser(_("""\
if full and not ui.utils.askUser(_("""\
This operation will find and fix some common problems.<br>
<br>
On the next sync, all cards will be sent to the server.<br>
@ -2331,12 +2335,23 @@ Any changes on the server since your last sync will be lost.<br>
<b>This operation is not undoable.</b><br>
Proceed?""")):
return
ret = self.deck.fixIntegrity()
ret = self.deck.fixIntegrity(quick=not full)
if ret == "ok":
ret = True
else:
ret = _("Problems found:\n%s") % ret
ui.utils.showWarning(ret)
diag = QDialog(self)
diag.setWindowTitle("Anki")
layout = QVBoxLayout(diag)
diag.setLayout(layout)
text = QTextEdit()
text.setReadOnly(True)
text.setPlainText(ret)
layout.addWidget(text)
box = QDialogButtonBox(QDialogButtonBox.Close)
layout.addWidget(box)
self.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
diag.exec_()
ret = False
self.reset()
return ret

View file

@ -1209,6 +1209,7 @@
<string>Ad&amp;vanced</string>
</property>
<addaction name="actionCheckDatabaseIntegrity" />
<addaction name="actionFullDatabaseCheck" />
<addaction name="actionOptimizeDatabase" />
<addaction name="separator" />
<addaction name="actionCheckMediaDatabase" />
@ -1216,6 +1217,7 @@
<addaction name="actionUncacheLatex" />
<addaction name="separator" />
<addaction name="actionRecordNoiseProfile" />
<addaction name="separator" />
</widget>
<addaction name="actionGraphs" />
<addaction name="actionDstats" />
@ -1731,7 +1733,7 @@
<normaloff>:/icons/sqlitebrowser.png</normaloff>:/icons/sqlitebrowser.png</iconset>
</property>
<property name="text" >
<string>Check Database...</string>
<string>Quick Database Check</string>
</property>
<property name="statusTip" >
<string>Check the database for errors</string>
@ -1964,6 +1966,11 @@
<string>Ctrl+Shift+B</string>
</property>
</action>
<action name="actionFullDatabaseCheck" >
<property name="text" >
<string>Full Database Check...</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>newPerDay</tabstop>