Skip to content

Conversation

@soininen
Copy link
Contributor

@soininen soininen commented Dec 7, 2025

This PR contains a considerable rework of the column filters in stacked tables (a.k.a auto filters). The most impactful change is that the filters now filter solely by values; entity class ids and databases are not considered as part of the value anymore. Further, filter data is recreated when the filter menu is opened. This ensures the menu always contains latest information and simplifies the code a lot. Additionally, some minor bugs in the filter menu were fixed like the "Add current selection to filter" option not always working as intended due to a row number mistake.

Fixes #2886, #3229

Checklist before merging

  • Documentation is up-to-date
  • Release notes have been updated
  • Unit tests have been added/updated accordingly
  • Code has been formatted by black & isort
  • Unit tests pass

Use signals instead to make the models independent of DB editor.

Re #3229
The list in DB editor wasn't chronologically ordered.

Also, made RecentDatabasesPopupMenu independent of DB editor.

Re #3229
Stacked tables would try to repaint their contents while a new DB
was being added to DB editor. This failed because the db_map used
by the views' single models was unregistered from DB manager
and therefore DB locks associated with the DB were not present.

Re #3229
Modernized and simplified code regarding (auto) filter menus.
Some internal semantics did change, but no user-facing changes
were intended.

Re #3229
Menus are UI components and have no place in the models.

Re #3229
Since StackedTableView is used as a base class for the empty tables
who don't use autofilter functionality, it makes more sense to
offer it as a mixin.
Also, the functionality is only used in spine_db_editor so move
the class there from spinetoolbox.widgets

Re #3229
This is a considerable refactoring to auto filter functionality in
stacked tables (compound/single models).
Originally, filter data carried entity class ids and DB mappings
with it but this complicated stuff and caused bugs.
Filter data is now simply a set values that should pass the filter.

Further, the filter doesn't follow DB changes with fetch parents
anymore since that also complicated stuff too much.
Instead, we now recreate the available values every time the
filter menu is opened. If this proves to be too slow for
large datasets, we may consider a caching scheme later.

Re #2886
Re #3229
@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

❌ Patch coverage is 80.79332% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.02%. Comparing base (39e8b30) to head (7f5aa62).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...olbox/spine_db_editor/widgets/custom_qtableview.py 54.54% 34 Missing and 1 partial ⚠️
...inetoolbox/spine_db_editor/widgets/custom_menus.py 77.01% 18 Missing and 2 partials ⚠️
...olbox/spine_db_editor/mvcmodels/compound_models.py 84.00% 10 Missing and 2 partials ⚠️
...lbox/spine_db_editor/widgets/stacked_view_mixin.py 47.05% 9 Missing ⚠️
...toolbox/spine_db_editor/widgets/spine_db_editor.py 73.07% 5 Missing and 2 partials ⚠️
...inetoolbox/mvcmodels/filter_checkbox_list_model.py 94.93% 3 Missing and 1 partial ⚠️
...lbox/spine_db_editor/widgets/tabular_view_mixin.py 50.00% 3 Missing ⚠️
...toolbox/spine_db_editor/mvcmodels/single_models.py 95.00% 1 Missing ⚠️
spinetoolbox/widgets/custom_qwidgets.py 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3231      +/-   ##
==========================================
+ Coverage   69.78%   70.02%   +0.24%     
==========================================
  Files         201      202       +1     
  Lines       39048    39081      +33     
  Branches     4729     4725       -4     
==========================================
+ Hits        27248    27367     +119     
+ Misses      10493    10412      -81     
+ Partials     1307     1302       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@soininen soininen merged commit 183ce08 into master Dec 8, 2025
35 of 36 checks passed
@soininen soininen deleted the 3229_fix_auto_filters branch December 8, 2025 06:34
@jkiviluo
Copy link
Member

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter checkbox list doesn't update when parameter values change

3 participants