From 0dca3ef548efd348acf46f8b39a4992eddb7839b Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 22 May 2021 19:11:06 +0200 Subject: [PATCH 1/2] Check notetype count in browser.onChangeModel() --- qt/aqt/browser/browser.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index f16196a2a..d9ee930d8 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -528,7 +528,17 @@ where id in %s""" @skip_if_selection_is_empty @ensure_editor_saved 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: search = self.current_search() From ff76d5033843078d01b0784d020074f79161d7c4 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 22 May 2021 19:12:03 +0200 Subject: [PATCH 2/2] Remove browser.oneModelNotes() --- qt/aqt/browser/browser.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index d9ee930d8..8a2bb5245 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -498,21 +498,6 @@ class Browser(QMainWindow): def selectedNotesAsCards(self) -> Sequence[CardId]: return self.table.get_card_ids_from_selected_note_ids() - def oneModelNotes(self) -> Sequence[NoteId]: - sf = self.selected_notes() - if not sf: - return [] - mods = self.col.db.scalar( - """ -select count(distinct mid) from notes -where id in %s""" - % ids2str(sf) - ) - if mods > 1: - showInfo(tr.browsing_please_select_cards_from_only_one()) - return [] - return sf - def onHelp(self) -> None: openHelp(HelpPage.BROWSING)