X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=qml%2FMainPage.qml;h=a14e48db09c9161f201f0aa1dadfeecf2474d1fc;hb=e069deef85dd16cf7070b5f1d7272a867a2a7fb3;hp=25cfbd9bfc1263177e5b4a5de56a9c7ce2852af9;hpb=23d46d6fa1ca0c145cd04ce4fe2c169b45d02964;p=pywienerlinien diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 25cfbd9..a14e48d 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -1,19 +1,64 @@ import QtQuick 1.1 import com.nokia.meego 1.0 +import QtMobility.location 1.1 + import "UIConstants.js" as UIConstants import "ExtrasConstants.js" as ExtrasConstants Page { tools: commonTools - Image { - id: logo - source: 'logo.png' + property bool canRefresh: realtimeResult.sourceUrl != '' || (realtimeResult.isStation && realtimeResult.gstation != '') + //property alias stationSelect: stationSelector + property variant nearbyStations - anchors { - topMargin: 25 - top: parent.top - horizontalCenter: parent.horizontalCenter + function refresh() { + realtimeResult.refresh() + } + + function fillNearbyStations(lat, lon) { + nearbyStations = itip.get_nearby_stations(lat, lon) + } + + function showNearby() { + console.log("show nearby") + + var stations = nearbyStations + stationSelectorModel.clear() + for (var idx in stations) { + stationSelectorModel.append({'name': stations[idx]}) + } + + stationSelector.open() + } + + PositionSource { + id: positionSource + updateInterval: 10000 + + active: true + + onPositionChanged: { + fillNearbyStations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) + } + } + + SelectionDialog { + id: stationSelector + titleText: 'Select nearby station' + + model: ListModel { + id: stationSelectorModel + } + + onAccepted: { + realtimeResult.isStation = true + realtimeResult.gstation = stationSelectorModel.get(selectedIndex).name + realtimeResult.gline = '' + realtimeResult.sourceUrl = '' + gline.text = '' + gstation.text = stationSelectorModel.get(selectedIndex).name + console.log('station to get: ' + realtimeResult.gstation) } } @@ -22,13 +67,17 @@ Page { id: gline anchors { - top: logo.bottom + top: parent.top left: parent.left topMargin: 20 leftMargin: 10 rightMargin: 10 + right: lineSearchButton.left + } + + onTextChanged: { + gstation.text = '' } - width: parent.width - 20 MouseArea { anchors.fill: parent @@ -39,36 +88,95 @@ Page { } } + LineSheet { + id: lineSheet + onAccepted: { + gline.text = currentLine + + /* We usually want to select a station after selecting a line */ + stationPickerButton.clicked() + } + } + + Button { + id: lineSearchButton + + anchors { + top: gline.top + bottom: gline.bottom + right: parent.right + rightMargin: 10 + } + + width: 60 + iconSource: 'image://theme/icon-m-common-search' + + onClicked: { + lineSheet.currentLine = '' + lineSheet.open() + } + } + TextField { placeholderText: 'Station' id: gstation + anchors { top: gline.bottom left: parent.left - right: parent.right + right: stationPickerButton.left topMargin: 10 leftMargin: 10 - rightMargin: 10 + rightMargin: 10*stationPickerButton.opacity } } - ResultRealtime { id: resu } + StationSheet { + id: stationSheet + } Button { - id: btnSearch - text: 'Search' + id: stationPickerButton + anchors { - top: gstation.bottom - topMargin: 10 - horizontalCenter: parent.horizontalCenter + top: gstation.top + bottom: gstation.bottom + right: parent.right + rightMargin: 10 } + + Behavior on opacity { PropertyAnimation { } } + + opacity: gline.text !== '' // XXX: Check if the line is valid + + width: lineSearchButton.width * opacity + //iconSource: 'image://theme/icon-m-common-location-picker' + iconSource: 'image://theme/icon-m-toolbar-list' + onClicked: { - resu.gline = gline.text - resu.gstation = gstation.text - pageStack.push(resu) - itip.search(gline.text, gstation.text) - resu.busy = false + stationSheet.open() + stationSheet.loadData(gline.text) } } + + ResultRealtime { + id: realtimeResult + + anchors { + margins: 10 + top: gstation.bottom + left: parent.left + bottom: parent.bottom + right: parent.right + } + + clip: true + + gline: stationSheet.currentLine + gstation: stationSheet.currentStation + gdirection: stationSheet.currentDirection + + sourceUrl: stationSheet.currentUrl + } }