Пример #1
0
    def show_template_editor(self, *args):
        view = self.gui.current_view()
        if view is not self.gui.library_view:
            return error_dialog(
                self.gui, _('No template tester available'),
                _('Template tester is not available for books '
                  'on the device.')).exec_()

        rows = view.selectionModel().selectedRows()
        if not rows:
            return error_dialog(self.gui,
                                _('No books selected'),
                                _('One book must be selected'),
                                show=True)
        if len(rows) > 1:
            return error_dialog(self.gui,
                                _('Selected multiple books'),
                                _('Only one book can be selected'),
                                show=True)

        index = rows[0]
        if index.isValid():
            db = view.model().db
            t = TemplateDialog(self.gui,
                               self.previous_text,
                               mi=db.get_metadata(index.row(),
                                                  index_is_id=False,
                                                  get_cover=False),
                               text_is_placeholder=self.first_time)
            t.setWindowTitle(_('Template tester'))
            if t.exec_() == t.Accepted:
                self.previous_text = t.rule[1]
                self.first_time = False
Пример #2
0
    def show_template_editor(self, *args):
        view = self.gui.current_view()
        if view is not self.gui.library_view:
            return error_dialog(
                self.gui, _('No template tester available'),
                _('Template tester is not available for books '
                  'on the device.')).exec_()

        rows = view.selectionModel().selectedRows()
        if not rows:
            return error_dialog(self.gui,
                                _('No books selected'),
                                _('At least one book must be selected'),
                                show=True)
        mi = []
        db = view.model().db
        for row in rows:
            if row.isValid():
                mi.append(
                    db.new_api.get_proxy_metadata(
                        db.data.index_to_id(row.row())))
        if mi:
            t = TemplateDialog(self.gui,
                               self.previous_text,
                               mi,
                               text_is_placeholder=self.first_time)
            t.setWindowTitle(_('Template tester'))
            if t.exec_() == QDialog.DialogCode.Accepted:
                self.previous_text = t.rule[1]
                self.first_time = False
Пример #3
0
 def edit_cb_title_template(self):
     t = TemplateDialog(self,
                        self.opt_cover_browser_title_template.text(),
                        fm=self.gui.current_db.field_metadata)
     t.setWindowTitle(_('Edit template for caption'))
     if t.exec_():
         self.opt_cover_browser_title_template.setText(t.rule[1])
Пример #4
0
    def show_template_editor(self, *args):
        view = self.gui.current_view()
        if view is not self.gui.library_view:
            return error_dialog(self.gui, _('No template tester available'),
                _('Template tester is not available for books '
                  'on the device.')).exec_()

        rows = view.selectionModel().selectedRows()
        if not rows:
            return error_dialog(self.gui, _('No books selected'),
                    _('One book must be selected'), show=True)
        if len(rows) > 1:
            return error_dialog(self.gui, _('Selected multiple books'),
                    _('Only one book can be selected'), show=True)

        index = rows[0]
        if index.isValid():
            db = view.model().db
            t = TemplateDialog(self.gui, self.previous_text,
                   mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False),
                   text_is_placeholder=self.first_time)
            t.setWindowTitle(_('Template tester'))
            if t.exec_() == t.Accepted:
                self.previous_text = t.rule[1]
                self.first_time = False
Пример #5
0
 def do_open_editor(self):
     t = TemplateDialog(self,
                        self.opt_template.text(),
                        fm=self.field_metadata)
     t.setWindowTitle(_('Edit template'))
     if t.exec_():
         self.opt_template.set_value(t.rule[1])
Пример #6
0
 def createEditor(self, parent, option, index):
     m = index.model()
     mi = m.db.get_metadata(index.row(), index_is_id=False)
     text = m.custom_columns[m.column_map[index.column()]]['display']['composite_template']
     editor = TemplateDialog(parent, text, mi)
     editor.setWindowTitle(_("Edit template"))
     editor.textbox.setTabChangesFocus(False)
     editor.textbox.setTabStopWidth(20)
     d = editor.exec_()
     if d:
         m.setData(index, (editor.rule[1]), Qt.EditRole)
     return None
