mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make decorating custom columns in the GUI a separate 'display' option from subtype. Add the UI to control it to preferences.
This commit is contained in:
parent
be44ea7383
commit
52209e7f58
@ -689,9 +689,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
if datatype in ('text', 'comments', 'composite', 'enumeration'):
|
if datatype in ('text', 'comments', 'composite', 'enumeration'):
|
||||||
self.dc[col] = functools.partial(text_type, idx=idx,
|
self.dc[col] = functools.partial(text_type, idx=idx,
|
||||||
mult=self.custom_columns[col]['is_multiple'])
|
mult=self.custom_columns[col]['is_multiple'])
|
||||||
if datatype == 'composite':
|
if datatype in ['text', 'composite', 'enumeration']:
|
||||||
csort = self.custom_columns[col]['display'].get('composite_sort', 'text')
|
if self.custom_columns[col]['display'].get('use_decorations', False):
|
||||||
if csort == 'bool':
|
|
||||||
self.dc_decorator[col] = functools.partial(
|
self.dc_decorator[col] = functools.partial(
|
||||||
bool_type_decorator, idx=idx,
|
bool_type_decorator, idx=idx,
|
||||||
bool_cols_are_tristate=tweaks['bool_custom_columns_are_tristate'] != 'no')
|
bool_cols_are_tristate=tweaks['bool_custom_columns_are_tristate'] != 'no')
|
||||||
|
@ -121,6 +121,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
elif ct == 'enumeration':
|
elif ct == 'enumeration':
|
||||||
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
|
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
|
||||||
self.datatype_changed()
|
self.datatype_changed()
|
||||||
|
if ct in ['text', '*text', 'composite', 'enumeration']:
|
||||||
|
self.use_decorations.setChecked(c['display'].get('use_decorations', False))
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def shortcut_activated(self, url):
|
def shortcut_activated(self, url):
|
||||||
@ -161,6 +163,11 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
getattr(self, 'composite_'+x).setVisible(col_type == 'composite')
|
getattr(self, 'composite_'+x).setVisible(col_type == 'composite')
|
||||||
for x in ('box', 'default_label', 'label'):
|
for x in ('box', 'default_label', 'label'):
|
||||||
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
getattr(self, 'enum_'+x).setVisible(col_type == 'enumeration')
|
||||||
|
if col_type in ['text', '*text', 'composite', 'enumeration']:
|
||||||
|
self.use_decorations.setVisible(True)
|
||||||
|
else:
|
||||||
|
self.use_decorations.setVisible(False)
|
||||||
|
self.use_decorations.setChecked(False)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
col = unicode(self.column_name_box.text()).strip()
|
col = unicode(self.column_name_box.text()).strip()
|
||||||
@ -233,6 +240,9 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
|
|||||||
'list more than once').format(l[i]))
|
'list more than once').format(l[i]))
|
||||||
display_dict = {'enum_values': l}
|
display_dict = {'enum_values': l}
|
||||||
|
|
||||||
|
if col_type in ['text', '*text', 'composite', 'enumeration']:
|
||||||
|
display_dict['use_decorations'] = self.use_decorations.checkState()
|
||||||
|
|
||||||
if not self.editing_col:
|
if not self.editing_col:
|
||||||
db.field_metadata
|
db.field_metadata
|
||||||
self.parent.custcols[key] = {
|
self.parent.custcols[key] = {
|
||||||
|
@ -88,23 +88,58 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QComboBox" name="column_type_box">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
<widget class="QComboBox" name="column_type_box">
|
||||||
<horstretch>0</horstretch>
|
<property name="sizePolicy">
|
||||||
<verstretch>0</verstretch>
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
</sizepolicy>
|
<horstretch>0</horstretch>
|
||||||
</property>
|
<verstretch>0</verstretch>
|
||||||
<property name="minimumSize">
|
</sizepolicy>
|
||||||
<size>
|
</property>
|
||||||
<width>70</width>
|
<property name="minimumSize">
|
||||||
<height>0</height>
|
<size>
|
||||||
</size>
|
<width>70</width>
|
||||||
</property>
|
<height>0</height>
|
||||||
<property name="toolTip">
|
</size>
|
||||||
<string>What kind of information will be kept in the column.</string>
|
</property>
|
||||||
</property>
|
<property name="toolTip">
|
||||||
</widget>
|
<string>What kind of information will be kept in the column.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="use_decorations">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show checkmarks</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Show check marks in the GUI. Values of 'yes', 'checked', and 'true'
|
||||||
|
will show a green check. Values of 'no', 'unchecked', and 'false' will show a red X.
|
||||||
|
Everything else will show nothing.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_27">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>10</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="2">
|
<item row="4" column="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user