From 52209e7f58a0c4622e744d952ecdb6d723edc5a9 Mon Sep 17 00:00:00 2001
From: Charles Haley <>
Date: Sat, 5 Mar 2011 15:43:24 +0000
Subject: [PATCH] Make decorating custom columns in the GUI a separate
'display' option from subtype. Add the UI to control it to preferences.
---
src/calibre/gui2/library/models.py | 5 +-
.../gui2/preferences/create_custom_column.py | 10 +++
.../gui2/preferences/create_custom_column.ui | 69 ++++++++++++++-----
3 files changed, 64 insertions(+), 20 deletions(-)
diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py
index 1a8d4e93bc..787b18facc 100644
--- a/src/calibre/gui2/library/models.py
+++ b/src/calibre/gui2/library/models.py
@@ -689,9 +689,8 @@ class BooksModel(QAbstractTableModel): # {{{
if datatype in ('text', 'comments', 'composite', 'enumeration'):
self.dc[col] = functools.partial(text_type, idx=idx,
mult=self.custom_columns[col]['is_multiple'])
- if datatype == 'composite':
- csort = self.custom_columns[col]['display'].get('composite_sort', 'text')
- if csort == 'bool':
+ if datatype in ['text', 'composite', 'enumeration']:
+ if self.custom_columns[col]['display'].get('use_decorations', False):
self.dc_decorator[col] = functools.partial(
bool_type_decorator, idx=idx,
bool_cols_are_tristate=tweaks['bool_custom_columns_are_tristate'] != 'no')
diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py
index def74a4864..9348098dc9 100644
--- a/src/calibre/gui2/preferences/create_custom_column.py
+++ b/src/calibre/gui2/preferences/create_custom_column.py
@@ -121,6 +121,8 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
elif ct == 'enumeration':
self.enum_box.setText(','.join(c['display'].get('enum_values', [])))
self.datatype_changed()
+ if ct in ['text', '*text', 'composite', 'enumeration']:
+ self.use_decorations.setChecked(c['display'].get('use_decorations', False))
self.exec_()
def shortcut_activated(self, url):
@@ -161,6 +163,11 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
getattr(self, 'composite_'+x).setVisible(col_type == 'composite')
for x in ('box', 'default_label', 'label'):
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):
col = unicode(self.column_name_box.text()).strip()
@@ -233,6 +240,9 @@ class CreateCustomColumn(QDialog, Ui_QCreateCustomColumn):
'list more than once').format(l[i]))
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:
db.field_metadata
self.parent.custcols[key] = {
diff --git a/src/calibre/gui2/preferences/create_custom_column.ui b/src/calibre/gui2/preferences/create_custom_column.ui
index f045141ecb..aaa69f5e4b 100644
--- a/src/calibre/gui2/preferences/create_custom_column.ui
+++ b/src/calibre/gui2/preferences/create_custom_column.ui
@@ -88,23 +88,58 @@
-
-
-
-
- 0
- 0
-
-
-
-
- 70
- 0
-
-
-
- What kind of information will be kept in the column.
-
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 70
+ 0
+
+
+
+ What kind of information will be kept in the column.
+
+
+
+ -
+
+
+ Show checkmarks
+
+
+ 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.
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 10
+ 0
+
+
+
+
+ 20
+ 0
+
+
+
+
+
-