[vlc-commits] qml: add a helper method to clear the selection in SelectableDelegateModel
Pierre Lamot
git at videolan.org
Fri Feb 14 11:59:56 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Jan 29 12:55:35 2020 +0100| [2e4267681c1ed911cf338bdd52dbc7463e38c114] | committer: Jean-Baptiste Kempf
qml: add a helper method to clear the selection in SelectableDelegateModel
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e4267681c1ed911cf338bdd52dbc7463e38c114
---
.../gui/qt/util/qml/SelectableDelegateModel.qml | 23 +++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/modules/gui/qt/util/qml/SelectableDelegateModel.qml b/modules/gui/qt/util/qml/SelectableDelegateModel.qml
index 5910f99278..445d278a56 100644
--- a/modules/gui/qt/util/qml/SelectableDelegateModel.qml
+++ b/modules/gui/qt/util/qml/SelectableDelegateModel.qml
@@ -39,6 +39,11 @@ DelegateModel {
}
}
+ function selectNone() {
+ if (selectedGroup.count > 0)
+ selectedGroup.remove(0,selectedGroup.count)
+ }
+
function selectAll() {
delegateModel.items.addGroups(0, delegateModel.items.count, ["selected"])
}
@@ -66,22 +71,12 @@ DelegateModel {
_delRange(oldIndex, newIndex - 1)
}
} else {
-
var e = delegateModel.items.get(newIndex)
- if (e.inSelected) {
- if ((keymodifiers & Qt.ControlModifier) == Qt.ControlModifier) {
- e.inSelected = false
- } else {
- selectedGroup.remove(0,selectedGroup.count) //clear
- }
+ if ((keymodifiers & Qt.ControlModifier) == Qt.ControlModifier) {
+ e.inSelected = !e.inSelected
} else {
- if ((keymodifiers & Qt.ControlModifier) == Qt.ControlModifier) {
- e.inSelected = true
- } else {
- if (selectedGroup.count > 0)
- selectedGroup.remove(0,selectedGroup.count) //clear
- e.inSelected = true
- }
+ selectNone()
+ e.inSelected = true
}
shiftIndex = newIndex
}
More information about the vlc-commits
mailing list