def createEditor(self, parent, option, index): if self.db and hasattr(self.db, self.items_func_name): m = index.model() col = m.column_map[index.column()] # If shifted, bring up the tag editor instead of the line editor. if check_key_modifier(Qt.ShiftModifier) and col != 'authors': key = col if m.is_custom_column(col) else None d = TagEditor(parent, self.db, m.id(index.row()), key=key) if d.exec_() == TagEditor.Accepted: m.setData(index, self.sep.join(d.tags), Qt.EditRole) return None editor = EditWithComplete(parent) editor.set_separator(self.sep) editor.set_space_before_sep(self.space_before_sep) if self.sep == '&': editor.set_add_separator(tweaks['authors_completer_append_separator']) if not m.is_custom_column(col): all_items = getattr(self.db, self.items_func_name)() else: all_items = list(self.db.all_custom( label=self.db.field_metadata.key_to_label(col))) editor.update_items_cache(all_items) else: editor = EnLineEdit(parent) return editor
def createEditor(self, parent, option, index): if self.db and hasattr(self.db, self.items_func_name): m = index.model() col = m.column_map[index.column()] # If shifted, bring up the tag editor instead of the line editor. if check_key_modifier(Qt.ShiftModifier) and col != 'authors': key = col if m.is_custom_column(col) else None d = TagEditor(parent, self.db, m.id(index.row()), key=key) if d.exec_() == TagEditor.Accepted: m.setData(index, self.sep.join(d.tags), Qt.EditRole) return None editor = EditWithComplete(parent) editor.set_separator(self.sep) editor.set_space_before_sep(self.space_before_sep) if self.sep == '&': editor.set_add_separator( tweaks['authors_completer_append_separator']) if not m.is_custom_column(col): all_items = getattr(self.db, self.items_func_name)() else: all_items = list( self.db.all_custom( label=self.db.field_metadata.key_to_label(col))) editor.update_items_cache(all_items) else: editor = EnLineEdit(parent) return editor
def tag_editor(self, *args): d = TagEditor(self, self.db, None) d.exec_() if d.result() == QDialog.Accepted: tag_string = ', '.join(d.tags) self.tags.setText(tag_string) self.tags.update_items_cache(self.db.all_tags()) self.remove_tags.update_items_cache(self.db.all_tags())
def edit_tags(self): from calibre.gui2.dialogs.tag_editor import TagEditor d = TagEditor(self, get_gui().current_db, current_tags=filter( None, [x.strip() for x in self.query.text().split(',')])) if d.exec_() == d.Accepted: self.query.setText(', '.join(d.tags))
def edit(self, widget): if widget.text(): d = _save_dialog(self.parent, _('Values changed'), _('You have entered values. In order to use this ' 'editor you must first discard them. ' 'Discard the values?')) if d == QMessageBox.Cancel or d == QMessageBox.No: return widget.setText('') d = TagEditor(self.parent, self.db, key=('#'+self.col_metadata['label'])) if d.exec_() == TagEditor.Accepted: val = d.tags if not val: val = [] widget.setText(self.col_metadata['multiple_seps']['list_to_ui'].join(val))
def edit(self): if (self.getter() != self.initial_val and (self.getter() or self.initial_val)): d = self._save_dialog(self.parent, _('Values changed'), _('You have changed the values. In order to use this ' 'editor, you must either discard or apply these ' 'changes. Apply changes?')) if d == QMessageBox.Cancel: return if d == QMessageBox.Yes: self.commit(self.book_id) self.db.commit() self.initial_val = self.current_val else: self.setter(self.initial_val) d = TagEditor(self.parent, self.db, self.book_id, self.key) if d.exec_() == TagEditor.Accepted: self.setter(d.tags)
def edit(self, db, id_): if self.changed: d = save_dialog(self, _('Tags changed'), _('You have changed the tags. In order to use the tags' ' editor, you must either discard or apply these ' 'changes. Apply changes?')) if d == QMessageBox.Cancel: return if d == QMessageBox.Yes: self.commit(db, id_) db.commit() self.original_val = self.current_val else: self.current_val = self.original_val d = TagEditor(self, db, id_) if d.exec_() == TagEditor.Accepted: self.current_val = d.tags self.all_items = db.all_tags()
def edit(self, db, id_): if self.changed: d = save_dialog( self, _('Tags changed'), _('You have changed the tags. In order to use the tags' ' editor, you must either discard or apply these ' 'changes. Apply changes?')) if d == QMessageBox.Cancel: return if d == QMessageBox.Yes: self.commit(db, id_) db.commit() self.original_val = self.current_val else: self.current_val = self.original_val d = TagEditor(self, db, id_) if d.exec_() == TagEditor.Accepted: self.current_val = d.tags self.all_items = db.all_tags()
def edit_tags(self): from calibre.gui2.dialogs.tag_editor import TagEditor d = TagEditor(self, get_gui().current_db, current_tags=filter(None, [x.strip() for x in self.query.text().split(',')])) if d.exec_() == d.Accepted: self.query.setText(', '.join(d.tags))