version changed
[pywienerlinien] / gotovienna-qml
index d0ba500..57cccb6 100755 (executable)
@@ -3,13 +3,17 @@
 """Public transport information for Vienna"""
 
 __author__ = 'kelvan <kelvan@logic.at>'
-__version__ = '1.0'
+__version__ = '0.8.1'
 __website__ = 'https://github.com/kelvan/gotoVienna/'
 __license__ = 'GNU General Public License v3 or later'
 
-from PySide.QtCore import *
-from PySide.QtGui import *
-from PySide.QtDeclarative import *
+from datetime import datetime
+
+t = datetime.now()
+
+from PySide.QtCore import QAbstractListModel, QModelIndex, QObject, Slot, Signal
+from PySide.QtGui import QApplication
+from PySide.QtDeclarative import QDeclarativeView
 
 from gotovienna.utils import *
 from gotovienna.realtime import *
@@ -58,6 +62,7 @@ class Gui(QObject):
 
         self.current_line = ''
         self.current_stations = []
+        self.current_departures = []
 
     @Slot(int, result=str)
     def get_direction(self, idx):
@@ -87,10 +92,30 @@ class Gui(QObject):
 
         threading.Thread(target=load_async).start()
 
+    departuresLoaded = Signal()
+
+    @Slot(str)
+    def load_departures(self, url):
+        def load_async():
+            self.current_departures = [x['ftime'] for x in
+                    self.itip.get_departures(url)]
+            print self.current_departures
+            self.departuresLoaded.emit()
+
+        threading.Thread(target=load_async).start()
+
+    @Slot(str, str, str, result=str)
+    def get_directions_url(self, line, direction, station):
+        return self.itip.get_url_from_direction(line, direction, station)
+
     @Slot(result='QStringList')
     def get_lines(self):
         return self.lines
 
+    @Slot(result='QStringList')
+    def get_departures(self):
+        return self.current_departures
+
     @Slot(str, str)
     def search(self, line, station):
         line = line.upper()
@@ -132,6 +157,8 @@ if __name__ == '__main__':
         # Assume test from source directory, use relative path
         view.setSource(os.path.join(os.path.dirname(__file__), 'qml/main.qml'))
 
+    print datetime.now() - t
+
     view.showFullScreen()
 
     sys.exit(app.exec_())