From 1dd8f4af30e0b2277ce8971a4a7a6e2779c0fe97 Mon Sep 17 00:00:00 2001 From: Peery Date: Fri, 7 Jan 2022 23:00:10 +0100 Subject: [PATCH] Added quick select for TagSelectDialog Implemented the last remaining tag in the TagSelectDialog to be automatically selected when confirming the dialog. Improved logging of DB connection and selected tags --- ArtNet/artnet_manager.py | 2 +- .../gui/dialogs/tag_select_dialog/tag_select_dialog.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ArtNet/artnet_manager.py b/ArtNet/artnet_manager.py index ff36380..3697063 100644 --- a/ArtNet/artnet_manager.py +++ b/ArtNet/artnet_manager.py @@ -358,7 +358,7 @@ class ArtNetManager: self.window.setting_up_data = False def create_db_connection(self, host: str, port: int, database: str, user: str, password: str) -> DBAdapter: - print("Changing db connection to ".format(host, port, user, password)) + print(f"Changing db connection to {host}:{port} {user}@{database}") return DBAdapter(user=user, password=password, host=host, port=port, database=database) def get_root(self) -> str: diff --git a/ArtNet/gui/dialogs/tag_select_dialog/tag_select_dialog.py b/ArtNet/gui/dialogs/tag_select_dialog/tag_select_dialog.py index d5814d2..5c38307 100644 --- a/ArtNet/gui/dialogs/tag_select_dialog/tag_select_dialog.py +++ b/ArtNet/gui/dialogs/tag_select_dialog/tag_select_dialog.py @@ -63,7 +63,13 @@ class TagSelectDialog(QtWidgets.QDialog): if super(TagSelectDialog, self).exec_() == QtWidgets.QDialog.Rejected: return None - if self.selection is None: + if self.ui.search_result_list.model().rowCount() == 1 and self.selection is None: + # quick select for the last remaining tag + model_index = self.ui.search_result_list.model().index(0, 0) + item_data = self.ui.search_result_list.model().itemData(model_index) + + self.selection = item_data[0] + elif self.selection is None: # nothing selected return None tag = self.parent.get_tag(self.selection)[0] tag_data = { @@ -74,4 +80,5 @@ class TagSelectDialog(QtWidgets.QDialog): "implications": self.parent.get_tag_implications(tag[0]), "category_id": tag[2] } + print("TagSelectDialog selected tag:", tag_data) return tag_data