mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove "view column definition"
This commit is contained in:
parent
04e50fa395
commit
74eceb7214
@ -569,9 +569,6 @@ class BooksView(QTableView): # {{{
|
|||||||
view.apply_state(view.get_default_state())
|
view.apply_state(view.get_default_state())
|
||||||
elif action == 'addcustcol':
|
elif action == 'addcustcol':
|
||||||
self.add_column_signal.emit()
|
self.add_column_signal.emit()
|
||||||
elif action == 'viewcustcol':
|
|
||||||
col_manager = CreateNewCustomColumn(self.gui)
|
|
||||||
col_manager.view_existing_column(column)
|
|
||||||
elif action == 'editcustcol':
|
elif action == 'editcustcol':
|
||||||
def show_restart_dialog():
|
def show_restart_dialog():
|
||||||
from calibre.gui2.preferences.main import must_restart_message
|
from calibre.gui2.preferences.main import must_restart_message
|
||||||
@ -651,13 +648,10 @@ class BooksView(QTableView): # {{{
|
|||||||
if not isinstance(view, DeviceBooksView):
|
if not isinstance(view, DeviceBooksView):
|
||||||
col_manager = CreateNewCustomColumn(self.gui)
|
col_manager = CreateNewCustomColumn(self.gui)
|
||||||
if self.can_add_columns and self.model().is_custom_column(col):
|
if self.can_add_columns and self.model().is_custom_column(col):
|
||||||
actv = ans.addAction(QIcon.ic('view-image.png'), _('View column definition for %s') % name,
|
act = ans.addAction(QIcon.ic('edit_input.png'), _('Edit column definition for %s') % name,
|
||||||
partial(handler, action='viewcustcol'))
|
|
||||||
acte = ans.addAction(QIcon.ic('edit_input.png'), _('Edit column definition for %s') % name,
|
|
||||||
partial(handler, action='editcustcol'))
|
partial(handler, action='editcustcol'))
|
||||||
if col_manager.must_restart():
|
if col_manager.must_restart():
|
||||||
actv.setEnabled(False)
|
act.setEnabled(False)
|
||||||
acte.setEnabled(False)
|
|
||||||
if self.is_library_view:
|
if self.is_library_view:
|
||||||
if self._model.db.field_metadata[col]['is_category']:
|
if self._model.db.field_metadata[col]['is_category']:
|
||||||
act = ans.addAction(QIcon.ic('quickview.png'), _('Quickview column %s') % name,
|
act = ans.addAction(QIcon.ic('quickview.png'), _('Quickview column %s') % name,
|
||||||
|
@ -106,11 +106,10 @@ class CreateCustomColumn(QDialog):
|
|||||||
)))
|
)))
|
||||||
column_types_map = {k['datatype']:idx for idx, k in iteritems(column_types)}
|
column_types_map = {k['datatype']:idx for idx, k in iteritems(column_types)}
|
||||||
|
|
||||||
def __init__(self, gui, caller, current_key, standard_colheads, freeze_lookup_name=False, view_only=False):
|
def __init__(self, gui, caller, current_key, standard_colheads, freeze_lookup_name=False):
|
||||||
QDialog.__init__(self, gui)
|
QDialog.__init__(self, gui)
|
||||||
self.orig_column_number = -1
|
self.orig_column_number = -1
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
self.view_only = view_only
|
|
||||||
self.setup_ui()
|
self.setup_ui()
|
||||||
self.setWindowTitle(_('Create a custom column'))
|
self.setWindowTitle(_('Create a custom column'))
|
||||||
self.heading_label.setText('<b>' + _('Create a custom column'))
|
self.heading_label.setText('<b>' + _('Create a custom column'))
|
||||||
@ -139,12 +138,8 @@ class CreateCustomColumn(QDialog):
|
|||||||
self.exec()
|
self.exec()
|
||||||
return
|
return
|
||||||
|
|
||||||
if view_only:
|
self.setWindowTitle(_('Edit custom column'))
|
||||||
self.setWindowTitle(_('View custom column'))
|
self.heading_label.setText('<b>' + _('Edit custom column'))
|
||||||
self.heading_label.setText('<b>' + _('View custom column definition. Changes will be ignored'))
|
|
||||||
else:
|
|
||||||
self.setWindowTitle(_('Edit custom column'))
|
|
||||||
self.heading_label.setText('<b>' + _('Edit custom column definition'))
|
|
||||||
self.shortcuts.setVisible(False)
|
self.shortcuts.setVisible(False)
|
||||||
col = current_key
|
col = current_key
|
||||||
if col not in caller.custcols:
|
if col not in caller.custcols:
|
||||||
@ -297,13 +292,15 @@ class CreateCustomColumn(QDialog):
|
|||||||
self.g = g = QGridLayout()
|
self.g = g = QGridLayout()
|
||||||
l.addLayout(g)
|
l.addLayout(g)
|
||||||
l.addStretch(10)
|
l.addStretch(10)
|
||||||
if self.view_only:
|
bbl = QHBoxLayout()
|
||||||
self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, self)
|
txt = QLabel(_('Pressing OK will require restarting calibre even if nothing was changed'))
|
||||||
else:
|
txt.setWordWrap(True)
|
||||||
self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok |
|
bbl.addWidget(txt)
|
||||||
QDialogButtonBox.StandardButton.Cancel, self)
|
bbl.addStretch(1)
|
||||||
|
self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel, self)
|
||||||
bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
|
bb.accepted.connect(self.accept), bb.rejected.connect(self.reject)
|
||||||
l.addWidget(bb)
|
bbl.addWidget(bb)
|
||||||
|
l.addLayout(bbl)
|
||||||
|
|
||||||
def add_row(text, widget):
|
def add_row(text, widget):
|
||||||
if text is None:
|
if text is None:
|
||||||
@ -1010,17 +1007,11 @@ class CreateNewCustomColumn:
|
|||||||
return self.Result.INVALID_KEY
|
return self.Result.INVALID_KEY
|
||||||
return self._create_or_edit_column(lookup_name, freeze_lookup_name=False, operation='edit')
|
return self._create_or_edit_column(lookup_name, freeze_lookup_name=False, operation='edit')
|
||||||
|
|
||||||
def view_existing_column(self, lookup_name):
|
|
||||||
if lookup_name not in self.custcols:
|
|
||||||
return self.Result.INVALID_KEY
|
|
||||||
return self._create_or_edit_column(lookup_name, freeze_lookup_name=True, operation='view')
|
|
||||||
|
|
||||||
def _create_or_edit_column(self, lookup_name, freeze_lookup_name, operation=None):
|
def _create_or_edit_column(self, lookup_name, freeze_lookup_name, operation=None):
|
||||||
try:
|
try:
|
||||||
dialog = CreateCustomColumn(self.gui, self, lookup_name,
|
dialog = CreateCustomColumn(self.gui, self, lookup_name,
|
||||||
self.gui.library_view.model().orig_headers,
|
self.gui.library_view.model().orig_headers,
|
||||||
freeze_lookup_name=freeze_lookup_name,
|
freeze_lookup_name=freeze_lookup_name)
|
||||||
view_only=operation=='view')
|
|
||||||
if dialog.result() == QDialog.DialogCode.Accepted and self.cc_column_key is not None:
|
if dialog.result() == QDialog.DialogCode.Accepted and self.cc_column_key is not None:
|
||||||
cc = self.custcols[lookup_name]
|
cc = self.custcols[lookup_name]
|
||||||
if operation == 'create':
|
if operation == 'create':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user