[vlc-devel] [PATCH 8/9] qml: add a signal to notify data changes rather than index change in SortControl

Pierre Lamot pierre at videolabs.io
Mon Nov 18 18:15:41 CET 2019


---
 modules/gui/qt/qml/BannerSources.qml     | 7 +++----
 modules/gui/qt/qml/utils/SortControl.qml | 4 ++++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/qml/BannerSources.qml b/modules/gui/qt/qml/BannerSources.qml
index 7e034b96cb..7536db68f0 100644
--- a/modules/gui/qt/qml/BannerSources.qml
+++ b/modules/gui/qt/qml/BannerSources.qml
@@ -217,10 +217,9 @@ Utils.NavigableFocusScope {
                             visible: !!root.contentModel
                             enabled: visible
 
-                            onCurrentIndexChanged: {
-                                if (model !== undefined && contentModel !== undefined) {
-                                    var sorting = model.get(currentIndex);
-                                    contentModel.sortCriteria = sorting.criteria
+                            onSortSelected: {
+                                if (contentModel !== undefined) {
+                                    contentModel.sortCriteria = modelData.criteria
                                 }
                             }
                         }
diff --git a/modules/gui/qt/qml/utils/SortControl.qml b/modules/gui/qt/qml/utils/SortControl.qml
index 091b9ed66f..93b61b88d0 100644
--- a/modules/gui/qt/qml/utils/SortControl.qml
+++ b/modules/gui/qt/qml/utils/SortControl.qml
@@ -34,6 +34,9 @@ Utils.NavigableFocusScope {
     property int popupAlignment: Qt.AlignRight | Qt.AlignBottom
     property int listWidth
     property alias currentIndex: list.currentIndex
+    property alias focusPolicy: button.focusPolicy
+
+    signal sortSelected(var modelData)
 
     onFocusChanged: {
         if (!focus)
@@ -145,6 +148,7 @@ Utils.NavigableFocusScope {
 
                 onClicked: {
                     root.currentIndex = index
+                    root.sortSelected(model)
                     popup.close()
                 }
             }
-- 
2.17.1



More information about the vlc-devel mailing list