From e62a22f000d65adcb6417c62adb579937eb2cd7b Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 29 Dec 2020 09:17:29 +0000 Subject: [PATCH] Bug #1909507: Enhancement: permit disambiguation of columns such as formats and #formats in rules editor. --- src/calibre/gui2/dialogs/template_dialog.py | 5 +++-- src/calibre/gui2/preferences/coloring.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py index aa1a17144b..74d89a7b11 100644 --- a/src/calibre/gui2/dialogs/template_dialog.py +++ b/src/calibre/gui2/dialogs/template_dialog.py @@ -242,7 +242,8 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): if self.coloring: self.color_layout.setVisible(True) for n1, k1 in cols: - self.colored_field.addItem(n1, k1) + self.colored_field.addItem(n1 + + (' (' + k1 + ')' if k1 != color_row_key else ''), k1) self.colored_field.setCurrentIndex(self.colored_field.findData(color_field)) elif self.iconing or self.embleming: self.icon_layout.setVisible(True) @@ -253,7 +254,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): self.icon_field.setVisible(False) for n1, k1 in cols: - self.icon_field.addItem(n1, k1) + self.icon_field.addItem('{} ({})'.format(n1, k1), k1) self.icon_file_names = [] d = os.path.join(config_dir, 'cc_icons') if os.path.exists(d): diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index 0ce5157b98..61882f5c1a 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -137,7 +137,7 @@ class ConditionEditor(QWidget): # {{{ for key in sorted( conditionable_columns(fm), key=lambda key: sort_key(fm[key]['name'])): - self.column_box.addItem(fm[key]['name'], key) + self.column_box.addItem('{} ({})'.format(fm[key]['name'], key), key) self.column_box.setCurrentIndex(0) self.column_box.currentIndexChanged.connect(self.init_action_box) @@ -443,7 +443,8 @@ class RuleEditor(QDialog): # {{{ continue name = all_columns_string if key == color_row_key else fm[key]['name'] if name: - self.column_box.addItem(name, key) + self.column_box.addItem(name + + (' (' + key + ')' if key != color_row_key else ''), key) self.column_box.setCurrentIndex(0) if self.rule_kind == 'color':