Пример #7
0
 def createEditor(self, parent, option, index):
     m = index.model()
     mi = m.db.get_metadata(index.row(), index_is_id=False)
     text = m.custom_columns[m.column_map[index.column()]]['display']['composite_template']
     editor = TemplateDialog(parent, text, mi)
     editor.setWindowTitle(_("Edit template"))
     editor.textbox.setTabChangesFocus(False)
     editor.textbox.setTabStopWidth(20)
     d = editor.exec_()
     if d:
         m.setData(index, QVariant(editor.rule[1]), Qt.EditRole)
     return None
Пример #8
0
 def createEditor(self, parent, option, index):
     m = index.model()
     mi = m.db.get_metadata(index.row(), index_is_id=False)
     if check_key_modifier(Qt.KeyboardModifier.ControlModifier):
         text = ''
     else:
         text = m.custom_columns[m.column_map[index.column()]]['display']['composite_template']
     editor = TemplateDialog(parent, text, mi)
     editor.setWindowTitle(_("Edit template"))
     editor.textbox.setTabChangesFocus(False)
     editor.textbox.setTabStopWidth(20)
     d = editor.exec_()
     if d:
         m.setData(index, (editor.rule[1]), Qt.ItemDataRole.EditRole)
     return None
Пример #9
0
 def st_test_template(self):
     if self.mi:
         self.st_replace_button_clicked()
         all_funcs = copy.copy(formatter_functions().get_functions())
         for n, f in self.st_funcs.items():
             all_funcs[n] = f
         t = TemplateDialog(self.gui,
                            self.st_previous_text,
                            mi=self.mi,
                            fm=self.fm,
                            text_is_placeholder=self.st_first_time,
                            all_functions=all_funcs)
         t.setWindowTitle(_('Template tester'))
         if t.exec() == QDialog.DialogCode.Accepted:
             self.st_previous_text = t.rule[1]
             self.st_first_time = False
     else:
         error_dialog(self.gui,
                      _('Template functions'),
                      _('Cannot "test" when no books are selected'),
                      show=True)
Пример #10
0
    def show_template_editor(self, *args):
        view = self.gui.current_view()
        if view is not self.gui.library_view:
            return error_dialog(self.gui, _('No template tester available'),
                _('Template tester is not available for books '
                  'on the device.')).exec_()

        rows = view.selectionModel().selectedRows()
        if not rows:
            return error_dialog(self.gui, _('No books selected'),
                    _('One book must be selected'), show=True)
        if len(rows) > 1:
            return error_dialog(self.gui, _('Selected multiple books'),
                    _('Only one book can be selected'), show=True)

        index = rows[0]
        if index.isValid():
            db = view.model().db
            t = TemplateDialog(self.gui,
                   _('Enter a template to test using data from the selected book'),
                   mi=db.get_metadata(index.row(), index_is_id=False, get_cover=False))
            t.setWindowTitle(_('Template tester'))
            t.exec_()
Пример #11
0
 def edit_template(self):
     t = TemplateDialog(self, self.template)
     t.setWindowTitle(_('Edit template'))
     if t.exec_():
         self.t.setText(t.rule[1])
Пример #12
0
 def edit_template(self):
     t = TemplateDialog(self, self.template)
     t.setWindowTitle(_("Edit template"))
     if t.exec_():
         self.t.setText(t.rule[1])
Пример #13
0
 def open_editor(self):
     t = TemplateDialog(self, self.text(), mi=self.mi)
     t.setWindowTitle(_('Edit template'))
     if t.exec_():
         self.setText(t.rule[1])
Пример #14
0
 def edit_cb_title_template(self):
     t = TemplateDialog(self, self.opt_cover_browser_title_template.text(), fm=self.gui.current_db.field_metadata)
     t.setWindowTitle(_('Edit template for caption'))
     if t.exec_():
         self.opt_cover_browser_title_template.setText(t.rule[1])
Пример #15
0
 def open_editor(self):
     t = TemplateDialog(self, self.text(), mi=self.mi)
     t.setWindowTitle(_('Edit template'))
     if t.exec_():
         self.setText(t.rule[1])
Пример #16
0
 def do_open_editor(self):
     t = TemplateDialog(self, self.opt_template.text(), fm=self.field_metadata)
     t.setWindowTitle(_('Edit template'))
     if t.exec_():
         self.opt_template.set_value(t.rule[1])