mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Check notetype count in browser.onChangeModel()
This commit is contained in:
parent
195c41cba3
commit
0dca3ef548
1 changed files with 11 additions and 1 deletions
|
@ -528,7 +528,17 @@ where id in %s"""
|
||||||
@skip_if_selection_is_empty
|
@skip_if_selection_is_empty
|
||||||
@ensure_editor_saved
|
@ensure_editor_saved
|
||||||
def onChangeModel(self) -> None:
|
def onChangeModel(self) -> None:
|
||||||
ChangeModel(self, self.oneModelNotes())
|
ids = self.selected_notes()
|
||||||
|
if self._is_one_notetype(ids):
|
||||||
|
ChangeModel(self, ids)
|
||||||
|
else:
|
||||||
|
showInfo(tr.browsing_please_select_cards_from_only_one())
|
||||||
|
|
||||||
|
def _is_one_notetype(self, ids: Sequence[NoteId]) -> bool:
|
||||||
|
query = f"select count(distinct mid) from notes where id in {ids2str(ids)}"
|
||||||
|
if self.col.db.scalar(query) == 1:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def createFilteredDeck(self) -> None:
|
def createFilteredDeck(self) -> None:
|
||||||
search = self.current_search()
|
search = self.current_search()
|
||||||
|
|
Loading…
Reference in a new issue