refactor(ui): refactor SearchPanel classes to use newer MVC pattern

This commit is contained in:
Travis Abendshien
2026-07-20 04:25:42 -07:00
parent 74f77de962
commit 9780d68d2c
15 changed files with 281 additions and 379 deletions
+4 -3
View File
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: (c) TagStudio Contributors
# SPDX-License-Identifier: GPL-3.0-only
# pyright: reportPrivateUsage = false
from collections.abc import Callable
@@ -22,7 +23,7 @@ def test_build_tag_panel_add_sub_tag_callback(
panel: BuildTagPanel = BuildTagPanel(library, child)
qtbot.addWidget(panel)
panel._add_parent_tag_callback(parent.id) # pyright: ignore[reportPrivateUsage]
panel._add_parent_tag_callback(parent.id)
assert len(panel.parent_ids) == 1
@@ -40,7 +41,7 @@ def test_build_tag_panel_remove_subtag_callback(
panel: BuildTagPanel = BuildTagPanel(library, child)
qtbot.addWidget(panel)
panel._remove_parent_tag_callback(parent.id) # pyright: ignore[reportPrivateUsage]
panel._remove_parent_tag_callback(parent.id)
assert len(panel.parent_ids) == 0
@@ -58,7 +59,7 @@ def test_build_tag_panel_add_alias_callback(
panel: BuildTagPanel = BuildTagPanel(library, tag)
qtbot.addWidget(panel)
panel._create_alias_callback() # pyright: ignore[reportPrivateUsage]
panel._create_alias_callback()
assert panel.aliases_table.rowCount() == 1
+4 -6
View File
@@ -8,13 +8,12 @@ from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.controllers.tag_search_panel_controller import TagSearchPanel
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.ts_qt import QtDriver
from tagstudio.qt.views.tag_search_panel_view import TagSearchPanelView
from tagstudio.qt.views.search_panel_view import SearchPanelView
def test_update_tags(qtbot: QtBot, library: Library):
# Given
panel = TagSearchPanel(library, view=TagSearchPanelView(is_tag_chooser=True))
panel = TagSearchPanel(library, view=SearchPanelView("", is_chooser=True))
qtbot.addWidget(panel)
@@ -22,10 +21,9 @@ def test_update_tags(qtbot: QtBot, library: Library):
panel.update_items()
def test_tag_widget_actions_replaced_correctly(qtbot: QtBot, qt_driver: QtDriver, library: Library):
panel = TagSearchPanel(library, view=TagSearchPanelView(is_tag_chooser=True))
def test_tag_widget_actions_replaced_correctly(qtbot: QtBot, library: Library):
panel = TagSearchPanel(library, view=SearchPanelView(""))
qtbot.addWidget(panel)
panel.set_driver(qt_driver)
# Set the widget
tags = library.tags