mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
fix deletion of decks; allow deleting cards from default
https://anki.tenderapp.com/discussions/beta-testing/1967-2126-189-g7384df8f-crash-at-note-types-fields-save#comment_48353232
This commit is contained in:
parent
9baa8530d5
commit
0bf4fe400a
2 changed files with 6 additions and 6 deletions
|
@ -99,6 +99,8 @@ class DeckManager:
|
|||
|
||||
def rem(self, did: int, cardsToo: bool = True, childrenToo: bool = True) -> None:
|
||||
"Remove the deck. If cardsToo, delete any cards inside."
|
||||
if isinstance(did, str):
|
||||
did = int(did)
|
||||
assert cardsToo and childrenToo
|
||||
self.col.backend.remove_deck(did)
|
||||
|
||||
|
|
|
@ -231,23 +231,23 @@ where id > ?""",
|
|||
# Options
|
||||
##########################################################################
|
||||
|
||||
def _showOptions(self, did) -> None:
|
||||
def _showOptions(self, did: str) -> None:
|
||||
m = QMenu(self.mw)
|
||||
a = m.addAction(_("Rename"))
|
||||
qconnect(a.triggered, lambda b, did=did: self._rename(did))
|
||||
qconnect(a.triggered, lambda b, did=did: self._rename(int(did)))
|
||||
a = m.addAction(_("Options"))
|
||||
qconnect(a.triggered, lambda b, did=did: self._options(did))
|
||||
a = m.addAction(_("Export"))
|
||||
qconnect(a.triggered, lambda b, did=did: self._export(did))
|
||||
a = m.addAction(_("Delete"))
|
||||
qconnect(a.triggered, lambda b, did=did: self._delete(did))
|
||||
qconnect(a.triggered, lambda b, did=did: self._delete(int(did)))
|
||||
gui_hooks.deck_browser_will_show_options_menu(m, did)
|
||||
m.exec_(QCursor.pos())
|
||||
|
||||
def _export(self, did):
|
||||
self.mw.onExport(did=did)
|
||||
|
||||
def _rename(self, did):
|
||||
def _rename(self, did: int) -> None:
|
||||
self.mw.checkpoint(_("Rename Deck"))
|
||||
deck = self.mw.col.decks.get(did)
|
||||
oldName = deck["name"]
|
||||
|
@ -285,8 +285,6 @@ where id > ?""",
|
|||
self.show()
|
||||
|
||||
def _delete(self, did):
|
||||
if str(did) == "1":
|
||||
return showWarning(_("The default deck can't be deleted."))
|
||||
self.mw.checkpoint(_("Delete Deck"))
|
||||
deck = self.mw.col.decks.get(did)
|
||||
if not deck["dyn"]:
|
||||
|
|
Loading…
Reference in a new issue