diff --git a/tagstudio/src/core/library/alchemy/models.py b/tagstudio/src/core/library/alchemy/models.py index 843cb4e90..ff7a9e89a 100644 --- a/tagstudio/src/core/library/alchemy/models.py +++ b/tagstudio/src/core/library/alchemy/models.py @@ -50,7 +50,7 @@ class Tag(Base): aliases: Mapped[set[TagAlias]] = relationship(back_populates="tag") - parent_tags: Mapped[list["Tag"]] = relationship( + parent_tags: Mapped[set["Tag"]] = relationship( secondary=TagSubtag.__tablename__, primaryjoin="Tag.id == TagSubtag.parent_id", secondaryjoin="Tag.id == TagSubtag.child_id", @@ -76,39 +76,20 @@ def alias_strings(self) -> list[str]: def alias_ids(self) -> list[int]: return [tag.id for tag in self.aliases] - @property - def display_name(self) -> str: - if len(self.parent_tags) == 0: - return "" - - parent_tag = list(self.parent_tags)[0] - - if parent_tag is None: - return "" - - display_name = "" - - if parent_tag.shorthand.strip() == "" or parent_tag.shorthand is None: - display_name = " (" + parent_tag.name + ")" - else: - display_name = " (" + parent_tag.shorthand + ")" - - return self.name + display_name - def __init__( self, id: int | None = None, name: str | None = None, shorthand: str | None = None, aliases: set[TagAlias] | None = None, - parent_tags: list["Tag"] | None = None, + parent_tags: set["Tag"] | None = None, subtags: set["Tag"] | None = None, icon: str | None = None, color: TagColor = TagColor.DEFAULT, ): self.name = name self.aliases = aliases or set() - self.parent_tags = parent_tags or list() + self.parent_tags = parent_tags or set() self.subtags = subtags or set() self.color = color self.icon = icon diff --git a/tagstudio/src/qt/modals/tag_database.py b/tagstudio/src/qt/modals/tag_database.py index 3ac38a75f..04d2cc75c 100644 --- a/tagstudio/src/qt/modals/tag_database.py +++ b/tagstudio/src/qt/modals/tag_database.py @@ -84,10 +84,7 @@ def update_tags(self, query: str | None = None): row = QHBoxLayout(container) row.setContentsMargins(0, 0, 0, 0) row.setSpacing(3) - display_name = tag.display_name - tag_widget = TagWidget( - tag, tag_display_name=display_name, has_edit=True, has_remove=False - ) + tag_widget = TagWidget(tag, has_edit=True, has_remove=False) tag_widget.on_edit.connect(lambda checked=False, t=tag: self.edit_tag(t)) row.addWidget(tag_widget) self.scroll_layout.addWidget(container) diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index 4aa36762e..c8c14b382 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -661,7 +661,10 @@ def clear_select_action_callback(self): def show_tag_database(self): self.modal = PanelModal( - TagDatabasePanel(self.lib), "Library Tags", "Library Tags", has_save=False + TagDatabasePanel(self.lib), + "Library Tags", + "Library Tags", + has_save=False, ) self.modal.show() diff --git a/tagstudio/src/qt/widgets/tag.py b/tagstudio/src/qt/widgets/tag.py index 4f279617f..2d4cc7ce1 100644 --- a/tagstudio/src/qt/widgets/tag.py +++ b/tagstudio/src/qt/widgets/tag.py @@ -105,7 +105,6 @@ def __init__( tag: Tag, has_edit: bool, has_remove: bool, - tag_display_name: str = None, on_remove_callback: FunctionType = None, on_click_callback: FunctionType = None, on_edit_callback: FunctionType = None, @@ -125,7 +124,7 @@ def __init__( self.bg_button = QPushButton(self) self.bg_button.setFlat(True) - self.bg_button.setText(tag_display_name or tag.name) + self.bg_button.setText(tag.name) if has_edit: edit_action = QAction("Edit", self) edit_action.triggered.connect(on_edit_callback)