experimental gps support
authorFlorian Schweikert <kelvan@logic.at>
Sun, 20 Nov 2011 01:13:55 +0000 (02:13 +0100)
committerFlorian Schweikert <kelvan@logic.at>
Sun, 20 Nov 2011 01:13:55 +0000 (02:13 +0100)
gotovienna-qml
qml/ResultRealtime.qml
qml/main.qml

index 45269ca..81ad9c1 100755 (executable)
@@ -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):
index fafc85d..60b2d76 100644 (file)
@@ -137,6 +137,8 @@ Item {
             smooth: true
 
             Text {
+                id: header
+
                 anchors {
                     top: parent.top
                     left: parent.left
index 5236447..11965e3 100644 (file)
@@ -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)
                 }
             }
         }