feat: field template manager (#1374)

* refactor: merge tag_database.py into tag_search.py

* refactor: mvc split of tag_search.py

* refactor: tweaks

* doc: REUSE license information

* doc: add REUSE license information

* refactor: split generic functionality into "search panel"

* feat: field template search panel

* feat: field template manager

* fix: rename `tag.view_limit` key for other languages

* tweak: remove exclusion from field template search panel

* tweak: rename `is_field_chooser` to `is_field_template_chooser`

* feat: switch from multiple inheritance to composition

---------

Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
This commit is contained in:
Trigam
2026-06-23 00:59:26 -04:00
committed by GitHub
parent ae787eaf5e
commit 185691bcd2
42 changed files with 1307 additions and 679 deletions

View File

@@ -6,30 +6,31 @@ from PySide6.QtCore import SIGNAL
from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.mixed.tag_search import TagSearchPanel
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
def test_update_tags(qtbot: QtBot, library: Library):
# Given
panel = TagSearchPanel(library)
panel = TagSearchPanel(library, view=TagSearchPanelView(is_tag_chooser=True))
qtbot.addWidget(panel)
# When
panel.update_tags()
panel.update_items()
def test_tag_widget_actions_replaced_correctly(qtbot: QtBot, qt_driver: QtDriver, library: Library):
panel = TagSearchPanel(library)
panel = TagSearchPanel(library, view=TagSearchPanelView(is_tag_chooser=True))
qtbot.addWidget(panel)
panel.driver = qt_driver
panel.set_driver(qt_driver)
# Set the widget
tags = library.tags
panel.set_tag_widget(tags[0], 0)
tag_widget: TagWidget = panel.scroll_layout.itemAt(0).widget() # pyright: ignore[reportAssignmentType]
panel.set_item_widget(tags[0], 0)
tag_widget: TagWidget = panel.get_item_widget(0, library)
should_replace_actions = {
tag_widget: ["on_edit()", "on_remove()"],
@@ -41,7 +42,7 @@ def test_tag_widget_actions_replaced_correctly(qtbot: QtBot, qt_driver: QtDriver
ensure_one_receiver_per_action(should_replace_actions)
# Set the widget again
panel.set_tag_widget(tags[0], 0)
panel.set_item_widget(tags[0], 0)
# Ensure each action has been replaced (amount of receivers is still 1)
ensure_one_receiver_per_action(should_replace_actions)