Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/tagstudio/qt/controllers/field_template_search_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def __init__(
self._unlimited_limit_item_label = Translations["field_template.all_field_templates"]
self._create_and_add_button_key = "field_template.create_add"

@override
def _get_max_limit(self) -> int:
return len(self.__lib.field_templates)

@override
def on_item_create(self, add_to_entry: bool = False) -> None:
"""Opens panel to create a new field template and optionally add it to an entry.
Expand Down
15 changes: 1 addition & 14 deletions src/tagstudio/qt/controllers/search_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,6 @@ def on_limit_changed(self, index: int) -> None:
def _get_limit(self) -> tuple[str, int]:
return self._limit_items[self.get_limit_index()]

def _get_previous_limit(self) -> tuple[str, int]:
return self._limit_items[self._previous_limit_index]

def _get_max_limit(self) -> int:
raise NotImplementedError()

def on_search_query_changed(self, query: str) -> None:
self.layout().create_and_add_button.setText(
Translations.format(self._create_and_add_button_key, query=query)
Expand Down Expand Up @@ -230,14 +224,7 @@ def update_items(self, query: str | None = None) -> None:
logger.info("[SearchPanel] Search results", results=self._search_results)

# Update every item widget with the new search result data
previous_limit: int = (
self._get_previous_limit()[1] > 0 and self._get_previous_limit()[1]
) or self._get_max_limit()
current_limit: int = (
self._get_limit()[1] > 0 and self._get_limit()[1]
) or self._get_max_limit()

for i in range(0, max(previous_limit, current_limit)):
for i in range(max(len(all_results), self.layout().scroll_layout.count())):
item: T | None = all_results[i] if i < len(all_results) else None
self.set_item_widget(item=item, index=i)

Expand Down
4 changes: 0 additions & 4 deletions src/tagstudio/qt/controllers/tag_search_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def __init__(
self._unlimited_limit_item_label = Translations["tag.all_tags"]
self._create_and_add_button_key = "tag.create_add"

@override
def _get_max_limit(self) -> int:
return len(self._lib.tags)

@override
def on_item_create(self, add_to_entry: bool = False) -> None:
"""Opens panel to create a new tag and optionally add it to an entry.
Expand Down
22 changes: 22 additions & 0 deletions tests/qt/test_tag_search_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ def test_update_tags(qtbot: QtBot, library: Library):
panel.update_items()


def test_removed_tag_capsules_hidden(qtbot: QtBot, library: Library):
"""Regression test for #1523."""
panel = TagSearchPanel(library, is_chooser=False)
qtbot.addWidget(panel)

# 1. Set view limit to "All Items"
panel.set_limit_index(panel.layout().limit_combobox.count() - 1)
panel.update_items()

# 2. Delete a tag
library.remove_tag(library.tags[-1].id)
panel.update_items()

# 3. Assert that there's the correct number of visible capsules and no duplicates
visible_capsules = [
i
for i in range(panel.layout().scroll_layout.count())
if not panel.get_item_widget(i, library).isHidden()
]
assert len(visible_capsules) == len(library.tags)


def test_capsule_actions_replaced_correctly(qtbot: QtBot, library: Library):
panel = TagSearchPanel(library, view=SearchPanelView(""))
qtbot.addWidget(panel)
Expand Down
Loading