diff --git a/ArtNet/artnet_manager.py b/ArtNet/artnet_manager.py index f2220f5..6759478 100644 --- a/ArtNet/artnet_manager.py +++ b/ArtNet/artnet_manager.py @@ -416,8 +416,9 @@ class ArtNetManager: self.all_images[self.curr_image_index], art_ID, image_link, file_name=s[-1], description=image_description, collections=collections) - self.curr_active_window.set_tag_list( - [self.db_connection.get_tag_by_ID(x)[0][1].strip() for x in self.db_connection.get_art_tags_by_ID(art_ID)]) + tmp = [self.db_connection.get_tag_by_ID(x) for x in self.db_connection.get_art_tags_by_ID(art_ID)] + tags = [{"id": int(t[0][0]), "name": t[0][1].strip(), "description": t[0][2].strip(), "category": t[0][3]} for t in tmp] + self.curr_active_window.set_tag_list(tags) self.curr_active_window.data_changed = False self.curr_active_window.setting_up_data = False diff --git a/ArtNet/db/db_adapter.py b/ArtNet/db/db_adapter.py index ecd9401..60ca3f0 100644 --- a/ArtNet/db/db_adapter.py +++ b/ArtNet/db/db_adapter.py @@ -931,7 +931,8 @@ class DBAdapter: for tag_ID in collected_tags: tag_data = self.get_tag_by_ID(tag_ID) if len(tag_data) != 0: - result.append(tag_data[0][1].strip()) + result.append({"name": tag_data[0][1].strip(), "id": int(tag_data[0][0]), + "description": tag_data[0][2].strip(), "category": int(tag_data[0][3])}) return result def get_all_tag_impliers_by_ID(self, ID: int) -> list: diff --git a/ArtNet/gui/importer_window.py b/ArtNet/gui/importer_window.py index 610f8fc..f6a8a1f 100644 --- a/ArtNet/gui/importer_window.py +++ b/ArtNet/gui/importer_window.py @@ -499,18 +499,20 @@ class ImporterWindow(ArtnetMainWindow): :param tags: :return: """ - tags.sort() + tags.sort(key=lambda x: x["name"]) item_model = QStandardItemModel(self.ui.search_result_list) for tag in tags: - item = QStandardItem(tag) + tag_name = tag["name"] + item = QStandardItem(tag_name) flags = Qt.ItemIsEnabled - if tag not in self.curr_implied_tags: + if tag_name not in self.curr_implied_tags: # new tag and not implied yet item.setData(Qt.Unchecked, Qt.CheckStateRole) + item.setToolTip(f"Tag ID: {tag['id']}\n\n"+tag["description"]+f"\nCategory: {tag['category']}") flags |= Qt.ItemIsUserCheckable - if self.curr_tags is not None and tag in (self.curr_tags + self.curr_implied_tags + self.curr_tag_aliases): + if self.curr_tags is not None and tag_name in (self.curr_tags + self.curr_implied_tags + self.curr_tag_aliases): # already selected, implied or aliased tags item.setCheckState(Qt.Checked) item.setFlags(flags) @@ -534,28 +536,30 @@ class ImporterWindow(ArtnetMainWindow): :param no_implication: not used :return: """ - tags.sort() + tags.sort(key=lambda x: x["name"]) self.curr_tags = tags item_model = QStandardItemModel(self.ui.tag_list) implied_tags = [] for x in self.curr_tags: # collect all implied tags into a list - implied_tags += self.main.db_connection.get_all_tag_implications_by_name(x) + implied_tags += self.main.db_connection.get_all_tag_implications_by_name(x["name"]) self.set_implied_list(implied_tags) for tag in tags: - item = QStandardItem(tag) + tag_name = tag["name"] + item = QStandardItem(tag_name) flags = Qt.ItemIsEnabled - if tag not in self.curr_implied_tags: + if tag_name not in self.curr_implied_tags: # new tag and not implied yet item.setData(Qt.Unchecked, Qt.CheckStateRole) + item.setToolTip(f"Tag ID: {tag['id']}\n\n" + tag["description"] + f"\nCategory: {tag['category']}") flags |= Qt.ItemIsUserCheckable if set_checked: - if tag not in self.curr_implied_tags: + if tag_name not in self.curr_implied_tags: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) @@ -578,11 +582,13 @@ class ImporterWindow(ArtnetMainWindow): item_model = QStandardItemModel(self.ui.implied_tag_list) done = [] for tag in tags: - if tag in done: + tag_name = tag["name"] + if tag_name in done: continue else: - done.append(tag) - item = QStandardItem(tag) + done.append(tag_name) + item = QStandardItem(tag_name) + item.setToolTip(f"Tag ID: {tag['id']}\n\n"+tag["description"]+f"\nCategory: {tag['category']}") item_model.appendRow(item) self.ui.implied_tag_list.setModel(item_model) @@ -1081,7 +1087,7 @@ class ImporterWindow(ArtnetMainWindow): result = [] for tag_name, tag_desc, tag_category, tag_id in tags: - result.append(tag_name) + result.append({"name": tag_name, "description": tag_desc, "category": tag_category, "id": tag_id}) self.set_tag_search_result_list(result)