[vlc-devel] [PATCH 08/22] qml: add a helper method to clear the selection in SelectableDelegateModel

Pierre Lamot pierre at videolabs.io
Fri Feb 14 11:23:43 CET 2020


---
 .../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
         }
-- 
2.17.1



More information about the vlc-devel mailing list