-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
Avoid rebuilding models for ListQuantityGroup and ListTextGroup #1903
Conversation
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
0f77dbd
to
fd51a61
Compare
pages/settings/PageCanbusStatus.qml
Outdated
id: busOffCounters | ||
} | ||
content.children: [ | ||
ColumnLayout { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't normally reach for a layout - did you mean to use ColumnLayout deliberately over Column? Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the ColumnLayout was from WIP code so I've reverted it to a Column, as there aren't any particular benefits here from using the layout.
|
||
int main(int argc, char **argv) \ | ||
{ | ||
qmlRegisterType<Victron::VenusOS::QuantityObject>("Victron.VenusOS", 2, 0, "QuantityObject"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These (and in other tests) would not be needed if the test executable was correctly linked to the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would be worth cleaning that up, as a separate task
import Victron.VenusOS | ||
import QtQuick.Window | ||
|
||
TestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the test cover the append/remove cases or are they not applicable because of the usage of QQmlListProperty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, not applicable as you said. We can have add/remove support in QuantityObjectModel in the future if needed.
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
fd51a61
to
777b93f
Compare
No description provided.