Added Header combo-box
authorLuciano Montanaro <mikelima@cirulla.net>
Sat, 23 Jul 2011 17:32:16 +0000 (19:32 +0200)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 27 Dec 2011 22:16:47 +0000 (23:16 +0100)
application/resources/harmattan/qml/PageHeader.qml
application/resources/harmattan/qml/StationListPage.qml

index 1e9bb8d..cf6fe74 100644 (file)
@@ -1,11 +1,62 @@
 import QtQuick 1.0
 import com.nokia.meego 1.0
+import com.nokia.extras 1.0
 import "uiconstants.js" as UiConstants
 
 Rectangle {
+    property alias text: label.text
+    property alias options: dialog.model
+    property alias selectedIndex: dialog.selectedIndex
+
+    id: root
     width: parent.width
     height: screen.currentOrientation == Screen.Landscape ?
                 UiConstants.HeaderDefaultHeightLandscape :
-                UiConstants.HeaderDefaultHeightPortrait
-    color: "#071"
+    UiConstants.HeaderDefaultHeightPortrait
+    color: mouse.pressed ? "#060" : "#071"
+
+    TumblerButtonStyle {
+        id: style
+        inverted: true
+    }
+    Item {
+        id: spacer
+        anchors.left: parent.left
+        width: UiConstants.DefaultMargins
+        height: parent.heigth
+    }
+    Label {
+        id: label
+        anchors.left: spacer.right
+        anchors.verticalCenter: parent.verticalCenter
+        font {
+            pixelSize: UiConstants.HeaderFontPixelSize
+            bold: false
+        }
+        color: style.textColor
+    }
+    MouseArea {
+        id: mouse
+        anchors.fill: parent
+        onClicked: dialog.open()
+    }
+
+    Image {
+        id: icon
+
+        anchors { right: (label.text != "") ? parent.right : undefined;
+            rightMargin: UiConstants.DefaultMargins;
+            horizontalCenter: (label.text != "") ? undefined : parent.horizontalCenter;
+            verticalCenter: parent.verticalCenter;
+        }
+        height: label.height
+        source: "image://theme/meegotouch-combobox-indicator" +
+                (style.inverted ? "-inverted" : "") +
+                (root.enabled ? "" : "-disabled") +
+                (mouse.pressed ? "-pressed" : "")
+    }
+    SelectionDialog {
+        id: dialog
+        titleText: qsTr("Show")
+    }
 }
index 57cb63e..142f021 100644 (file)
@@ -46,6 +46,33 @@ Page {
     PageHeader {
         id: header
         anchors.top: parent.top
+        text: qsTr("Stations")
+        options: ListModel {
+            id: dialogOptions
+            ListElement {
+                name: QT_TR_NOOP("Stations by Name")
+            }
+            ListElement {
+                name: QT_TR_NOOP("Stations by Distance")
+            }
+            ListElement {
+                name: QT_TR_NOOP("Stations Recently Seen")
+            }
+        }
+        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;
+            }
+        }
     }
     SearchBar {
         id: searchField
@@ -106,8 +133,8 @@ Page {
 
     Sheet {
         id: settingsSheet
-        acceptButtonText: "Save"
-        rejectButtonText: "Cancel"
+        acceptButtonText: qsTr("Save")
+        rejectButtonText: qsTr("Cancel")
         content: Item {
             x: 16
             y: 16