Skip to content

Commit

Permalink
Use AllowedItemModel instead of ObjectModel where possible
Browse files Browse the repository at this point in the history
AllowedItemModel automatically filters out non-allowed items so that
they are not part of any view that uses the model.

This means that:
- views won't need to create unnecessary delegates
- when key navigation is added, it won't try to focus non-allowed
delegates

AllowedItemModel does not have an insert() function so it cannot be
used from SwipePageModel.

Part of #1732
  • Loading branch information
blammit committed Jan 15, 2025
1 parent e666ee7 commit d11a187
Show file tree
Hide file tree
Showing 129 changed files with 148 additions and 148 deletions.
6 changes: 3 additions & 3 deletions components/PageGensetModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import QtQuick
import Victron.VenusOS

ObjectModel {
AllowedItemModel {
id: root

property string bindPrefix
Expand Down Expand Up @@ -226,7 +226,7 @@ ObjectModel {

Page {
GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListQuantity {
//% "Speed"
text: qsTrId("ac-in-genset_speed")
Expand Down Expand Up @@ -345,7 +345,7 @@ ObjectModel {

Page {
GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSpinBox {
//% "Charge voltage"
text: qsTrId("genset_charge_voltage")
Expand Down
2 changes: 1 addition & 1 deletion components/listitems/ListChargeSchedule.qml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ListNavigation {
id: scheduledOptionsPage

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSwitch {
id: itemEnabled

Expand Down
2 changes: 1 addition & 1 deletion pages/ControlCardsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Page {
maximumFlickVelocity: Theme.geometry_flickable_maximumFlickVelocity
flickDeceleration: Theme.geometry_flickable_flickDeceleration

model: ObjectModel {
model: AllowedItemModel {
Loader {
active: systemType.value === "ESS" || systemType.value === "Hub-4"
width: active ? root.cardWidth : -cardsView.spacing
Expand Down
2 changes: 1 addition & 1 deletion pages/NotificationLayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Item {
spacing: Theme.geometry_toastNotification_bottomMargin
layoutDirection: Qt.RightToLeft // layout from bottom to top

model: ObjectModel {
model: AllowedItemModel {
id: toastItemsModel
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SwipeViewPage {
id: settingsListView

clip: true
model: ObjectModel {
model: AllowedItemModel {
SettingsListNavigation {
text: CommonWords.devices
//% "All connected devices"
Expand Down
2 changes: 1 addition & 1 deletion pages/evcs/EvChargerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Page {
title: evCharger.name

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListItemBackground {
height: phaseTable.y + phaseTable.height

Expand Down
2 changes: 1 addition & 1 deletion pages/evcs/EvChargerSetupPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Page {
required property string bindPrefix

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListEvChargerPositionRadioButtonGroup {
dataItem.uid: root.bindPrefix + "/Position"
}
Expand Down
2 changes: 1 addition & 1 deletion pages/invertercharger/OverviewInverterChargerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListItem {
id: modeListButton

Expand Down
2 changes: 1 addition & 1 deletion pages/settings/GeneratorCondition.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ListNavigation {

GradientListView {

model: ObjectModel {
model: AllowedItemModel {

ListSwitch {
text: root.enableDescription
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageCanbusStatus.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListTextGroup {
id: stateGroup

Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageDeviceInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {
ListText {
//% "Connection"
text: qsTrId("settings_deviceinfo_connection")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGenerator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Page {
}
}

ObjectModel {
AllowedItemModel {
id: startStopModel

ListSwitch {
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGeneratorAcLoad.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Page {

GradientListView {

model: ObjectModel {
model: AllowedItemModel {

ListSwitch {
id: enableSwitch
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGeneratorConditions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListRadioButtonGroup {
id: monitorService
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGeneratorRuntimeService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListText {
//% "Total run time"
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGeneratorTestRun.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Page {

GradientListView {

model: ObjectModel {
model: AllowedItemModel {

ListSwitch {
id: enableSwitch
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageGps.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListText {
text: CommonWords.status
secondaryText: {
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageHub4Debug.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSpinBox {
id: gridSetpoint

Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageRelayGenerator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ PageGenerator {

model: !relayFunction.isValid || relayFunction.value === 1 ? startStopModel : disabledModel

ObjectModel {
AllowedItemModel {
id: disabledModel

ListItem {
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsAcSystem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
id: acInput1

Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsAccessAndSecurity.qml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Page {
id: settingsListView

boundsBehavior: Flickable.DragOverBounds
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
//% "Access level"
text: qsTrId("settings_access_level")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsAlarmsAndFeedback.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {
ListSwitch {
//% "Audible alarm"
text: qsTrId("settings_audible_alarm")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsBatteries.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Page {
title: CommonWords.batteries

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
id: batteryMonitorRadioButtons

Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsBatteryMeasurements.qml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Page {

Page {
GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListText {
text: root._visibleText
//% "Active battery monitor"
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsBleSensors.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSwitch {
id: enable
text: CommonWords.enable
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsBluetooth.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Page {

GradientListView {

model: ObjectModel {
model: AllowedItemModel {

ListSwitch {
id: bluetoothEnabled
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsCGwacs.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
text: CommonWords.ac_input_role
optionModel: Global.acInputs.roles.map(function(role) {
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsCanbus.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
//% "CAN-bus profile"
text: qsTrId("settings_canbus_profile")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsConnectivity.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {
ListNavigation {
//% "Ethernet"
text: qsTrId("pagesettingsconnectivity_ethernet")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsDisplayAndAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListSwitch {
id: autoBrightness
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsDisplayMinMax.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Page {
id: root

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSwitch {
//: Whether to adjust the min/max values in the range dynamically, based on the lowest and highest values observed on the system.
//% "Auto-ranging"
Expand Down
4 changes: 2 additions & 2 deletions pages/settings/PageSettingsDisplayStartPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListNavigation {
id: startPageNavigation
//% "Start page"
Expand Down Expand Up @@ -99,7 +99,7 @@ Page {

Page {
GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListSwitch {
id: startPageMode
text: CommonWords.auto
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsDisplayUnits.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
text: CommonWords.temperature
optionModel: [
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsDvcc.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Page {
GradientListView {
id: dvccSettings

model: ObjectModel {
model: AllowedItemModel {
PrimaryListLabel {
//% "<b>CAUTION:</b> Read the manual before adjusting."
text: qsTrId("settings_dvcc_instructions")
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsDynamicEss.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Page {
id: root

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListRadioButtonGroup {
id: dEssMode
text: CommonWords.mode
Expand Down
4 changes: 2 additions & 2 deletions pages/settings/PageSettingsEthernet.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Page {
model: networkServices.ready ? connectedModel : disconnectedModel
}

ObjectModel {
AllowedItemModel {
id: disconnectedModel

ListText {
Expand All @@ -27,7 +27,7 @@ Page {
}
}

ObjectModel {
AllowedItemModel {
id: connectedModel

ListText {
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsFirmware.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListText {
id: remotePort
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsFirmwareOffline.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListFirmwareCheckButton {
//% "Check for updates on SD/USB"
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsFirmwareOnline.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Page {
GradientListView {
id: settingsListView

model: ObjectModel {
model: AllowedItemModel {

ListRadioButtonGroup {
//% "Auto update"
Expand Down
2 changes: 1 addition & 1 deletion pages/settings/PageSettingsFronius.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Page {
}

GradientListView {
model: ObjectModel {
model: AllowedItemModel {
ListNavigation {
//% "Inverters"
text: qsTrId("page_settings_fronius_inverters")
Expand Down
Loading

0 comments on commit d11a187

Please sign in to comment.