Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid rebuilding models for ListQuantityGroup and ListTextGroup #1903

Conversation

blammit
Copy link
Contributor

@blammit blammit commented Feb 13, 2025

No description provided.

@blammit blammit linked an issue Feb 13, 2025 that may be closed by this pull request
@blammit blammit force-pushed the blam/1338-avoid-rebuilding-models-for-listquantitygroup-and-listtextgroup branch from 0f77dbd to fd51a61 Compare February 13, 2025 04:17
@blammit blammit force-pushed the blam/1338-avoid-rebuilding-models-for-listquantitygroup-and-listtextgroup branch from fd51a61 to 777b93f Compare February 14, 2025 01:08
CMakeLists.txt Outdated
@@ -703,6 +702,11 @@ list(APPEND VenusQMLModule_CPP_SOURCES
src/productinfo.h
src/quantityinfo.h
src/quantityinfo.cpp
src/quantityinfo.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated file reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@blammit blammit force-pushed the blam/1338-avoid-rebuilding-models-for-listquantitygroup-and-listtextgroup branch from 777b93f to f2e839a Compare February 17, 2025 22:32
QuantityObject provides QObject-based access to a quantity value.
QuantityObjectModel provides a model of QuantityObject values, and
is able to filter out items that do not have valid values.

This allows ListQuantityGroup and its derived types to specify their
models without creating a JavaScript array that directly refers each
quantity value. Otherwise, whenever a quantity value is updated, the
entire array is rebuilt, which in turn causes the QuantityRow repeater
to rebuild its delegates.

Part of #1338
Change QuantityRow's model type to QuantityObjectModel, so that the
model cannot be specified as an array of real values, and update the
codebase accordingly so that it always uses QuantityObject with
QuantityObjectModel instead of an array-based model in all cases where
multiple quantities are displayed.

This greatly improves the performance of QuantityRow in updating its
values, as the Repeater no longer rebuilds its delegates whenever a
single quantity changes in the model.

Also, since QuantityObjectModel is able to filter out invalid values,
it is not necessary to create and show separate models depending on
whether particular values are valid.

The updates affect the following types and their uses:
- QuantityRow
- ListQuantityGroup
- ListQuantityGroupNavigation

Also remove ListTextGroup and replace its uses with ListQuantityGroup,
as ListTextGroup was being used to show text alongside number values,
and that can now easily be done with ListQuantityGroup as a
QuantityObject value can be a string if the unit is Units_None.

Part of #1338
@blammit blammit force-pushed the blam/1338-avoid-rebuilding-models-for-listquantitygroup-and-listtextgroup branch from f2e839a to faaf021 Compare February 20, 2025 06:07
@blammit
Copy link
Contributor Author

blammit commented Feb 20, 2025

Rebased.

@blammit blammit merged commit bc746d9 into main Feb 20, 2025
2 checks passed
@blammit blammit deleted the blam/1338-avoid-rebuilding-models-for-listquantitygroup-and-listtextgroup branch February 20, 2025 06:09
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.

Avoid rebuilding models for ListQuantityGroup and ListTextGroup
3 participants