This commit is contained in:
Kovid Goyal 2015-11-26 18:22:43 +05:30
parent efb6dcbf2a
commit 7cdf343936
2 changed files with 11 additions and 13 deletions

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import copy, sys import copy, sys
from PyQt5.Qt import Qt, QTableWidgetItem, QIcon, QHeaderView, QTimer from PyQt5.Qt import Qt, QTableWidgetItem, QIcon
from calibre.gui2 import gprefs from calibre.gui2 import gprefs
from calibre.gui2.preferences import ConfigWidgetBase, test_widget from calibre.gui2.preferences import ConfigWidgetBase, test_widget
@ -91,7 +91,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
for row, col in enumerate(colmap): for row, col in enumerate(colmap):
self.setup_row(self.field_metadata, row, col) self.setup_row(self.field_metadata, row, col)
self.restore_geometry(); self.restore_geometry()
self.opt_columns.blockSignals(False) self.opt_columns.blockSignals(False)
def restore_geometry(self): def restore_geometry(self):
@ -185,7 +185,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
return return
self.opt_columns.removeRow(idx) self.opt_columns.removeRow(idx)
if self.custcols[col]['colnum'] is None: if self.custcols[col]['colnum'] is None:
del self.custcols[col] # A newly-added column was deleted del self.custcols[col] # A newly-added column was deleted
else: else:
self.custcols[col]['*deleteme'] = True self.custcols[col]['*deleteme'] = True
self.changed_signal.emit() self.changed_signal.emit()
@ -216,15 +216,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
def apply_custom_column_changes(self): def apply_custom_column_changes(self):
model = self.gui.library_view.model() model = self.gui.library_view.model()
db = model.db db = model.db
config_cols = [unicode(self.opt_columns.item(i, 0).data(Qt.UserRole) or '')\ config_cols = [unicode(self.opt_columns.item(i, 0).data(Qt.UserRole) or '')
for i in range(self.opt_columns.rowCount())] for i in range(self.opt_columns.rowCount())]
if not config_cols: if not config_cols:
config_cols = ['title'] config_cols = ['title']
removed_cols = set(model.column_map) - set(config_cols) removed_cols = set(model.column_map) - set(config_cols)
hidden_cols = set([unicode(self.opt_columns.item(i, 0).data(Qt.UserRole) or '')\ hidden_cols = set([unicode(self.opt_columns.item(i, 0).data(Qt.UserRole) or '')
for i in range(self.opt_columns.rowCount()) \ for i in range(self.opt_columns.rowCount())
if self.opt_columns.item(i, 0).checkState()==Qt.Unchecked]) if self.opt_columns.item(i, 0).checkState()==Qt.Unchecked])
hidden_cols = hidden_cols.union(removed_cols) # Hide removed cols hidden_cols = hidden_cols.union(removed_cols) # Hide removed cols
hidden_cols = list(hidden_cols.intersection(set(model.column_map))) hidden_cols = list(hidden_cols.intersection(set(model.column_map)))
if 'ondevice' in hidden_cols: if 'ondevice' in hidden_cols:
hidden_cols.remove('ondevice') hidden_cols.remove('ondevice')
@ -247,7 +247,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
name=self.custcols[c]['name'], name=self.custcols[c]['name'],
datatype=self.custcols[c]['datatype'], datatype=self.custcols[c]['datatype'],
is_multiple=self.custcols[c]['is_multiple'], is_multiple=self.custcols[c]['is_multiple'],
display = self.custcols[c]['display']) display=self.custcols[c]['display'])
must_restart = True must_restart = True
elif '*deleteme' in self.custcols[c]: elif '*deleteme' in self.custcols[c]:
db.delete_custom_column(label=self.custcols[c]['label']) db.delete_custom_column(label=self.custcols[c]['label'])
@ -256,7 +256,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
cc = self.custcols[c] cc = self.custcols[c]
db.set_custom_column_metadata(cc['colnum'], name=cc['name'], db.set_custom_column_metadata(cc['colnum'], name=cc['name'],
label=cc['label'], label=cc['label'],
display = self.custcols[c]['display'], display=self.custcols[c]['display'],
notify=False) notify=False)
if '*must_restart' in self.custcols[c]: if '*must_restart' in self.custcols[c]:
must_restart = True must_restart = True
@ -267,4 +267,3 @@ if __name__ == '__main__':
from PyQt5.Qt import QApplication from PyQt5.Qt import QApplication
app = QApplication([]) app = QApplication([])
test_widget('Interface', 'Custom Columns') test_widget('Interface', 'Custom Columns')

View File

@ -6,7 +6,7 @@ __copyright__ = '2010, Kovid Goyal <kovid at kovidgoyal.net>'
import re import re
from functools import partial from functools import partial
from PyQt5.Qt import QDialog, Qt, QListWidgetItem, QColor, QIcon, QTableWidgetItem from PyQt5.Qt import QDialog, Qt, QColor
from calibre.gui2.preferences.create_custom_column_ui import Ui_QCreateCustomColumn from calibre.gui2.preferences.create_custom_column_ui import Ui_QCreateCustomColumn
from calibre.gui2 import error_dialog from calibre.gui2 import error_dialog
@ -160,8 +160,7 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
'An Oblique Approach</b></big> [Belisarius [1]]". The template ' 'An Oblique Approach</b></big> [Belisarius [1]]". The template '
'<pre>&lt;a href="http://www.beam-ebooks.de/ebook/{identifiers' '<pre>&lt;a href="http://www.beam-ebooks.de/ebook/{identifiers'
':select(beam)}"&gt;Beam book&lt;/a&gt;</pre> ' ':select(beam)}"&gt;Beam book&lt;/a&gt;</pre> '
'will generate a link to the book on the Beam ebooks site.') 'will generate a link to the book on the Beam ebooks site.') + '</p>')
+ '</p>')
self.exec_() self.exec_()
def shortcut_activated(self, url): def shortcut_activated(self, url):