def onHistory(self) -> None: m = QMenu(self) for nid in self.history: if self.col.find_notes( self.col.build_search_string(SearchNode(nid=nid))): note = self.col.get_note(nid) fields = note.fields txt = htmlToTextLine(", ".join(fields)) if len(txt) > 30: txt = f"{txt[:30]}..." line = tr.adding_edit(val=txt) line = gui_hooks.addcards_will_add_history_entry(line, note) a = m.addAction(line) qconnect(a.triggered, lambda b, nid=nid: self.editHistory(nid)) else: a = m.addAction(tr.adding_note_deleted()) a.setEnabled(False) gui_hooks.add_cards_will_show_history_menu(self, m) m.exec_(self.historyButton.mapToGlobal(QPoint(0, 0)))
def onHistory(self) -> None: m = QMenu(self) for nid in self.history: if self.col.find_notes( self.col.build_search_string(SearchNode(nid=nid))): note = self.col.get_note(nid) fields = note.fields txt = htmlToTextLine(", ".join(fields)) if len(txt) > 30: txt = f"{txt[:30]}..." line = tr.adding_edit(val=txt) line = gui_hooks.addcards_will_add_history_entry(line, note) line = line.replace("&", "&&") # In qt action "&i" means "underline i, trigger this line when i is pressed". # except for "&&" which is replaced by a single "&" a = m.addAction(line) qconnect(a.triggered, lambda b, nid=nid: self.editHistory(nid)) else: a = m.addAction(tr.adding_note_deleted()) a.setEnabled(False) gui_hooks.add_cards_will_show_history_menu(self, m) m.exec_(self.historyButton.mapToGlobal(QPoint(0, 0)))