mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -04:00
option to delete unselected cards when generating
This commit is contained in:
parent
d9299a6793
commit
722645d4b7
2 changed files with 19 additions and 2 deletions
|
@ -1185,15 +1185,20 @@ class GenCards(QDialog):
|
|||
|
||||
def accept(self):
|
||||
tplates = []
|
||||
unused = []
|
||||
for i, item in enumerate(self.items):
|
||||
idx = self.form.list.indexFromItem(item)
|
||||
if self.form.list.selectionModel().isSelected(idx):
|
||||
tplates.append(self.model.templates[i])
|
||||
self.genCards(tplates)
|
||||
else:
|
||||
unused.append(self.model.templates[i]['ord'])
|
||||
if not self.form.deleteUnsel.isChecked():
|
||||
unused = None
|
||||
self.genCards(tplates, unused)
|
||||
saveGeom(self, "addCardModels")
|
||||
QDialog.accept(self)
|
||||
|
||||
def genCards(self, tplates):
|
||||
def genCards(self, tplates, unused):
|
||||
mw = self.browser.mw
|
||||
mw.checkpoint(_("Generate Cards"))
|
||||
mw.progress.start()
|
||||
|
@ -1202,6 +1207,11 @@ class GenCards(QDialog):
|
|||
mw.deck.genCards(f, tplates)
|
||||
if c % 100 == 0:
|
||||
mw.progress.update()
|
||||
if unused:
|
||||
cids = mw.deck.db.list("""
|
||||
select id from cards where fid in %s and ord in %s""" % (
|
||||
ids2str(self.fids), ids2str(unused)))
|
||||
mw.deck.delCards(cids)
|
||||
mw.progress.finish()
|
||||
mw.requireReset()
|
||||
self.browser.onSearch()
|
||||
|
|
|
@ -28,6 +28,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="deleteUnsel">
|
||||
<property name="text">
|
||||
<string>Delete unselected cards</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in a new issue