From 5a2e406b30f899f35fc447517617845001101a95 Mon Sep 17 00:00:00 2001 From: Florian Schweikert Date: Sun, 20 Nov 2011 02:13:55 +0100 Subject: [PATCH] experimental gps support --- gotovienna-qml | 51 ++++++++++++++++++++++++++++++++++++++---------- qml/ResultRealtime.qml | 2 ++ qml/main.qml | 5 +++-- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/gotovienna-qml b/gotovienna-qml index 45269ca..81ad9c1 100755 --- a/gotovienna-qml +++ b/gotovienna-qml @@ -92,22 +92,53 @@ class Gui(QObject): threading.Thread(target=load_async).start() + def map_departure(self, dep): + dep['lowfloor'] = 1 if dep['lowfloor'] else 0 + if type(dep['time']) == time: + dep['time'] = dep['time'].strftime('%H:%M') + return dep + departuresLoaded = Signal() @Slot(str) def load_departures(self, url): def load_async(): - def map_departure(dep): - dep['lowfloor'] = 1 if dep['lowfloor'] else 0 - if type(dep['time']) == time: - dep['time'] = dep['time'].strftime('%H:%M') - return dep - - self.current_departures = map(map_departure, self.itip.get_departures(url)) + self.current_departures = map(self.map_departure, self.itip.get_departures(url)) print self.current_departures self.departuresLoaded.emit() threading.Thread(target=load_async).start() + + @Slot(str) + def load_station_departures(self, station): + def load_async(): + self.current_departures = map(self.map_departure, self.itip.get_departures_by_station(station)) + print self.current_departures + self.departuresLoaded.emit() + + threading.Thread(target=load_async).start() + + @Slot(float, float) + def load_nearby_departures(self, lat, lon): + def load_async(): + self.current_departures = [] + try: + stations = get_nearby_stations(lat, lon) + print stations + for station in stations: + print station + try: + self.current_departures += map(self.map_departure, self.itip.get_departures_by_station(station)) + except Exception as e: + print e.message + print self.current_departures + except Exception as e: + print e.message + + print 'loaded' + self.departuresLoaded.emit() + + threading.Thread(target=load_async).start() @Slot(str, str, str, result=str) def get_directions_url(self, line, direction, station): @@ -121,13 +152,13 @@ class Gui(QObject): def get_departures(self): return self.current_departures - @Slot(float, float, result=str) + @Slot(float, float, result='QStringList') def get_nearby_stations(self, lat, lon): try: - return ', '.join(get_nearby_stations(lat, lon)) + return get_nearby_stations(lat, lon) except Exception as e: print e.message - return '' + return [] @Slot(str, str) def search(self, line, station): diff --git a/qml/ResultRealtime.qml b/qml/ResultRealtime.qml index fafc85d..60b2d76 100644 --- a/qml/ResultRealtime.qml +++ b/qml/ResultRealtime.qml @@ -137,6 +137,8 @@ Item { smooth: true Text { + id: header + anchors { top: parent.top left: parent.left diff --git a/qml/main.qml b/qml/main.qml index 5236447..11965e3 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -53,8 +53,9 @@ PageStackWindow { MouseArea { anchors.fill: parent onClicked: { - console.debug(itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude)) - debugText.text = itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) + //console.debug(itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude)) + //debugText.text = itip.get_nearby_stations(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) + itip.load_nearby_departures(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude) } } } -- 1.7.9.5