class ItemDelegate(QStyledItemDelegate): edited = pyqtSignal(object) def __init__(self, all_authors, parent): QStyledItemDelegate.__init__(self, parent) self.all_authors = all_authors def sizeHint(self, *args): return QStyledItemDelegate.sizeHint(self, *args) + QSize(0, 15) def setEditorData(self, editor, index): name = unicode_type(index.data(Qt.DisplayRole) or '') editor.setText(name) editor.lineEdit().selectAll() def setModelData(self, editor, model, index): authors = string_to_authors(unicode_type(editor.text())) model.setData(index, authors[0]) self.edited.emit(index.row()) def createEditor(self, parent, option, index): self.ed = EditWithComplete(parent) self.ed.setFocusPolicy(Qt.StrongFocus) init_line_edit(self.ed, self.all_authors) return self.ed
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 __init__(self, parent=None, show_saved_search_actions=False): EditWithComplete.__init__(self, parent) self.set_separator(None) self.show_saved_search_actions = show_saved_search_actions self.refresh() self.setToolTip(_('Choose a function to run on matched text (by name)')) boxes.append(weakref.ref(self))
class ItemDelegate(QStyledItemDelegate): edited = pyqtSignal(object) def __init__(self, all_authors, parent): QStyledItemDelegate.__init__(self, parent) self.all_authors = all_authors def sizeHint(self, *args): return QStyledItemDelegate.sizeHint(self, *args) + QSize(0, 15) def setEditorData(self, editor, index): name = unicode_type(index.data(Qt.DisplayRole) or '') editor.setText(name) editor.lineEdit().selectAll() def setModelData(self, editor, model, index): authors = string_to_authors(unicode_type(editor.text())) model.setData(index, authors[0]) self.edited.emit(index.row()) def createEditor(self, parent, option, index): self.ed = EditWithComplete(parent) self.ed.setFocusPolicy(Qt.StrongFocus) init_line_edit(self.ed, self.all_authors) return self.ed
def __init__(self, parent=None, show_saved_search_actions=False): EditWithComplete.__init__(self, parent) self.set_separator(None) self.show_saved_search_actions = show_saved_search_actions self.refresh() self.setToolTip(_('Choose a function to run on matched text (by name)')) boxes.append(weakref.ref(self))
def __init__(self, parent, db, author, series=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) self.create_epub = c = QCheckBox(_('Create an empty EPUB file as well')) c.setChecked(gprefs.get('create_empty_epub_file', False)) c.setToolTip(_('Also create an empty EPUB file that you can subsequently edit')) self._layout.addWidget(c, 6, 0, 1, -1) button_box = self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box, 7, 0, 1, -1) self.resize(self.sizeHint())
def createEditor(self, parent, option, index): m = index.model() col = m.column_map[index.column()] editor = EditWithComplete(parent) editor.set_separator(None) complete_items = sorted(list(m.db.all_custom(label=m.db.field_metadata.key_to_label(col))), key=sort_key) editor.update_items_cache(complete_items) return editor
def __init__(self, parent): EditWithComplete.__init__(self, parent) self.set_separator(None) self.dialog = parent self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setToolTip(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP) self.setEditable(True) self.books_to_refresh = set([])
def __init__(self, parent): EditWithComplete.__init__(self, parent) self.set_separator(None) self.dialog = parent self.setSizeAdjustPolicy( self.AdjustToMinimumContentsLengthWithIcon) self.setToolTip(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP) self.setEditable(True) self.books_to_refresh = set([])
def __init__(self, parent, manage_authors): self.dialog = parent self.books_to_refresh = set([]) EditWithComplete.__init__(self, parent) self.setToolTip(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP) self.setEditable(True) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.manage_authors_signal = manage_authors manage_authors.triggered.connect(self.manage_authors)
def __init__(self, parent, manage_authors): self.dialog = parent self.books_to_refresh = set([]) EditWithComplete.__init__(self, parent) self.setToolTip(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP) self.setEditable(True) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.manage_authors_signal = manage_authors manage_authors.triggered.connect(self.manage_authors)
def __init__(self, parent, db, author, series=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box) self.resize(self.sizeHint())
def __init__(self, parent=None, db=None): EditWithComplete.__init__(self, parent) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setMinimumContentsLength(20) self._lang_map = lang_map() self.names_with_commas = [x for x in self._lang_map.itervalues() if ',' in x] self.comma_map = {k:k.replace(',', '|') for k in self.names_with_commas} self.comma_rmap = {v:k for k, v in self.comma_map.iteritems()} self._rmap = {lower(v):k for k,v in self._lang_map.iteritems()} self.init_langs(db)
def createEditor(self, parent, option, index): m = index.model() col = m.column_map[index.column()] key = m.db.field_metadata.key_to_label(col) if m.db.field_metadata[col]['datatype'] != 'comments': editor = EditWithComplete(parent) editor.set_separator(None) complete_items = sorted(list(m.db.all_custom(label=key)), key=sort_key) editor.update_items_cache(complete_items) else: editor = QStyledItemDelegate.createEditor(self, parent, option, index) return editor
def __init__(self, parent): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) layout.addWidget(self.tags_box, stretch=1000) self.editor_button = QToolButton(self) self.editor_button.setToolTip(_('Open Item Editor')) self.editor_button.setIcon(QIcon(I('chapters.png'))) layout.addWidget(self.editor_button) self.setLayout(layout)
def createEditor(self, parent, option, index): if self.auto_complete_function: editor = EditWithComplete(parent) editor.set_separator(None) editor.set_clear_button_enabled(False) complete_items = [i[1] for i in self.auto_complete_function()] editor.update_items_cache(complete_items) else: editor = EnLineEdit(parent) return editor
def create_tags_edit(self, value, row): tags_edit = EditWithComplete(self) tags_edit.set_add_separator(False) tags_edit.update_items_cache(self.tags_values) tags_edit.setText(value) # tags_edit.editingFinished.connect(partial(self.tags_editing_finished, row, tags_edit)) return tags_edit
def __init__(self, parent, values): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) self.tags_box.update_items_cache(values) layout.addWidget(self.tags_box, stretch=3) self.checkbox = QCheckBox(_('Remove all tags'), parent) layout.addWidget(self.checkbox) layout.addStretch(1) self.setLayout(layout) self.checkbox.stateChanged[int].connect(self.box_touched)
class RemoveTags(QWidget): def __init__(self, parent, values): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) self.tags_box.update_items_cache(values) layout.addWidget(self.tags_box, stretch=3) self.remove_tags_button = QToolButton(parent) self.remove_tags_button.setToolTip(_('Open Item Editor')) self.remove_tags_button.setIcon(QIcon(I('chapters.png'))) layout.addWidget(self.remove_tags_button) self.checkbox = QCheckBox(_('Remove all tags'), parent) layout.addWidget(self.checkbox) layout.addStretch(1) self.setLayout(layout) self.checkbox.stateChanged[int].connect(self.box_touched) def box_touched(self, state): if state: self.tags_box.setText('') self.tags_box.setEnabled(False) else: self.tags_box.setEnabled(True)
def __init__(self, parent=None, db=None, prefs=None): self.prefs = prefs or gui_prefs() self.refresh_recently_used() EditWithComplete.__init__(self, parent, sort_func=self.sort_language_items_key) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setMinimumContentsLength(20) self._lang_map = lang_map_for_ui() self.names_with_commas = [x for x in itervalues(self._lang_map) if ',' in x] self.comma_map = {k:k.replace(',', '|') for k in self.names_with_commas} self.comma_rmap = {v:k for k, v in iteritems(self.comma_map)} self._rmap = {lower(v):k for k,v in iteritems(self._lang_map)} self.init_langs(db) self.item_selected.connect(self.update_recently_used)
def __init__(self, parent=None, db=None, prefs=None): self.prefs = prefs or gui_prefs() self.refresh_recently_used() EditWithComplete.__init__(self, parent, sort_func=self.sort_language_items_key) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setMinimumContentsLength(20) self._lang_map = lang_map_for_ui() self.names_with_commas = [x for x in self._lang_map.itervalues() if ',' in x] self.comma_map = {k:k.replace(',', '|') for k in self.names_with_commas} self.comma_rmap = {v:k for k, v in self.comma_map.iteritems()} self._rmap = {lower(v):k for k,v in self._lang_map.iteritems()} self.init_langs(db) self.item_selected.connect(self.update_recently_used)
def createEditor(self, parent, option, index): if self.auto_complete_function: editor = EditWithComplete(parent) editor.set_separator(None) complete_items = [i[1] for i in self.auto_complete_function()] editor.update_items_cache(complete_items) ct = index.data(Qt.DisplayRole).toString() editor.show_initial_value(ct) else: editor = EnLineEdit(parent) return editor
def __init__(self, parent=None, db=None): EditWithComplete.__init__(self, parent) self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon) self.setMinimumContentsLength(20) self._lang_map = lang_map() self.names_with_commas = [ x for x in self._lang_map.itervalues() if ',' in x ] self.comma_map = { k: k.replace(',', '|') for k in self.names_with_commas } self.comma_rmap = {v: k for k, v in self.comma_map.iteritems()} self._rmap = {lower(v): k for k, v in self._lang_map.iteritems()} self.init_langs(db)
def createEditor(self, parent, option, index): m = index.model() col = m.column_map[index.column()] key = m.db.field_metadata.key_to_label(col) if m.db.field_metadata[col]['datatype'] != 'comments': editor = EditWithComplete(parent) editor.set_separator(None) complete_items = sorted(list(m.db.all_custom(label=key)), key=sort_key) editor.update_items_cache(complete_items) else: editor = QLineEdit(parent) text = index.data(Qt.DisplayRole) if text: editor.setText(text) editor.selectAll() return editor
def createEditor(self, parent, option, index): if self.db and hasattr(self.db, self.items_func_name): col = index.model().column_map[index.column()] 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 index.model().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 create_tags_edit(self, value, row): tags_edit = EditWithComplete(self) tags_edit.set_add_separator(False) tags_edit.update_items_cache(self.tags_values) tags_edit.setText(value) # tags_edit.editingFinished.connect(partial(self.tags_editing_finished, row, tags_edit)) return tags_edit
def createEditor(self, parent, option, index): if self.completion_data: editor = EditWithComplete(parent) editor.set_separator(None) editor.update_items_cache(self.completion_data) else: editor = EnLineEdit(parent) return editor
def createEditor(self, parent, option, index): if index.column() == 0: if self.completion_data: from calibre.gui2.complete2 import EditWithComplete editor = EditWithComplete(parent) editor.set_separator(None) editor.update_items_cache(self.completion_data) else: from calibre.gui2.widgets import EnLineEdit editor = EnLineEdit(parent) return editor return QItemDelegate.createEditor(self, parent, option, index)
def createEditor(self, parent, option, index): m = index.model() col = m.column_map[index.column()] editor = EditWithComplete(parent) editor.set_separator(None) complete_items = sorted(list(m.db.all_custom(label=m.db.field_metadata.key_to_label(col))), key=sort_key) editor.update_items_cache(complete_items) return editor
def createEditor(self, parent, option, index): if self.auto_complete_function: editor = EditWithComplete(parent) editor.set_separator(None) complete_items = [i[1] for i in self.auto_complete_function()] editor.update_items_cache(complete_items) else: editor = EnLineEdit(parent) return editor
def setup_ui(self): from calibre.ebooks.constants import html5_tags self.l = l = QVBoxLayout(self) self.setLayout(l) self.la = la = QLabel(_('Specify the name of the &tag to insert:')) l.addWidget(la) self.tag_input = ti = EditWithComplete(self) ti.set_separator(None) ti.all_items = html5_tags | frozenset(tprefs['insert_tag_mru']) la.setBuddy(ti) l.addWidget(ti) l.addWidget(self.bb) ti.setFocus(Qt.OtherFocusReason)
def createEditor(self, parent, option, index): self.editing_started.emit(index.row()) if index.column() == 0: self.item = self.table.itemFromIndex(index) if self.item.is_deleted: return None if self.completion_data: editor = EditWithComplete(parent) editor.set_separator(None) editor.update_items_cache(self.completion_data) else: editor = EnLineEdit(parent) return editor return None
def createEditor(self, parent, option, index): m = index.model() col = m.column_map[index.column()] key = m.db.field_metadata.key_to_label(col) if m.db.field_metadata[col]['datatype'] != 'comments': editor = EditWithComplete(parent) editor.set_separator(None) complete_items = sorted(list(m.db.all_custom(label=key)), key=sort_key) editor.update_items_cache(complete_items) else: editor = QStyledItemDelegate.createEditor(self, parent, option, index) return editor
def setup_ui(self, parent): self.sep = self.col_metadata['multiple_seps'] self.key = self.db.field_metadata.label_to_key(self.col_metadata['label'], prefer_custom=True) self.parent = parent if self.col_metadata['is_multiple']: w = MultipleWidget(parent) w.set_separator(self.sep['ui_to_list']) if self.sep['ui_to_list'] == '&': w.set_space_before_sep(True) w.set_add_separator(tweaks['authors_completer_append_separator']) w.get_editor_button().clicked.connect(self.edit) w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) else: w = EditWithComplete(parent) w.set_separator(None) w.setSizeAdjustPolicy(w.AdjustToMinimumContentsLengthWithIcon) w.setMinimumContentsLength(25) self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), w]
class RemoveTags(QWidget): def __init__(self, parent, values): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) self.tags_box.update_items_cache(values) layout.addWidget(self.tags_box, stretch=3) self.checkbox = QCheckBox(_("Remove all tags"), parent) layout.addWidget(self.checkbox) layout.addStretch(1) self.setLayout(layout) self.checkbox.stateChanged[int].connect(self.box_touched) def box_touched(self, state): if state: self.tags_box.setText("") self.tags_box.setEnabled(False) else: self.tags_box.setEnabled(True)
class RemoveTags(QWidget): def __init__(self, parent, values): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) self.tags_box.update_items_cache(values) layout.addWidget(self.tags_box, stretch=3) self.checkbox = QCheckBox(_('Remove all tags'), parent) layout.addWidget(self.checkbox) layout.addStretch(1) self.setLayout(layout) self.connect(self.checkbox, SIGNAL('stateChanged(int)'), self.box_touched) def box_touched(self, state): if state: self.tags_box.setText('') self.tags_box.setEnabled(False) else: self.tags_box.setEnabled(True)
def __init__(self, parent, db, author): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box) self.resize(self.sizeHint())
def createEditor(self, parent, option, index): if self.db and hasattr(self.db, self.items_func_name): col = self.col if col is None: # We have not specified an explicit column, so we need # to lookup a column name. The calibre one will rely on stuff # on the model, we will rely on a callback function instead col = self.col_fn(index.column()) 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 col.startswith('#'): all_items = list(self.db.all_custom( label=self.db.field_metadata.key_to_label(col))) else: all_items = getattr(self.db, self.items_func_name)() editor.update_items_cache(all_items) for item in sorted(all_items, key=sort_key): editor.addItem(item) ct = index.data(Qt.DisplayRole).toString() editor.show_initial_value(ct) else: editor = EnLineEdit(parent) return editor
def keyPressEvent(self, ev): if ev.key() in (Qt.Key_Return, Qt.Key_Enter): ev.accept() self.returnPressed.emit() return return EditWithComplete.keyPressEvent(self, ev)
def createEditor(self, parent, option, index): self.ed = EditWithComplete(parent) self.ed.setFocusPolicy(Qt.StrongFocus) init_line_edit(self.ed, self.all_authors) return self.ed
def __init__(self, parent): EditWithComplete.__init__(self, parent) self.set_separator(None) self.setSizeAdjustPolicy( self.AdjustToMinimumContentsLengthWithIcon) self.books_to_refresh = set([])
def __init__(self, parent): EditWithComplete.__init__(self, parent) self.books_to_refresh = set([]) self.setToolTip(self.TOOLTIP) self.setWhatsThis(self.TOOLTIP)
def __init__(self, parent=None): EditWithComplete.__init__(self, parent, sort_func=lambda x:None)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(788, 663) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName("gridLayout") self.tabWidget = QtWidgets.QTabWidget(Form) self.tabWidget.setObjectName("tabWidget") self.tab = QtWidgets.QWidget() self.tab.setObjectName("tab") self.gridLayout_6 = QtWidgets.QGridLayout(self.tab) self.gridLayout_6.setObjectName("gridLayout_6") self.clear_history_button = QtWidgets.QPushButton(self.tab) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.clear_history_button.sizePolicy().hasHeightForWidth()) self.clear_history_button.setSizePolicy(sizePolicy) self.clear_history_button.setObjectName("clear_history_button") self.gridLayout_6.addWidget(self.clear_history_button, 6, 0, 1, 1) self.groupBox = QtWidgets.QGroupBox(self.tab) self.groupBox.setObjectName("groupBox") self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox) self.gridLayout_2.setObjectName("gridLayout_2") self.label = QtWidgets.QLabel(self.groupBox) self.label.setWordWrap(True) self.label.setObjectName("label") self.gridLayout_2.addWidget(self.label, 0, 0, 1, 2) self.opt_limit_search_columns = QtWidgets.QCheckBox(self.groupBox) self.opt_limit_search_columns.setObjectName("opt_limit_search_columns") self.gridLayout_2.addWidget(self.opt_limit_search_columns, 1, 0, 1, 2) self.label_2 = QtWidgets.QLabel(self.groupBox) self.label_2.setObjectName("label_2") self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) self.opt_limit_search_columns_to = EditWithComplete(self.groupBox) self.opt_limit_search_columns_to.setObjectName( "opt_limit_search_columns_to") self.gridLayout_2.addWidget(self.opt_limit_search_columns_to, 2, 1, 1, 1) self.label_3 = QtWidgets.QLabel(self.groupBox) self.label_3.setWordWrap(True) self.label_3.setObjectName("label_3") self.gridLayout_2.addWidget(self.label_3, 5, 0, 1, 2) self.gridLayout_6.addWidget(self.groupBox, 5, 0, 1, 2) self.opt_search_as_you_type = QtWidgets.QCheckBox(self.tab) self.opt_search_as_you_type.setObjectName("opt_search_as_you_type") self.gridLayout_6.addWidget(self.opt_search_as_you_type, 0, 0, 1, 2) self.opt_case_sensitive = QtWidgets.QCheckBox(self.tab) self.opt_case_sensitive.setObjectName("opt_case_sensitive") self.gridLayout_6.addWidget(self.opt_case_sensitive, 3, 0, 1, 1) self.opt_highlight_search_matches = QtWidgets.QCheckBox(self.tab) self.opt_highlight_search_matches.setObjectName( "opt_highlight_search_matches") self.gridLayout_6.addWidget(self.opt_highlight_search_matches, 1, 0, 1, 2) self.opt_show_highlight_toggle_button = QtWidgets.QCheckBox(self.tab) self.opt_show_highlight_toggle_button.setObjectName( "opt_show_highlight_toggle_button") self.gridLayout_6.addWidget(self.opt_show_highlight_toggle_button, 2, 0, 1, 2) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_6.addItem(spacerItem, 7, 0, 1, 1) self.opt_use_primary_find_in_search = QtWidgets.QCheckBox(self.tab) self.opt_use_primary_find_in_search.setObjectName( "opt_use_primary_find_in_search") self.gridLayout_6.addWidget(self.opt_use_primary_find_in_search, 4, 0, 1, 1) self.tabWidget.addTab(self.tab, "") self.tab_2 = QtWidgets.QWidget() self.tab_2.setObjectName("tab_2") self.gridLayout_4 = QtWidgets.QGridLayout(self.tab_2) self.gridLayout_4.setObjectName("gridLayout_4") self.groupBox_2 = QtWidgets.QGroupBox(self.tab_2) self.groupBox_2.setObjectName("groupBox_2") self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox_2) self.gridLayout_3.setObjectName("gridLayout_3") self.l12 = QtWidgets.QGridLayout() self.l12.setObjectName("l12") self.la10 = QtWidgets.QLabel(self.groupBox_2) self.la10.setObjectName("la10") self.l12.addWidget(self.la10, 0, 0, 1, 1) self.gst_names = QtWidgets.QComboBox(self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.gst_names.sizePolicy().hasHeightForWidth()) self.gst_names.setSizePolicy(sizePolicy) self.gst_names.setEditable(True) self.gst_names.setMinimumContentsLength(10) self.gst_names.setObjectName("gst_names") self.l12.addWidget(self.gst_names, 0, 1, 1, 1) self.gst_delete_button = QtWidgets.QToolButton(self.groupBox_2) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(I("trash.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.gst_delete_button.setIcon(icon) self.gst_delete_button.setObjectName("gst_delete_button") self.l12.addWidget(self.gst_delete_button, 0, 2, 1, 1) self.la112 = QtWidgets.QLabel(self.groupBox_2) self.la112.setObjectName("la112") self.l12.addWidget(self.la112, 1, 0, 1, 1) self.gst_value = EditWithComplete(self.groupBox_2) self.gst_value.setObjectName("gst_value") self.l12.addWidget(self.gst_value, 1, 1, 1, 1) self.hboxlayout = QtWidgets.QHBoxLayout() self.hboxlayout.setObjectName("hboxlayout") self.gst_save_button = QtWidgets.QToolButton(self.groupBox_2) self.gst_save_button.setObjectName("gst_save_button") self.hboxlayout.addWidget(self.gst_save_button) self.l12.addLayout(self.hboxlayout, 2, 0, 1, 3) self.gridLayout_3.addLayout(self.l12, 0, 0, 1, 1) self.gst_explanation = QtWidgets.QTextBrowser(self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(100) sizePolicy.setHeightForWidth( self.gst_explanation.sizePolicy().hasHeightForWidth()) self.gst_explanation.setSizePolicy(sizePolicy) self.gst_explanation.setObjectName("gst_explanation") self.gridLayout_3.addWidget(self.gst_explanation, 0, 1, 3, 1) self.user_category_layout = QtWidgets.QHBoxLayout() self.user_category_layout.setObjectName("user_category_layout") self.l11 = QtWidgets.QLabel(self.groupBox_2) self.l11.setObjectName("l11") self.user_category_layout.addWidget(self.l11) self.opt_grouped_search_make_user_categories = EditWithComplete( self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.opt_grouped_search_make_user_categories.sizePolicy( ).hasHeightForWidth()) self.opt_grouped_search_make_user_categories.setSizePolicy(sizePolicy) self.opt_grouped_search_make_user_categories.setObjectName( "opt_grouped_search_make_user_categories") self.user_category_layout.addWidget( self.opt_grouped_search_make_user_categories) self.gridLayout_3.addLayout(self.user_category_layout, 1, 0, 1, 1) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_3.addItem(spacerItem1, 2, 0, 1, 1) self.gridLayout_4.addWidget(self.groupBox_2, 0, 0, 1, 1) self.tabWidget.addTab(self.tab_2, "") self.tab_3 = QtWidgets.QWidget() self.tab_3.setObjectName("tab_3") self.gridLayout_5 = QtWidgets.QGridLayout(self.tab_3) self.gridLayout_5.setObjectName("gridLayout_5") self.groupBox22 = QtWidgets.QGroupBox(self.tab_3) self.groupBox22.setObjectName("groupBox22") self.gridLayout_22 = QtWidgets.QGridLayout(self.groupBox22) self.gridLayout_22.setObjectName("gridLayout_22") self.label1 = QtWidgets.QLabel(self.groupBox22) self.label1.setWordWrap(True) self.label1.setObjectName("label1") self.gridLayout_22.addWidget(self.label1, 0, 0, 1, 6) self.label_221 = QtWidgets.QLabel(self.groupBox22) self.label_221.setObjectName("label_221") self.gridLayout_22.addWidget(self.label_221, 1, 0, 1, 1) self.similar_authors_search_key = QtWidgets.QComboBox(self.groupBox22) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(10) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.similar_authors_search_key.sizePolicy().hasHeightForWidth()) self.similar_authors_search_key.setSizePolicy(sizePolicy) self.similar_authors_search_key.setObjectName( "similar_authors_search_key") self.gridLayout_22.addWidget(self.similar_authors_search_key, 1, 1, 1, 1) self.opt_similar_authors_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_authors_match_kind.setObjectName( "opt_similar_authors_match_kind") self.gridLayout_22.addWidget(self.opt_similar_authors_match_kind, 1, 2, 1, 1) self.label_222 = QtWidgets.QLabel(self.groupBox22) self.label_222.setObjectName("label_222") self.gridLayout_22.addWidget(self.label_222, 1, 3, 1, 1) self.similar_series_search_key = QtWidgets.QComboBox(self.groupBox22) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(10) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.similar_series_search_key.sizePolicy().hasHeightForWidth()) self.similar_series_search_key.setSizePolicy(sizePolicy) self.similar_series_search_key.setObjectName( "similar_series_search_key") self.gridLayout_22.addWidget(self.similar_series_search_key, 1, 4, 1, 1) self.opt_similar_series_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_series_match_kind.setObjectName( "opt_similar_series_match_kind") self.gridLayout_22.addWidget(self.opt_similar_series_match_kind, 1, 5, 1, 1) self.label_223 = QtWidgets.QLabel(self.groupBox22) self.label_223.setObjectName("label_223") self.gridLayout_22.addWidget(self.label_223, 2, 0, 1, 1) self.similar_tags_search_key = QtWidgets.QComboBox(self.groupBox22) self.similar_tags_search_key.setObjectName("similar_tags_search_key") self.gridLayout_22.addWidget(self.similar_tags_search_key, 2, 1, 1, 1) self.opt_similar_tags_match_kind = QtWidgets.QComboBox(self.groupBox22) self.opt_similar_tags_match_kind.setObjectName( "opt_similar_tags_match_kind") self.gridLayout_22.addWidget(self.opt_similar_tags_match_kind, 2, 2, 1, 1) self.label_224 = QtWidgets.QLabel(self.groupBox22) self.label_224.setObjectName("label_224") self.gridLayout_22.addWidget(self.label_224, 2, 3, 1, 1) self.similar_publisher_search_key = QtWidgets.QComboBox( self.groupBox22) self.similar_publisher_search_key.setObjectName( "similar_publisher_search_key") self.gridLayout_22.addWidget(self.similar_publisher_search_key, 2, 4, 1, 1) self.opt_similar_publisher_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_publisher_match_kind.setObjectName( "opt_similar_publisher_match_kind") self.gridLayout_22.addWidget(self.opt_similar_publisher_match_kind, 2, 5, 1, 1) spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_22.addItem(spacerItem2, 3, 1, 1, 1) self.gridLayout_5.addWidget(self.groupBox22, 0, 0, 1, 1) self.tabWidget.addTab(self.tab_3, "") self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) self.label_2.setBuddy(self.opt_limit_search_columns_to) self.la10.setBuddy(self.gst_names) self.la112.setBuddy(self.gst_value) self.l11.setBuddy(self.opt_grouped_search_make_user_categories) self.label_221.setBuddy(self.similar_authors_search_key) self.label_222.setBuddy(self.similar_series_search_key) self.label_223.setBuddy(self.similar_tags_search_key) self.label_224.setBuddy(self.similar_publisher_search_key) self.retranslateUi(Form) self.tabWidget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(Form)
def __init__(self, parent, db, author, series=None, title=None, dup_title=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.series_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) self.title_label = QLabel(_('Set the title of the new books to:')) self._layout.addWidget(self.title_label, 6, 0, 1, 2) self.title_edit = QLineEdit(self) self.title_edit.setText(title or '') self._layout.addWidget(self.title_edit, 7, 0, 1, 1) self.tclear_button = QToolButton(self) self.tclear_button.setIcon(QIcon(I('trash.png'))) self.tclear_button.setToolTip(_('Reset title')) self.tclear_button.clicked.connect(self.title_edit.clear) self._layout.addWidget(self.tclear_button, 7, 1, 1, 1) self.format_label = QLabel(_('Also create an empty e-book in format:')) self._layout.addWidget(self.format_label, 8, 0, 1, 2) c = self.format_value = QComboBox(self) from calibre.ebooks.oeb.polish.create import valid_empty_formats possible_formats = [''] + sorted(x.upper() for x in valid_empty_formats) c.addItems(possible_formats) c.setToolTip(_('Also create an empty book format file that you can subsequently edit')) if gprefs.get('create_empty_epub_file', False): # Migration of the check box gprefs.set('create_empty_format_file', 'epub') del gprefs['create_empty_epub_file'] use_format = gprefs.get('create_empty_format_file', '').upper() try: c.setCurrentIndex(possible_formats.index(use_format)) except Exception: pass self._layout.addWidget(c, 9, 0, 1, 1) self.copy_formats = cf = QCheckBox(_('Also copy book &formats when duplicating a book'), self) cf.setToolTip(_( 'Also copy all e-book files into the newly created duplicate' ' books.')) cf.setChecked(gprefs.get('create_empty_copy_dup_formats', False)) self._layout.addWidget(cf, 10, 0, 1, -1) button_box = self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box, 11, 0, 1, -1) if dup_title: self.dup_button = b = button_box.addButton(_('&Duplicate current book'), button_box.ActionRole) b.clicked.connect(self.do_duplicate_book) b.setIcon(QIcon(I('edit-copy.png'))) b.setToolTip(_( 'Make the new empty book records exact duplicates\n' 'of the current book "%s", with all metadata identical' ) % dup_title) self.resize(self.sizeHint()) self.duplicate_current_book = False
def setup_ui(self, parent): w = EditWithComplete(parent) w.set_separator(None) w.setSizeAdjustPolicy(w.AdjustToMinimumContentsLengthWithIcon) w.setMinimumContentsLength(25) self.name_widget = w self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent), w] w.editTextChanged.connect(self.series_changed) self.widgets.append(QLabel('&'+self.col_metadata['name']+_(' index:'), parent)) w = QDoubleSpinBox(parent) w.setRange(-10000., float(100000000)) w.setDecimals(2) w.setSingleStep(1) self.idx_widget=w self.widgets.append(w)
def __init__(self, parent, db, author, series=None, title=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.series_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) self.title_label = QLabel(_('Set the title of the new books to:')) self._layout.addWidget(self.title_label, 6, 0, 1, 2) self.title_edit = QLineEdit(self) self.title_edit.setText(title or '') self._layout.addWidget(self.title_edit, 7, 0, 1, 1) self.tclear_button = QToolButton(self) self.tclear_button.setIcon(QIcon(I('trash.png'))) self.tclear_button.setToolTip(_('Reset title')) self.tclear_button.clicked.connect(self.title_edit.clear) self._layout.addWidget(self.tclear_button, 7, 1, 1, 1) self.format_label = QLabel(_('Also create an empty ebook in format:')) self._layout.addWidget(self.format_label, 8, 0, 1, 2) c = self.format_value = QComboBox(self) from calibre.ebooks.oeb.polish.create import valid_empty_formats possible_formats = [''] + sorted(x.upper() for x in valid_empty_formats) c.addItems(possible_formats) c.setToolTip(_('Also create an empty book format file that you can subsequently edit')) if gprefs.get('create_empty_epub_file', False): # Migration of the check box gprefs.set('create_empty_format_file', 'epub') del gprefs['create_empty_epub_file'] use_format = gprefs.get('create_empty_format_file', '').upper() try: c.setCurrentIndex(possible_formats.index(use_format)) except Exception: pass self._layout.addWidget(c, 9, 0, 1, 1) button_box = self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box, 10, 0, 1, -1) self.resize(self.sizeHint())
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(731, 411) Dialog.setWindowTitle(_("Advanced Search")) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(I("search.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off) Dialog.setWindowIcon(icon) self.gridLayout_2 = QtGui.QGridLayout(Dialog) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.label_5 = QtGui.QLabel(Dialog) self.label_5.setText(_("&What kind of match to use:")) self.label_5.setObjectName(_fromUtf8("label_5")) self.gridLayout_2.addWidget(self.label_5, 0, 0, 1, 1) self.matchkind = QtGui.QComboBox(Dialog) self.matchkind.setObjectName(_fromUtf8("matchkind")) self.matchkind.addItem(_fromUtf8("")) self.matchkind.setItemText(0, _("Contains: the word or phrase matches anywhere in the metadata field")) self.matchkind.addItem(_fromUtf8("")) self.matchkind.setItemText(1, _("Equals: the word or phrase must match the entire metadata field")) self.matchkind.addItem(_fromUtf8("")) self.matchkind.setItemText(2, _("Regular expression: the expression must match anywhere in the metadata field")) self.gridLayout_2.addWidget(self.matchkind, 0, 1, 1, 1) self.tabWidget = QtGui.QTabWidget(Dialog) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.tab = QtGui.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.gridLayout_3 = QtGui.QGridLayout(self.tab) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.groupBox = QtGui.QGroupBox(self.tab) self.groupBox.setTitle(_("Find entries that have...")) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.label = QtGui.QLabel(self.groupBox) self.label.setText(_("&All these words:")) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout.addWidget(self.label) self.all = QtGui.QLineEdit(self.groupBox) self.all.setObjectName(_fromUtf8("all")) self.horizontalLayout.addWidget(self.all) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_2 = QtGui.QLabel(self.groupBox) self.label_2.setText(_("This exact &phrase:")) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout_2.addWidget(self.label_2) self.phrase = QtGui.QLineEdit(self.groupBox) self.phrase.setObjectName(_fromUtf8("phrase")) self.horizontalLayout_2.addWidget(self.phrase) self.verticalLayout.addLayout(self.horizontalLayout_2) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.label_3 = QtGui.QLabel(self.groupBox) self.label_3.setText(_("&One or more of these words:")) self.label_3.setObjectName(_fromUtf8("label_3")) self.horizontalLayout_3.addWidget(self.label_3) self.any = QtGui.QLineEdit(self.groupBox) self.any.setObjectName(_fromUtf8("any")) self.horizontalLayout_3.addWidget(self.any) self.verticalLayout.addLayout(self.horizontalLayout_3) self.gridLayout_3.addWidget(self.groupBox, 0, 0, 1, 1) self.groupBox_2 = QtGui.QGroupBox(self.tab) self.groupBox_2.setTitle(_("But dont show entries that have...")) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_2) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_4 = QtGui.QLabel(self.groupBox_2) self.label_4.setText(_("Any of these &unwanted words:")) self.label_4.setObjectName(_fromUtf8("label_4")) self.horizontalLayout_4.addWidget(self.label_4) self.none = QtGui.QLineEdit(self.groupBox_2) self.none.setObjectName(_fromUtf8("none")) self.horizontalLayout_4.addWidget(self.none) self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.label_6 = QtGui.QLabel(self.groupBox_2) self.label_6.setMaximumSize(QtCore.QSize(16777215, 30)) self.label_6.setText(_("See the <a href=\"http://manual.calibre-ebook.com/gui.html#the-search-interface\">User Manual</a> for more help")) self.label_6.setOpenExternalLinks(True) self.label_6.setObjectName(_fromUtf8("label_6")) self.verticalLayout_2.addWidget(self.label_6) self.gridLayout_3.addWidget(self.groupBox_2, 1, 0, 1, 1) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout_3.addItem(spacerItem, 2, 0, 1, 1) self.buttonBox = QtGui.QDialogButtonBox(self.tab) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.gridLayout_3.addWidget(self.buttonBox, 3, 0, 1, 1) self.tabWidget.addTab(self.tab, _fromUtf8("")) self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName(_fromUtf8("tab_2")) self.gridLayout = QtGui.QGridLayout(self.tab_2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.label_7 = QtGui.QLabel(self.tab_2) self.label_7.setText(_("&Title:")) self.label_7.setObjectName(_fromUtf8("label_7")) self.gridLayout.addWidget(self.label_7, 1, 0, 1, 1) self.title_box = EnLineEdit(self.tab_2) self.title_box.setToolTip(_("Enter the title.")) self.title_box.setObjectName(_fromUtf8("title_box")) self.gridLayout.addWidget(self.title_box, 1, 1, 1, 1) self.label_8 = QtGui.QLabel(self.tab_2) self.label_8.setText(_("&Author:")) self.label_8.setObjectName(_fromUtf8("label_8")) self.gridLayout.addWidget(self.label_8, 2, 0, 1, 1) self.label_9 = QtGui.QLabel(self.tab_2) self.label_9.setText(_("&Series:")) self.label_9.setObjectName(_fromUtf8("label_9")) self.gridLayout.addWidget(self.label_9, 3, 0, 1, 1) self.label_10 = QtGui.QLabel(self.tab_2) self.label_10.setText(_("Ta&gs:")) self.label_10.setObjectName(_fromUtf8("label_10")) self.gridLayout.addWidget(self.label_10, 4, 0, 1, 1) self.authors_box = EditWithComplete(self.tab_2) self.authors_box.setToolTip(_("Enter an author\'s name. Only one author can be used.")) self.authors_box.setObjectName(_fromUtf8("authors_box")) self.gridLayout.addWidget(self.authors_box, 2, 1, 1, 1) self.series_box = EditWithComplete(self.tab_2) self.series_box.setToolTip(_("Enter a series name, without an index. Only one series name can be used.")) self.series_box.setObjectName(_fromUtf8("series_box")) self.gridLayout.addWidget(self.series_box, 3, 1, 1, 1) self.tags_box = EditWithComplete(self.tab_2) self.tags_box.setToolTip(_("Enter tags separated by spaces")) self.tags_box.setObjectName(_fromUtf8("tags_box")) self.gridLayout.addWidget(self.tags_box, 4, 1, 1, 1) self.general_box = QtGui.QLineEdit(self.tab_2) self.general_box.setObjectName(_fromUtf8("general_box")) self.gridLayout.addWidget(self.general_box, 6, 1, 1, 1) self.general_combo = QtGui.QComboBox(self.tab_2) self.general_combo.setObjectName(_fromUtf8("general_combo")) self.gridLayout.addWidget(self.general_combo, 6, 0, 1, 1) self.horizontalLayout_6 = QtGui.QHBoxLayout() self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.clear_button = QtGui.QPushButton(self.tab_2) self.clear_button.setText(_("&Clear")) self.clear_button.setObjectName(_fromUtf8("clear_button")) self.horizontalLayout_6.addWidget(self.clear_button) self.tab_2_button_box = QtGui.QDialogButtonBox(self.tab_2) self.tab_2_button_box.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.tab_2_button_box.setObjectName(_fromUtf8("tab_2_button_box")) self.horizontalLayout_6.addWidget(self.tab_2_button_box) self.gridLayout.addLayout(self.horizontalLayout_6, 8, 0, 1, 2) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem1, 7, 1, 1, 1) self.label_11 = QtGui.QLabel(self.tab_2) self.label_11.setText(_("Search only in specific fields:")) self.label_11.setObjectName(_fromUtf8("label_11")) self.gridLayout.addWidget(self.label_11, 0, 0, 1, 2) self.tabWidget.addTab(self.tab_2, _fromUtf8("")) self.gridLayout_2.addWidget(self.tabWidget, 2, 0, 1, 2) spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout_2.addItem(spacerItem2, 1, 1, 1, 1) self.label_5.setBuddy(self.matchkind) self.label.setBuddy(self.all) self.label_2.setBuddy(self.all) self.label_3.setBuddy(self.all) self.label_4.setBuddy(self.all) self.label_7.setBuddy(self.title_box) self.label_8.setBuddy(self.authors_box) self.label_9.setBuddy(self.series_box) self.label_10.setBuddy(self.tags_box) self.retranslateUi(Dialog) self.tabWidget.setCurrentIndex(0) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject) QtCore.QMetaObject.connectSlotsByName(Dialog) Dialog.setTabOrder(self.all, self.phrase) Dialog.setTabOrder(self.phrase, self.any) Dialog.setTabOrder(self.any, self.none) Dialog.setTabOrder(self.none, self.buttonBox) Dialog.setTabOrder(self.buttonBox, self.title_box) Dialog.setTabOrder(self.title_box, self.authors_box) Dialog.setTabOrder(self.authors_box, self.series_box) Dialog.setTabOrder(self.series_box, self.tags_box) Dialog.setTabOrder(self.tags_box, self.general_combo) Dialog.setTabOrder(self.general_combo, self.general_box) Dialog.setTabOrder(self.general_box, self.clear_button) Dialog.setTabOrder(self.clear_button, self.tab_2_button_box)
def createEditor(self, parent, option, index): if self.db and hasattr(self.db, self.items_func_name): col = self.col if col is None: # We have not specified an explicit column, so we need # to lookup a column name. The calibre one will rely on stuff # on the model, we will rely on a callback function instead col = self.col_fn(index.column()) 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 col.startswith('#'): all_items = list( self.db.all_custom( label=self.db.field_metadata.key_to_label(col))) else: all_items = getattr(self.db, self.items_func_name)() editor.update_items_cache(all_items) for item in sorted(all_items, key=sort_key): editor.addItem(item) ct = index.data(Qt.DisplayRole).toString() editor.show_initial_value(ct) else: editor = EnLineEdit(parent) return editor
class MultipleWidget(QWidget): def __init__(self, parent): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(5) layout.setContentsMargins(0, 0, 0, 0) self.tags_box = EditWithComplete(parent) layout.addWidget(self.tags_box, stretch=1000) self.editor_button = QToolButton(self) self.editor_button.setToolTip(_('Open Item Editor')) self.editor_button.setIcon(QIcon(I('chapters.png'))) layout.addWidget(self.editor_button) self.setLayout(layout) def get_editor_button(self): return self.editor_button def update_items_cache(self, values): self.tags_box.update_items_cache(values) def clear(self): self.tags_box.clear() def setEditText(self): self.tags_box.setEditText() def addItem(self, itm): self.tags_box.addItem(itm) def set_separator(self, sep): self.tags_box.set_separator(sep) def set_add_separator(self, sep): self.tags_box.set_add_separator(sep) def set_space_before_sep(self, v): self.tags_box.set_space_before_sep(v) def setSizePolicy(self, v1, v2): self.tags_box.setSizePolicy(v1, v2) def setText(self, v): self.tags_box.setText(v) def text(self): return self.tags_box.text()
class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(788, 663) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName("gridLayout") self.tabWidget = QtWidgets.QTabWidget(Form) self.tabWidget.setObjectName("tabWidget") self.tab = QtWidgets.QWidget() self.tab.setObjectName("tab") self.gridLayout_6 = QtWidgets.QGridLayout(self.tab) self.gridLayout_6.setObjectName("gridLayout_6") self.clear_history_button = QtWidgets.QPushButton(self.tab) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.clear_history_button.sizePolicy().hasHeightForWidth()) self.clear_history_button.setSizePolicy(sizePolicy) self.clear_history_button.setObjectName("clear_history_button") self.gridLayout_6.addWidget(self.clear_history_button, 6, 0, 1, 1) self.groupBox = QtWidgets.QGroupBox(self.tab) self.groupBox.setObjectName("groupBox") self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox) self.gridLayout_2.setObjectName("gridLayout_2") self.label = QtWidgets.QLabel(self.groupBox) self.label.setWordWrap(True) self.label.setObjectName("label") self.gridLayout_2.addWidget(self.label, 0, 0, 1, 2) self.opt_limit_search_columns = QtWidgets.QCheckBox(self.groupBox) self.opt_limit_search_columns.setObjectName("opt_limit_search_columns") self.gridLayout_2.addWidget(self.opt_limit_search_columns, 1, 0, 1, 2) self.label_2 = QtWidgets.QLabel(self.groupBox) self.label_2.setObjectName("label_2") self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) self.opt_limit_search_columns_to = EditWithComplete(self.groupBox) self.opt_limit_search_columns_to.setObjectName( "opt_limit_search_columns_to") self.gridLayout_2.addWidget(self.opt_limit_search_columns_to, 2, 1, 1, 1) self.label_3 = QtWidgets.QLabel(self.groupBox) self.label_3.setWordWrap(True) self.label_3.setObjectName("label_3") self.gridLayout_2.addWidget(self.label_3, 5, 0, 1, 2) self.gridLayout_6.addWidget(self.groupBox, 5, 0, 1, 2) self.opt_search_as_you_type = QtWidgets.QCheckBox(self.tab) self.opt_search_as_you_type.setObjectName("opt_search_as_you_type") self.gridLayout_6.addWidget(self.opt_search_as_you_type, 0, 0, 1, 2) self.opt_case_sensitive = QtWidgets.QCheckBox(self.tab) self.opt_case_sensitive.setObjectName("opt_case_sensitive") self.gridLayout_6.addWidget(self.opt_case_sensitive, 3, 0, 1, 1) self.opt_highlight_search_matches = QtWidgets.QCheckBox(self.tab) self.opt_highlight_search_matches.setObjectName( "opt_highlight_search_matches") self.gridLayout_6.addWidget(self.opt_highlight_search_matches, 1, 0, 1, 2) self.opt_show_highlight_toggle_button = QtWidgets.QCheckBox(self.tab) self.opt_show_highlight_toggle_button.setObjectName( "opt_show_highlight_toggle_button") self.gridLayout_6.addWidget(self.opt_show_highlight_toggle_button, 2, 0, 1, 2) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_6.addItem(spacerItem, 7, 0, 1, 1) self.opt_use_primary_find_in_search = QtWidgets.QCheckBox(self.tab) self.opt_use_primary_find_in_search.setObjectName( "opt_use_primary_find_in_search") self.gridLayout_6.addWidget(self.opt_use_primary_find_in_search, 4, 0, 1, 1) self.tabWidget.addTab(self.tab, "") self.tab_2 = QtWidgets.QWidget() self.tab_2.setObjectName("tab_2") self.gridLayout_4 = QtWidgets.QGridLayout(self.tab_2) self.gridLayout_4.setObjectName("gridLayout_4") self.groupBox_2 = QtWidgets.QGroupBox(self.tab_2) self.groupBox_2.setObjectName("groupBox_2") self.gridLayout_3 = QtWidgets.QGridLayout(self.groupBox_2) self.gridLayout_3.setObjectName("gridLayout_3") self.l12 = QtWidgets.QGridLayout() self.l12.setObjectName("l12") self.la10 = QtWidgets.QLabel(self.groupBox_2) self.la10.setObjectName("la10") self.l12.addWidget(self.la10, 0, 0, 1, 1) self.gst_names = QtWidgets.QComboBox(self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.gst_names.sizePolicy().hasHeightForWidth()) self.gst_names.setSizePolicy(sizePolicy) self.gst_names.setEditable(True) self.gst_names.setMinimumContentsLength(10) self.gst_names.setObjectName("gst_names") self.l12.addWidget(self.gst_names, 0, 1, 1, 1) self.gst_delete_button = QtWidgets.QToolButton(self.groupBox_2) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(I("trash.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.gst_delete_button.setIcon(icon) self.gst_delete_button.setObjectName("gst_delete_button") self.l12.addWidget(self.gst_delete_button, 0, 2, 1, 1) self.la112 = QtWidgets.QLabel(self.groupBox_2) self.la112.setObjectName("la112") self.l12.addWidget(self.la112, 1, 0, 1, 1) self.gst_value = EditWithComplete(self.groupBox_2) self.gst_value.setObjectName("gst_value") self.l12.addWidget(self.gst_value, 1, 1, 1, 1) self.hboxlayout = QtWidgets.QHBoxLayout() self.hboxlayout.setObjectName("hboxlayout") self.gst_save_button = QtWidgets.QToolButton(self.groupBox_2) self.gst_save_button.setObjectName("gst_save_button") self.hboxlayout.addWidget(self.gst_save_button) self.l12.addLayout(self.hboxlayout, 2, 0, 1, 3) self.gridLayout_3.addLayout(self.l12, 0, 0, 1, 1) self.gst_explanation = QtWidgets.QTextBrowser(self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(100) sizePolicy.setHeightForWidth( self.gst_explanation.sizePolicy().hasHeightForWidth()) self.gst_explanation.setSizePolicy(sizePolicy) self.gst_explanation.setObjectName("gst_explanation") self.gridLayout_3.addWidget(self.gst_explanation, 0, 1, 3, 1) self.user_category_layout = QtWidgets.QHBoxLayout() self.user_category_layout.setObjectName("user_category_layout") self.l11 = QtWidgets.QLabel(self.groupBox_2) self.l11.setObjectName("l11") self.user_category_layout.addWidget(self.l11) self.opt_grouped_search_make_user_categories = EditWithComplete( self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.opt_grouped_search_make_user_categories.sizePolicy( ).hasHeightForWidth()) self.opt_grouped_search_make_user_categories.setSizePolicy(sizePolicy) self.opt_grouped_search_make_user_categories.setObjectName( "opt_grouped_search_make_user_categories") self.user_category_layout.addWidget( self.opt_grouped_search_make_user_categories) self.gridLayout_3.addLayout(self.user_category_layout, 1, 0, 1, 1) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_3.addItem(spacerItem1, 2, 0, 1, 1) self.gridLayout_4.addWidget(self.groupBox_2, 0, 0, 1, 1) self.tabWidget.addTab(self.tab_2, "") self.tab_3 = QtWidgets.QWidget() self.tab_3.setObjectName("tab_3") self.gridLayout_5 = QtWidgets.QGridLayout(self.tab_3) self.gridLayout_5.setObjectName("gridLayout_5") self.groupBox22 = QtWidgets.QGroupBox(self.tab_3) self.groupBox22.setObjectName("groupBox22") self.gridLayout_22 = QtWidgets.QGridLayout(self.groupBox22) self.gridLayout_22.setObjectName("gridLayout_22") self.label1 = QtWidgets.QLabel(self.groupBox22) self.label1.setWordWrap(True) self.label1.setObjectName("label1") self.gridLayout_22.addWidget(self.label1, 0, 0, 1, 6) self.label_221 = QtWidgets.QLabel(self.groupBox22) self.label_221.setObjectName("label_221") self.gridLayout_22.addWidget(self.label_221, 1, 0, 1, 1) self.similar_authors_search_key = QtWidgets.QComboBox(self.groupBox22) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(10) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.similar_authors_search_key.sizePolicy().hasHeightForWidth()) self.similar_authors_search_key.setSizePolicy(sizePolicy) self.similar_authors_search_key.setObjectName( "similar_authors_search_key") self.gridLayout_22.addWidget(self.similar_authors_search_key, 1, 1, 1, 1) self.opt_similar_authors_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_authors_match_kind.setObjectName( "opt_similar_authors_match_kind") self.gridLayout_22.addWidget(self.opt_similar_authors_match_kind, 1, 2, 1, 1) self.label_222 = QtWidgets.QLabel(self.groupBox22) self.label_222.setObjectName("label_222") self.gridLayout_22.addWidget(self.label_222, 1, 3, 1, 1) self.similar_series_search_key = QtWidgets.QComboBox(self.groupBox22) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(10) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.similar_series_search_key.sizePolicy().hasHeightForWidth()) self.similar_series_search_key.setSizePolicy(sizePolicy) self.similar_series_search_key.setObjectName( "similar_series_search_key") self.gridLayout_22.addWidget(self.similar_series_search_key, 1, 4, 1, 1) self.opt_similar_series_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_series_match_kind.setObjectName( "opt_similar_series_match_kind") self.gridLayout_22.addWidget(self.opt_similar_series_match_kind, 1, 5, 1, 1) self.label_223 = QtWidgets.QLabel(self.groupBox22) self.label_223.setObjectName("label_223") self.gridLayout_22.addWidget(self.label_223, 2, 0, 1, 1) self.similar_tags_search_key = QtWidgets.QComboBox(self.groupBox22) self.similar_tags_search_key.setObjectName("similar_tags_search_key") self.gridLayout_22.addWidget(self.similar_tags_search_key, 2, 1, 1, 1) self.opt_similar_tags_match_kind = QtWidgets.QComboBox(self.groupBox22) self.opt_similar_tags_match_kind.setObjectName( "opt_similar_tags_match_kind") self.gridLayout_22.addWidget(self.opt_similar_tags_match_kind, 2, 2, 1, 1) self.label_224 = QtWidgets.QLabel(self.groupBox22) self.label_224.setObjectName("label_224") self.gridLayout_22.addWidget(self.label_224, 2, 3, 1, 1) self.similar_publisher_search_key = QtWidgets.QComboBox( self.groupBox22) self.similar_publisher_search_key.setObjectName( "similar_publisher_search_key") self.gridLayout_22.addWidget(self.similar_publisher_search_key, 2, 4, 1, 1) self.opt_similar_publisher_match_kind = QtWidgets.QComboBox( self.groupBox22) self.opt_similar_publisher_match_kind.setObjectName( "opt_similar_publisher_match_kind") self.gridLayout_22.addWidget(self.opt_similar_publisher_match_kind, 2, 5, 1, 1) spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.gridLayout_22.addItem(spacerItem2, 3, 1, 1, 1) self.gridLayout_5.addWidget(self.groupBox22, 0, 0, 1, 1) self.tabWidget.addTab(self.tab_3, "") self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) self.label_2.setBuddy(self.opt_limit_search_columns_to) self.la10.setBuddy(self.gst_names) self.la112.setBuddy(self.gst_value) self.l11.setBuddy(self.opt_grouped_search_make_user_categories) self.label_221.setBuddy(self.similar_authors_search_key) self.label_222.setBuddy(self.similar_series_search_key) self.label_223.setBuddy(self.similar_tags_search_key) self.label_224.setBuddy(self.similar_publisher_search_key) self.retranslateUi(Form) self.tabWidget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(_("Form")) self.clear_history_button.setToolTip( _("Clear search histories from all over calibre. Including the book list, E-book viewer, fetch news dialog, etc." )) self.clear_history_button.setText(_("Clear search &histories")) self.groupBox.setTitle(_("What to search by default")) self.label.setText( _("When you enter a search term without a prefix, by default calibre will search all metadata for matches. For example, entering, \"asimov\" will search not just authors but title/tags/series/comments/etc. Use these options if you would like to change this behavior." )) self.opt_limit_search_columns.setText( _("&Limit the searched metadata")) self.label_2.setText( _("&Columns that non-prefixed searches are limited to:")) self.label_3.setText( _("Note that this option affects all searches, including saved searches and restrictions. Therefore, if you use this option, it is best to ensure that you always use prefixes in your saved searches. For example, use \"series:Foundation\" rather than just \"Foundation\" in a saved search" )) self.opt_search_as_you_type.setText(_("Search as you &type")) self.opt_case_sensitive.setText(_("Case &sensitive searching")) self.opt_highlight_search_matches.setText( _("&Highlight search results instead of restricting the book list to the results" )) self.opt_show_highlight_toggle_button.setToolTip( _("<p>This option will cause a small button to appear next to the Search bar. Clicking the button will toggle between showing only the search results and showing all books with the search results highlighted." )) self.opt_show_highlight_toggle_button.setText( _("Show a &quick toggle button to switch between highlighting and restricting results next to the Search bar" )) self.opt_use_primary_find_in_search.setText( _("Unaccented characters match &accented characters")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _("Genera&l")) self.groupBox_2.setTitle(_("Grouped search terms")) self.la10.setText(_("&Names:")) self.gst_names.setToolTip( _("Contains the names of the currently-defined group search terms.\n" "Create a new name by entering it into the empty box, then\n" "pressing Save. Rename a search term by selecting it then\n" "changing the name and pressing Save. Change the value of\n" "a search term by changing the value box then pressing Save.")) self.gst_delete_button.setToolTip(_("Delete the current search term")) self.gst_delete_button.setText(_("...")) self.la112.setText(_("&Value:")) self.gst_value.setToolTip( _("Enter a comma-separated list of lookup names of the columns\n" "to include in the grouped search term")) self.gst_save_button.setToolTip( _("Save the current search term. You can rename a search term by\n" "changing the name then pressing Save. You can change the value\n" "of a search term by changing the value box then pressing Save.") ) self.gst_save_button.setText(_("&Save")) self.l11.setText(_("Make &user categories from:")) self.opt_grouped_search_make_user_categories.setToolTip( _("Enter the names of any grouped search terms you wish\n" "to be shown as user categories")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _("&Grouped searches")) self.groupBox22.setTitle( _("What to search when searching similar books")) self.label1.setText( _("<p>When you search for similar books by right clicking the\n" " book and selecting \"Similar books...\",\n" " calibre constructs a search using the column lookup names specified below.\n" " By changing the lookup name to a grouped search term you can\n" " search multiple columns at once.</p>")) self.label_221.setText(_("S&imilar authors: ")) self.label_222.setText(_("Si&milar series: ")) self.label_223.setText(_("Similar &tags: ")) self.label_224.setText(_("Simi&lar publishers: ")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _("&Similar books"))
class AddEmptyBookDialog(QDialog): def __init__(self, parent, db, author, series=None, title=None): QDialog.__init__(self, parent) self.db = db self.setWindowTitle(_('How many empty books?')) self._layout = QGridLayout(self) self.setLayout(self._layout) self.qty_label = QLabel(_('How many empty books should be added?')) self._layout.addWidget(self.qty_label, 0, 0, 1, 2) self.qty_spinbox = QSpinBox(self) self.qty_spinbox.setRange(1, 10000) self.qty_spinbox.setValue(1) self._layout.addWidget(self.qty_spinbox, 1, 0, 1, 2) self.author_label = QLabel(_('Set the author of the new books to:')) self._layout.addWidget(self.author_label, 2, 0, 1, 2) self.authors_combo = EditWithComplete(self) self.authors_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.authors_combo.setEditable(True) self._layout.addWidget(self.authors_combo, 3, 0, 1, 1) self.initialize_authors(db, author) self.clear_button = QToolButton(self) self.clear_button.setIcon(QIcon(I('trash.png'))) self.clear_button.setToolTip(_('Reset author to Unknown')) self.clear_button.clicked.connect(self.reset_author) self._layout.addWidget(self.clear_button, 3, 1, 1, 1) self.series_label = QLabel(_('Set the series of the new books to:')) self._layout.addWidget(self.series_label, 4, 0, 1, 2) self.series_combo = EditWithComplete(self) self.series_combo.setSizeAdjustPolicy( self.authors_combo.AdjustToMinimumContentsLengthWithIcon) self.series_combo.setEditable(True) self._layout.addWidget(self.series_combo, 5, 0, 1, 1) self.initialize_series(db, series) self.sclear_button = QToolButton(self) self.sclear_button.setIcon(QIcon(I('trash.png'))) self.sclear_button.setToolTip(_('Reset series')) self.sclear_button.clicked.connect(self.reset_series) self._layout.addWidget(self.sclear_button, 5, 1, 1, 1) self.title_label = QLabel(_('Set the title of the new books to:')) self._layout.addWidget(self.title_label, 6, 0, 1, 2) self.title_edit = QLineEdit(self) self.title_edit.setText(title or '') self._layout.addWidget(self.title_edit, 7, 0, 1, 1) self.tclear_button = QToolButton(self) self.tclear_button.setIcon(QIcon(I('trash.png'))) self.tclear_button.setToolTip(_('Reset title')) self.tclear_button.clicked.connect(self.title_edit.clear) self._layout.addWidget(self.tclear_button, 7, 1, 1, 1) self.format_label = QLabel(_('Also create an empty ebook in format:')) self._layout.addWidget(self.format_label, 8, 0, 1, 2) c = self.format_value = QComboBox(self) from calibre.ebooks.oeb.polish.create import valid_empty_formats possible_formats = [''] + sorted(x.upper() for x in valid_empty_formats) c.addItems(possible_formats) c.setToolTip(_('Also create an empty book format file that you can subsequently edit')) if gprefs.get('create_empty_epub_file', False): # Migration of the check box gprefs.set('create_empty_format_file', 'epub') del gprefs['create_empty_epub_file'] use_format = gprefs.get('create_empty_format_file', '').upper() try: c.setCurrentIndex(possible_formats.index(use_format)) except Exception: pass self._layout.addWidget(c, 9, 0, 1, 1) button_box = self.bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) self._layout.addWidget(button_box, 10, 0, 1, -1) self.resize(self.sizeHint()) def accept(self): gprefs['create_empty_format_file'] = self.format_value.currentText().lower() return QDialog.accept(self) def reset_author(self, *args): self.authors_combo.setEditText(_('Unknown')) def reset_series(self): self.series_combo.setEditText('') def initialize_authors(self, db, author): au = author if not au: au = _('Unknown') self.authors_combo.show_initial_value(au.replace('|', ',')) self.authors_combo.set_separator('&') self.authors_combo.set_space_before_sep(True) self.authors_combo.set_add_separator(tweaks['authors_completer_append_separator']) self.authors_combo.update_items_cache(db.all_author_names()) def initialize_series(self, db, series): self.series_combo.show_initial_value(series or '') self.series_combo.update_items_cache(db.all_series_names()) self.series_combo.set_separator(None) @property def qty_to_add(self): return self.qty_spinbox.value() @property def selected_authors(self): return string_to_authors(unicode(self.authors_combo.text())) @property def selected_series(self): return unicode(self.series_combo.text()) @property def selected_title(self): return self.title_edit.text().strip()
def __init__(self, parent=None): EditWithComplete.__init__(self, parent, sort_func=lambda x: None)
def __init__(self, parent=None, strip_completion_entries=True): EditWithComplete.__init__( self, parent, sort_func=lambda x: b'', strip_completion_entries=strip_completion_entries)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(600, 500) self.horizontalLayout = QtWidgets.QHBoxLayout(Form) self.horizontalLayout.setObjectName("horizontalLayout") self.groupBox_4 = QtWidgets.QGroupBox(Form) self.groupBox_4.setObjectName("groupBox_4") self._2 = QtWidgets.QGridLayout(self.groupBox_4) self._2.setObjectName("_2") self._4 = QtWidgets.QVBoxLayout() self._4.setContentsMargins(0, 0, 0, 0) self._4.setSpacing(6) self._4.setObjectName("_4") self.label_5 = QtWidgets.QLabel(self.groupBox_4) self.label_5.setObjectName("label_5") self._4.addWidget(self.label_5) self._5 = QtWidgets.QHBoxLayout() self._5.setContentsMargins(0, 0, 0, 0) self._5.setSpacing(6) self._5.setObjectName("_5") self.cover_path = QtWidgets.QLineEdit(self.groupBox_4) self.cover_path.setClearButtonEnabled(True) self.cover_path.setObjectName("cover_path") self._5.addWidget(self.cover_path) self.cover_button = QtWidgets.QToolButton(self.groupBox_4) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(I("document_open.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.cover_button.setIcon(icon) self.cover_button.setObjectName("cover_button") self._5.addWidget(self.cover_button) self._4.addLayout(self._5) self._2.addLayout(self._4, 1, 0, 1, 1) self.opt_prefer_metadata_cover = QtWidgets.QCheckBox(self.groupBox_4) self.opt_prefer_metadata_cover.setChecked(True) self.opt_prefer_metadata_cover.setObjectName( "opt_prefer_metadata_cover") self._2.addWidget(self.opt_prefer_metadata_cover, 2, 0, 1, 1) self._3 = QtWidgets.QHBoxLayout() self._3.setObjectName("_3") self.cover = ImageView(self.groupBox_4) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.cover.sizePolicy().hasHeightForWidth()) self.cover.setSizePolicy(sizePolicy) self.cover.setObjectName("cover") self._3.addWidget(self.cover) self._2.addLayout(self._3, 0, 0, 1, 1) self.horizontalLayout.addWidget(self.groupBox_4) self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self._7 = QtWidgets.QGridLayout() self._7.setObjectName("_7") self.label = QtWidgets.QLabel(Form) self.label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label.setObjectName("label") self._7.addWidget(self.label, 0, 0, 1, 1) self.title = EnLineEdit(Form) self.title.setObjectName("title") self._7.addWidget(self.title, 0, 1, 1, 1) self.label_2 = QtWidgets.QLabel(Form) self.label_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_2.setObjectName("label_2") self._7.addWidget(self.label_2, 1, 0, 1, 1) self.label_6 = QtWidgets.QLabel(Form) self.label_6.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_6.setObjectName("label_6") self._7.addWidget(self.label_6, 2, 0, 1, 1) self.author_sort = EnLineEdit(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.author_sort.sizePolicy().hasHeightForWidth()) self.author_sort.setSizePolicy(sizePolicy) self.author_sort.setObjectName("author_sort") self._7.addWidget(self.author_sort, 2, 1, 1, 1) self.label_3 = QtWidgets.QLabel(Form) self.label_3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_3.setObjectName("label_3") self._7.addWidget(self.label_3, 3, 0, 1, 1) self.label_4 = QtWidgets.QLabel(Form) self.label_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_4.setObjectName("label_4") self._7.addWidget(self.label_4, 4, 0, 1, 1) self.tags = EditWithComplete(Form) self.tags.setObjectName("tags") self._7.addWidget(self.tags, 4, 1, 1, 1) self.label_7 = QtWidgets.QLabel(Form) self.label_7.setTextFormat(QtCore.Qt.PlainText) self.label_7.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_7.setObjectName("label_7") self._7.addWidget(self.label_7, 5, 0, 1, 1) self.series = EditWithComplete(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(10) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.series.sizePolicy().hasHeightForWidth()) self.series.setSizePolicy(sizePolicy) self.series.setEditable(True) self.series.setInsertPolicy(QtWidgets.QComboBox.InsertAlphabetically) self.series.setObjectName("series") self._7.addWidget(self.series, 5, 1, 1, 1) self.series_index = QtWidgets.QDoubleSpinBox(Form) self.series_index.setMaximum(9999999999.99) self.series_index.setProperty("value", 1.0) self.series_index.setObjectName("series_index") self._7.addWidget(self.series_index, 6, 1, 1, 1) self.publisher = EditWithComplete(Form) self.publisher.setEditable(True) self.publisher.setObjectName("publisher") self._7.addWidget(self.publisher, 3, 1, 1, 1) self.author = EditWithComplete(Form) self.author.setEditable(True) self.author.setObjectName("author") self._7.addWidget(self.author, 1, 1, 1, 1) self.verticalLayout_2.addLayout(self._7) self.comment = Editor(Form) self.comment.setObjectName("comment") self.verticalLayout_2.addWidget(self.comment) self.horizontalLayout.addLayout(self.verticalLayout_2) self.label_5.setBuddy(self.cover_path) self.label.setBuddy(self.title) self.label_2.setBuddy(self.author) self.label_6.setBuddy(self.author_sort) self.label_3.setBuddy(self.publisher) self.label_4.setBuddy(self.tags) self.label_7.setBuddy(self.series) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) Form.setTabOrder(self.title, self.author) Form.setTabOrder(self.author, self.author_sort) Form.setTabOrder(self.author_sort, self.publisher) Form.setTabOrder(self.publisher, self.tags) Form.setTabOrder(self.tags, self.series) Form.setTabOrder(self.series, self.series_index) Form.setTabOrder(self.series_index, self.cover_path) Form.setTabOrder(self.cover_path, self.cover_button) Form.setTabOrder(self.cover_button, self.opt_prefer_metadata_cover)