Ejemplo n.º 1
0
    def setupModels(self) -> None:
        self.model = None
        f = self.form
        box = f.buttonBox

        default_buttons = [
            (tr.actions_add(), self.onAdd),
            (tr.actions_rename(), self.onRename),
            (tr.actions_delete(), self.onDelete),
        ]

        if self.fromMain:
            default_buttons.extend([
                (tr.notetypes_fields(), self.onFields),
                (tr.notetypes_cards(), self.onCards),
            ])

        default_buttons.append((tr.notetypes_options(), self.onAdvanced))

        for label, func in gui_hooks.models_did_init_buttons(
                default_buttons, self):
            button = box.addButton(label, QDialogButtonBox.ActionRole)
            qconnect(button.clicked, func)

        qconnect(f.modelsList.itemDoubleClicked, self.onRename)

        def on_done(fut: Future) -> None:
            self.updateModelsList(fut.result())
            self.maybe_select_provided_notetype()

        self.mw.taskman.with_progress(self.col.models.all_use_counts, on_done,
                                      self)
        maybeHideClose(box)
Ejemplo n.º 2
0
 def _maybe_add_type_specific_actions(self, menu: QMenu,
                                      item: SidebarItem) -> None:
     if item.item_type in (SidebarItemType.NOTETYPE,
                           SidebarItemType.NOTETYPE_ROOT):
         menu.addAction(tr.browsing_manage_note_types(),
                        lambda: self.manage_notetype(item))
     elif item.item_type == SidebarItemType.NOTETYPE_TEMPLATE:
         menu.addAction(tr.notetypes_cards(),
                        lambda: self.manage_template(item))
     elif item.item_type == SidebarItemType.NOTETYPE_FIELD:
         menu.addAction(tr.notetypes_fields(),
                        lambda: self.manage_fields(item))
     elif item.item_type == SidebarItemType.SAVED_SEARCH_ROOT:
         menu.addAction(tr.browsing_sidebar_save_current_search(),
                        self.save_current_search)
     elif item.item_type == SidebarItemType.SAVED_SEARCH:
         menu.addAction(
             tr.browsing_update_saved_search(),
             lambda: self.update_saved_search(item),
         )
     elif item.item_type == SidebarItemType.TAG:
         if all(s.item_type == item.item_type
                for s in self._selected_items()):
             menu.addAction(tr.browsing_add_to_selected_notes(),
                            self.add_tags_to_selected_notes)
             menu.addAction(
                 tr.browsing_remove_from_selected_notes(),
                 self.remove_tags_from_selected_notes,
             )