Removing device types now asks for confirmation

This commit is contained in:
2023-02-18 21:04:13 +01:00
parent 9d3c42c40c
commit 5493e21f40

View File

@@ -1,4 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material import QtQuick.Controls.Material
import QtQuick.Layouts import QtQuick.Layouts
@@ -21,8 +22,38 @@ ColumnLayout {
model: deviceTypesModel model: deviceTypesModel
onAddClicked: (index) => deviceTypesModel.insertRow(index < 0 ? 0 : index + 1); onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (deviceTypesModel.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
onRemoveClicked: (index) => deviceTypesModel.removeRow(index) onRemoveClicked: (index) => {
const dialog = dialogComponent.createObject(Overlay.overlay);
dialog.index = index;
dialog.open();
}
Component {
id: dialogComponent
Dialog {
property int index
anchors.centerIn: parent
standardButtons: DialogButtonBox.Yes | DialogButtonBox.Cancel
modal: true
title: qsTr('Confirmation')
onAccepted: deviceTypesModel.removeRow(index)
Label {
id: textContainer
anchors.fill: parent
horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignTop
text: qsTr('Are you sure you want to remove row %0').arg(index)
}
}
}
} }
ColumnLayout { ColumnLayout {