Skip to content

Commit

Permalink
fix: removed display names, as they didn't display properly and shoul…
Browse files Browse the repository at this point in the history
…d be added in a different PR
  • Loading branch information
DandyDev01 committed Dec 13, 2024
1 parent 979c6f3 commit 38b0e5d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
25 changes: 3 additions & 22 deletions tagstudio/src/core/library/alchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions tagstudio/src/qt/modals/tag_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions tagstudio/src/qt/widgets/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 38b0e5d

Please sign in to comment.