From 895ac570464516049e1a1fdb4741c8e164d16034 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Wed, 15 Feb 2023 22:27:57 +0100 Subject: [PATCH] Add settings for device type registers --- DeviceTypesSettingsPage.qml | 69 +++++++++++++++++++++++++++++-------- DevicesSettingsPage.qml | 3 +- EditableListView.qml | 4 ++- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/DeviceTypesSettingsPage.qml b/DeviceTypesSettingsPage.qml index c4f8183..65c3341 100644 --- a/DeviceTypesSettingsPage.qml +++ b/DeviceTypesSettingsPage.qml @@ -14,7 +14,7 @@ ColumnLayout { Layout.fillHeight: true EditableListView { - id: listView + id: deviceTypesListView Layout.preferredWidth: 300 Layout.maximumWidth: 300 @@ -27,39 +27,80 @@ ColumnLayout { } ColumnLayout { - enabled: listView.currentIndex !== -1 + enabled: deviceTypesListView.currentIndex !== -1 GridLayout { - Layout.preferredWidth: 300 - Layout.maximumWidth: 300 + Layout.preferredWidth: 600 + Layout.maximumWidth: 600 columns: 2 Label { text: qsTr("Id:") } SpinBox { + enabled: false Layout.fillWidth: true - value: listView.currentData.id - onValueModified: listView.currentData.id = value + value: deviceTypesListView.currentData.id + onValueModified: deviceTypesListView.currentData.id = value } Label { text: qsTr("Name:") } TextField { Layout.fillWidth: true - text: listView.currentData.name - onTextEdited: listView.currentData.name = text + text: deviceTypesListView.currentData.name + onTextEdited: deviceTypesListView.currentData.name = text } Label { text: qsTr("Registers:") } Pane { Layout.fillWidth: true Layout.fillHeight: true - EditableListView { - textRole: 'registerTypeName' - model: DeviceTypeRegistersModel { - controller: __controller - deviceTypeId: listView.currentData.id + Material.elevation: 6 + + RowLayout { + anchors.fill: parent + + Pane { + Layout.preferredWidth: 300 + Layout.fillHeight: true + + Material.elevation: 6 + + EditableListView { + id: deviceTypesRegistersListView + anchors.fill: parent + + textRole: 'registerTypeName' + + model: DeviceTypeRegistersModel { + controller: __controller + deviceTypeId: deviceTypesListView.currentData.id + } + } } - anchors.fill: parent + ColumnLayout { + Layout.fillWidth: true + Layout.fillHeight: true + + enabled: deviceTypesRegistersListView.currentIndex >= 0 + + GridLayout { + Layout.fillWidth: true + + columns: 2 + + Label { + text: qsTr('Type:') + } + ComboBox { + + } + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } + } } } } diff --git a/DevicesSettingsPage.qml b/DevicesSettingsPage.qml index 6c79cbc..8f51802 100644 --- a/DevicesSettingsPage.qml +++ b/DevicesSettingsPage.qml @@ -23,7 +23,7 @@ ColumnLayout { onAddClicked: (index) => devicesModel.insertRow(index < 0 ? 0 : index + 1); onRemoveClicked: (index) => devicesModel.removeRow(index) - onCurrentDataChanged: test.value = currentData.position + onCurrentDataChanged: if (currentData) test.value = currentData.position } ColumnLayout { @@ -37,6 +37,7 @@ ColumnLayout { Label { text: qsTr("Id:") } SpinBox { + enabled: false Layout.fillWidth: true value: listView.currentData.id onValueModified: listView.currentData.id = value diff --git a/EditableListView.qml b/EditableListView.qml index f85d563..60e9858 100644 --- a/EditableListView.qml +++ b/EditableListView.qml @@ -27,7 +27,7 @@ ColumnLayout { } Button { - text: qsTr("Remove") + text: qsTr("Remove ") + listView.currentIndex onClicked: removeClicked(listView.currentIndex) enabled: listView.currentIndex >= 0 @@ -42,6 +42,8 @@ ColumnLayout { clip: true + onCountChanged: if (count === 0 && currentIndex >= 0) currentIndex = -1 + delegate: Item { property variant myData: model readonly property bool isCurrentItem: ListView.isCurrentItem