From 52209e7f58a0c4622e744d952ecdb6d723edc5a9 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 5 Mar 2011 15:43:24 +0000 Subject: [PATCH 1/3] 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 + + + + + From f4cc10dd42e1009b06785c350f99aa37292f19c9 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 5 Mar 2011 16:06:53 +0000 Subject: [PATCH 2/3] Don't show decorations for is_multiple columns --- src/calibre/gui2/library/models.py | 14 ++++++++------ .../gui2/preferences/create_custom_column.py | 10 +++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index 787b18facc..b782cc7c72 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -687,13 +687,14 @@ class BooksModel(QAbstractTableModel): # {{{ idx = self.custom_columns[col]['rec_index'] datatype = self.custom_columns[col]['datatype'] 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 in ['text', 'composite', 'enumeration']: + mult=self.custom_columns[col]['is_multiple'] + self.dc[col] = functools.partial(text_type, idx=idx, mult=mult) + if datatype in ['text', 'composite', 'enumeration'] and not mult: 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') + bool_type_decorator, idx=idx, + bool_cols_are_tristate= + tweaks['bool_custom_columns_are_tristate'] != 'no') elif datatype in ('int', 'float'): self.dc[col] = functools.partial(number_type, idx=idx) elif datatype == 'datetime': @@ -702,7 +703,8 @@ class BooksModel(QAbstractTableModel): # {{{ self.dc[col] = functools.partial(bool_type, idx=idx) self.dc_decorator[col] = functools.partial( 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') elif datatype == 'rating': self.dc[col] = functools.partial(rating_type, idx=idx) elif datatype == 'series': diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py index 9348098dc9..50d567d239 100644 --- a/src/calibre/gui2/preferences/create_custom_column.py +++ b/src/calibre/gui2/preferences/create_custom_column.py @@ -121,7 +121,7 @@ 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']: + if ct in ['text', 'composite', 'enumeration']: self.use_decorations.setChecked(c['display'].get('use_decorations', False)) self.exec_() @@ -163,11 +163,7 @@ 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) + self.use_decorations.setVisible(col_type in ['text', 'composite', 'enumeration']) def accept(self): col = unicode(self.column_name_box.text()).strip() @@ -240,7 +236,7 @@ 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']: + if col_type in ['text', 'composite', 'enumeration']: display_dict['use_decorations'] = self.use_decorations.checkState() if not self.editing_col: From 342349ee0e01c2013dbdd684885bc64238d43a2a Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sat, 5 Mar 2011 21:03:46 +0000 Subject: [PATCH 3/3] Fix #8929 (reopened enhancement) Improve Content Server usability. --- src/calibre/library/server/browse.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/calibre/library/server/browse.py b/src/calibre/library/server/browse.py index 585c1255a4..97bfc30f14 100644 --- a/src/calibre/library/server/browse.py +++ b/src/calibre/library/server/browse.py @@ -666,15 +666,13 @@ class BrowseServer(object): if add_category_links: added_key = False fm = mi.metadata_for_field(key) - if val and fm and fm['is_category'] and \ + if val and fm and fm['is_category'] and not fm['is_csp'] and\ key != 'formats' and fm['datatype'] not in ['rating']: categories = mi.get(key) if isinstance(categories, basestring): categories = [categories] dbtags = [] for category in categories: - if category not in ccache: - continue dbtag = None for tag in ccache[key]: if tag.name == category: