Skip to content

Conversation

@soininen
Copy link
Contributor

@soininen soininen commented Nov 28, 2025

The main user-facing changes in this PR are:

  • Selecting alternatives in Alternative tree does not affect the Entity table anymore as entities do not have alternatives.
  • Selecting scenarios from Scenario tree makes the Entity tree show entities that are active in the chosen scenario(s).
  • Pre-filled values in the empty rows are now consistent and depend on the entity and alternative selections as one would expect.

A lot of of DB Editor code has been refactored. The main goal was to gather code that was scattered all over the DB editor mixins and views into a single place (see selection_for_filtering.py and default_row_generator.py) which can be unit tested in isolation.

Resolves #3216

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

The action tried to clear auto filter menus on empty models which
don't have them.

Re #3216
Simplify the collection of entity ids which have visible parameter
values; rename things to better reflect their use-cases.

Re #3216
A new class, FilterSelection, now handles changes in Entity tree
selections regarding filtering of Stacked and Graph views.
All the code is now in one place.

Re #3216
This simplifies code paths a little bit.

Re #3216
Moved some code where it belongs.

Re #3216
We don't store the ids of selected entities in the widget anymore.

Re #3216
The additional entity selection from Graph view that affect the stacked
tables only is now handled through the FilterSelection instance in
SpineDBEditor.

Re #3216
Similarly to how we now deal with filtering by entity and entity class
selections, alternative selections in Alternative and Scenario trees
are now handled and dispatched in a single location in DB editor.

Re #3216
Entities don't have an alternative field so filtering by alternative
makes no sense.

Re #3216
Opening scenario generator was broken since the management of
alternative selections was moved into AlternativeSelectionForFiltering.

Re #3216
A new class, ScenarioSelectionForFiltering, calculates selected scenario
ids similarly to the corresponding classes for Entity and Alternative
trees.

Re #3216
When selecting scenarios from the scenario tree, do not select
the scenario's alternatives.

Re #3216
The table now shows the entities that would be visible in the seleceted
scenario(s) according to entity alternatives and active_by_defaults.

Re #3216
- Empty row defaults are now handled in a new class, DefaultRowGenerator
- Concerted selection clearing of Entity, Alternative and Scenario trees
  is now handled solely by SpineDBEditor.
- EntityTreeView now relies less on directly calling SpineDBEditor;
  rather, it uses signals.
  In the long run, we should remove all references to spine_db_editor
  from all views and models to make the code more modular and less
  spaghetti.

Re #3216
@soininen soininen force-pushed the 3216_fix_scenario_filtering branch from 7b9d5a9 to 2a6cf9c Compare November 28, 2025 07:26
- Improve entity selections with multiple databases
- Update default row values when data, e.g. selected class name, changes
- Fix unit tests

Re #3216
@soininen soininen force-pushed the 3216_fix_scenario_filtering branch from d45f3f1 to 7d869e3 Compare December 2, 2025 10:19
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 90.54505% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.78%. Comparing base (7c3e86b) to head (7d869e3).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...oolbox/spine_db_editor/widgets/graph_view_mixin.py 70.77% 37 Missing and 8 partials ⚠️
...netoolbox/spine_db_editor/default_row_generator.py 92.40% 9 Missing and 3 partials ⚠️
...x/spine_db_editor/widgets/custom_qgraphicsviews.py 43.75% 9 Missing ⚠️
...toolbox/spine_db_editor/widgets/tree_view_mixin.py 87.71% 4 Missing and 3 partials ⚠️
...olbox/spine_db_editor/mvcmodels/compound_models.py 93.05% 4 Missing and 1 partial ⚠️
...olbox/spine_db_editor/widgets/custom_qtableview.py 57.14% 3 Missing ⚠️
...toolbox/spine_db_editor/mvcmodels/single_models.py 97.26% 2 Missing ⚠️
...oolbox/spine_db_editor/widgets/custom_qtreeview.py 95.45% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3228      +/-   ##
==========================================
+ Coverage   69.05%   69.78%   +0.73%     
==========================================
  Files         199      201       +2     
  Lines       38656    39048     +392     
  Branches     4634     4729      +95     
==========================================
+ Hits        26693    27250     +557     
+ Misses      10654    10492     -162     
+ Partials     1309     1306       -3     

☔ 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 39e8b30 into master Dec 2, 2025
19 checks passed
@soininen soininen deleted the 3216_fix_scenario_filtering branch December 2, 2025 10:41
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.

Alternative and scenario filters in DB editor do not work with Entity table

2 participants