From a4ef86609f46c879752880b630f86d484232d168 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 25 Jan 2022 18:48:06 +0100 Subject: [PATCH] Implement option to disable selections Sometimes you don't want the user to be able to highlight certain rows. Contributes to issue CURA-8686. --- plugins/DigitalLibrary/resources/qml/Table.qml | 3 +++ resources/qml/TableView.qml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/DigitalLibrary/resources/qml/Table.qml b/plugins/DigitalLibrary/resources/qml/Table.qml index 7d5750d113..1b12c8ec38 100644 --- a/plugins/DigitalLibrary/resources/qml/Table.qml +++ b/plugins/DigitalLibrary/resources/qml/Table.qml @@ -24,6 +24,7 @@ Item property alias model: tableView.model //A TableModel to display in this table. To use a ListModel for the rows, use "rows: listModel.items" property int currentRow: -1 //The selected row index. property var onDoubleClicked: function(row) {} //Something to execute when double clicked. Accepts one argument: The index of the row that was clicked on. + property bool allowSelection: true //Whether to allow the user to select items. Row { @@ -134,6 +135,8 @@ Item MouseArea { anchors.fill: parent + + enabled: tableScrollView.allowSelection onClicked: { tableScrollView.currentRow = row; //Select this row. diff --git a/resources/qml/TableView.qml b/resources/qml/TableView.qml index 7d5750d113..1b12c8ec38 100644 --- a/resources/qml/TableView.qml +++ b/resources/qml/TableView.qml @@ -24,6 +24,7 @@ Item property alias model: tableView.model //A TableModel to display in this table. To use a ListModel for the rows, use "rows: listModel.items" property int currentRow: -1 //The selected row index. property var onDoubleClicked: function(row) {} //Something to execute when double clicked. Accepts one argument: The index of the row that was clicked on. + property bool allowSelection: true //Whether to allow the user to select items. Row { @@ -134,6 +135,8 @@ Item MouseArea { anchors.fill: parent + + enabled: tableScrollView.allowSelection onClicked: { tableScrollView.currentRow = row; //Select this row.