Added experimental LineSheet to replace lineSelector
authorFlorian Schweikert <kelvan@logic.at>
Mon, 17 Oct 2011 18:18:16 +0000 (20:18 +0200)
committerFlorian Schweikert <kelvan@logic.at>
Mon, 17 Oct 2011 18:18:16 +0000 (20:18 +0200)
qml/LineSheet.qml [new file with mode: 0644]
qml/MainPage.qml

diff --git a/qml/LineSheet.qml b/qml/LineSheet.qml
new file mode 100644 (file)
index 0000000..025cf4c
--- /dev/null
@@ -0,0 +1,160 @@
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import com.nokia.extras 1.0
+
+import "UIConstants.js" as UIConstants
+import "ExtrasConstants.js" as ExtrasConstants
+
+Sheet {
+    id: lineSheet
+    property string currentSection: ''
+    property string currentLine: ''
+
+    acceptButtonText: 'Select'
+    rejectButtonText: 'Cancel'
+
+    function loadData() {
+        var lines = itip.get_lines()
+
+        for (var i in lines) {
+            lineSelectorModel.append({'name': lines[i]})
+        }
+        lineSheet.currentSection = sectionName
+
+        sectionChooserBusyIndicator.running = true
+
+        underground.clicked()
+        sectionChooser.checkedButton = underground
+    }
+
+    Connections {
+        target: itip
+
+        onLinesLoaded: {
+            sectionChooserBusyIndicator.running = false
+
+            underground.clicked()
+            sectionChooser.checkedButton = underground
+        }
+    }
+
+    content: Item {
+        anchors.fill: parent
+
+        ButtonRow {
+            id: sectionChooser
+            property string section1
+            property string section2
+            property string section3
+            property string section4
+
+            visible: !sectionChooserBusyIndicator.running
+
+            function chosen(idx) {
+                console.log('section chosen: '+ idx)
+
+                lineSelectorListView.selectedIndex = -1
+
+                if (idx == 1) {
+                    lineSheet.currentSection = sectionChooser.section1
+                } else if (idx == 2) {
+                    lineSheet.currentSection = sectionChooser.section2
+                } else if (idx == 2) {
+                    lineSheet.currentSection = sectionChooser.section3
+                } else {
+                    lineSheet.currentSection = sectionChooser.section4
+                }
+                console.log(lineSheet.currentSection)
+
+                sectionChooserModel.clear()
+                var lines = itip.get_lines()
+
+                for (var i in lines) {
+                    lineSelectorModel.append({'name': lines[i]})
+                }
+            }
+
+            anchors {
+                margins: 10
+                top: parent.top
+                left: parent.left
+                right: parent.right
+            }
+
+                Button {
+                    id: underground
+                    text: 'U-Bahn'
+                    onClicked: sectionChooser.chosen(1)
+                }
+
+                Button {
+                    id: tram
+                    text: 'Straßenbahn'
+                    onClicked: sectionChooser.chosen(2)
+                }
+
+                Button {
+                    id: bus
+                    text: 'Autobus'
+                    onClicked: sectionChooser.chosen(3)
+                }
+
+                Button {
+                    id: nightline
+                    text: 'Nightline'
+                    onClicked: sectionChooser.chosen(4)
+                }
+
+        }
+
+        ListView {
+            id: lineSelectorListView
+            visible: !sectionChooserBusyIndicator.running
+
+            property int selectedIndex: -1
+            onSelectedIndexChanged: {
+                console.log('current index: ' + selectedIndex)
+                if (selectedIndex != -1) {
+                    lineSheet.currentLine = sectionChooserModel.get(selectedIndex).station
+                } else {
+                    lineSheet.currentLine = ''
+                }
+            }
+
+            anchors {
+                margins: 10
+                top: sectionChooserModel.bottom
+                left: parent.left
+                right: parent.right
+                bottom: parent.bottom
+            }
+
+            clip: true
+
+            model: ListModel {
+                id: sectionChooserModel
+            }
+
+            delegate: SheetListItem { selector: lineSelectorListView }
+        }
+
+        ScrollDecorator {
+            flickableItem: lineSelectorListView
+        }
+
+        BusyIndicator {
+            id: sectionChooserBusyIndicator
+            anchors.centerIn: parent
+            visible: running
+            platformStyle: BusyIndicatorStyle { size: 'large' }
+        }
+    }
+
+    onAccepted: {
+        gstation.text = stationSheet.currentStation
+
+        realtimeResult.gline = stationSheet.currentLine
+
+        realtimeResult.sourceUrl = itip.get_directions_url(lineSheet.currentLine, lineSheet.currentSection, lineSheet.currentStation)
+    }
+}
index 3c3a035..e989fe4 100644 (file)
@@ -75,6 +75,10 @@ Page {
          }
     }
 
+    LineSheet {
+        id: lineSheet
+    }
+
     Button {
         id: lineSearchButton