From 35ce75e29c0b0d822514563c21c6641514628dce Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:35:34 +0100 Subject: [PATCH 1/2] fix a exception when trying to edit a rule recently created when commiting the change, TypeError: 'tuple' object does not support item assignment this only occurs if the rule was create during the current session but not in a new session --- src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py index 4e16173e1d..84902d7caa 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py @@ -532,7 +532,7 @@ class TbIconRulesTab(LazyConfigWidgetBase, Ui_Form): continue icon_item = self.rules_table.item(r, ICON_COLUMN) - d = v[cat_item.lookup_name][value_text] + d = list(v[cat_item.lookup_name][value_text]) if icon_item.is_modified: if value_item.is_template: From 1237f103c55921d1bc98bfba849f346448cf96b5 Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Thu, 30 Jan 2025 18:39:03 +0100 Subject: [PATCH 2/2] fix parent of hierarchical categories disappear --- .../gui2/preferences/look_feel_tabs/tb_icon_rules.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py index 84902d7caa..e1b2d1b5cc 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_icon_rules.py @@ -355,6 +355,7 @@ class TbIconRulesTab(LazyConfigWidgetBase, Ui_Form): def populate_content(self): field_metadata = self.gui.current_db.field_metadata category_icons = self.gui.tags_view.model().category_custom_icons + is_hierarchical_category = self.gui.tags_view.model().is_key_a_hierarchical_category only_current_library = self.show_only_current_library.isChecked() v = gprefs['tags_browser_value_icons'] row = 0 @@ -366,6 +367,15 @@ class TbIconRulesTab(LazyConfigWidgetBase, Ui_Form): if category in field_metadata: display_name = field_metadata[category]['name'] all_values = self.gui.current_db.new_api.all_field_names(category) + if is_hierarchical_category(category): + rslt = set() + for value in all_values: + idx = 0 + while idx >= 0: + rslt.add(value) + idx = value.rfind('.') + value = value[:idx] + all_values = rslt elif only_current_library: continue else: