Use Binding to select sorting mode instead of JavaScript code
authorLuciano Montanaro <mikelima@cirulla.net>
Sat, 30 Jul 2011 17:29:59 +0000 (19:29 +0200)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 27 Dec 2011 22:16:47 +0000 (23:16 +0100)
application/resources/harmattan/qml/StationListPage.qml

index c0bf165..e45f3f1 100644 (file)
@@ -47,6 +47,7 @@ Page {
         id: header
         anchors.top: parent.top
         text: qsTr("Stations")
+        selectedIndex: stationListProxyModel.sortingMode
         options: ListModel {
             id: dialogOptions
             ListElement {
@@ -61,17 +62,8 @@ Page {
         }
         onSelectedIndexChanged: {
             header.text = dialogOptions.get(selectedIndex).name
-            switch (selectedIndex) {
-            case 0:
-                stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
-                break;
-            case 1:
-                stationListProxyModel.sortingMode = StationListProxyModel.DistanceSorting
-                break;
-            case 2:
-                stationListProxyModel.sortingMode = StationListProxyModel.RecentUsageSorting
-                break;
-            }
+            console.log("Selection changed to: " + selectedIndex)
+            console.log("Selection text is: " + header.text)
         }
     }
     SearchBar {
@@ -83,6 +75,11 @@ Page {
         property: "searchPattern"
         value: searchField.text
     }
+    Binding {
+        target: stationListProxyModel
+        property: "sortingMode"
+        value: header.selectedIndex
+    }
     Rectangle {
         id: shadow
         width: parent.width