Exemplo n.º 1
0
 def onHistory(self) -> None:
     m = QMenu(self)
     for nid in self.history:
         if self.mw.col.findNotes("nid:%s" % nid):
             fields = self.mw.col.getNote(nid).fields
             txt = htmlToTextLine(", ".join(fields))
             if len(txt) > 30:
                 txt = txt[:30] + "..."
             a = m.addAction(_('Edit "%s"') % txt)
             qconnect(a.triggered, lambda b, nid=nid: self.editHistory(nid))
         else:
             a = m.addAction(_("(Note deleted)"))
             a.setEnabled(False)
     gui_hooks.add_cards_will_show_history_menu(self, m)
     m.exec_(self.historyButton.mapToGlobal(QPoint(0, 0)))
Exemplo n.º 2
0
 def onHistory(self) -> None:
     m = QMenu(self)
     for nid in self.history:
         if self.mw.col.findNotes("nid:%s" % nid):
             note = self.mw.col.getNote(nid)
             fields = note.fields
             txt = htmlToTextLine(", ".join(fields))
             if len(txt) > 30:
                 txt = txt[:30] + "..."
             line = tr(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(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)))
Exemplo n.º 3
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)
             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)))
Exemplo n.º 4
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)))