Adaptations for StationScheduleModel class
authorLuciano Montanaro <mikelima@cirulla.net>
Tue, 8 Nov 2011 15:05:35 +0000 (16:05 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 27 Dec 2011 22:19:10 +0000 (23:19 +0100)
application/resources/harmattan/qml/StationListPage.js
application/resources/harmattan/qml/StationPage.qml
application/stationschedulemodel.cpp

index 300d9e0..fb630d2 100644 (file)
@@ -18,7 +18,6 @@ function loadStation(name)
         view = component.createObject(stationListPage)
         stationListPage.stationView = view
         pageStack.push(view)
-        view.html = "<h1>Loading station " + name + "</h1><p>Lorem ipsum</p>"
         view.name = name
     }
     else
index ebc9b5f..2916622 100644 (file)
@@ -6,8 +6,6 @@ import "uiconstants.js" as UiConstants
 
 Page {
     property alias name: schedule.name
-    property alias html: webView.html
-    property alias url: webView.url
     anchors.fill: parent
 
     tools: ToolBarLayout {
@@ -60,22 +58,49 @@ Page {
         }
         width: parent.width
 
-        WebView {
-            id: webView
-            visible: false
-            anchors.fill: parent
+        ListView {
+            id: stationScheduleView
+            clip: true
+            width: parent.width
+            height: parent.height
+            model:  schedule
+            delegate: Item {
+                id: listItem
+                height: 48
+                width: parent.width
+                BorderImage {
+                    id: background
+                    anchors.fill: parent
+                    // Fill page borders
+                    visible: mouseArea.pressed
+                    source: "image://theme/meegotouch-list-background-pressed-center"
+                }
+                Row {
+                    anchors.fill: parent
 
-            settings.defaultFontSize: labelStyle.fontPixelSize
-            settings.defaultFixedFontSize: labelStyle.fontPixelSize
-            settings.standardFontFamily: labelStyle.fontFamily
+                    Column {
+                        anchors.verticalCenter: parent.verticalCenter
+
+                        Label {
+                            id: mainText
+                            text: Private.highlightSearch(model.display, UiConstants.AccentColor)
+                            font.bold: true
+                        }
+                    }
+                }
+                MouseArea {
+                    id: mouseArea
+                    anchors.fill: background
+                    onClicked: {
+                        // Load an external page about the train, for now
+                    }
+                }
+            }
         }
     }
 
     StationScheduleModel {
         id: schedule
-    }
-
-    Component.onCompleted: {
-        schedule.fetch(name)
+        onNameChanged: schedule.fetch(name)
     }
  }
index 314a19a..b39ebf6 100644 (file)
@@ -30,6 +30,10 @@ StationScheduleModel::StationScheduleModel(const QString &name, QObject *parent)
     m_name(name)
 
 {
+    DataProvider *provider = DataProvider::instance();
+
+    connect(provider, SIGNAL(stationScheduleReady(QByteArray,QUrl)),
+            this, SLOT(parse(QByteArray,QUrl)));
 }
 
 QString & StationScheduleModel::name()
@@ -39,15 +43,17 @@ QString & StationScheduleModel::name()
 
 void StationScheduleModel::setName(const QString &name)
 {
-    m_name = name;
-    emit nameChanged();
+    if (name != m_name) {
+        m_name = name;
+        emit nameChanged();
+    }
 }
 
 void StationScheduleModel::parse(const QByteArray &htmlReply, const QUrl &baseUrl)
 {
     Q_UNUSED(baseUrl);
     qDebug() << "--- start of query result --- cut here ------";
-    qDebug() << htmlReply;
+    qDebug() << QString::fromUtf8(htmlReply.constData());
     qDebug() << "--- end of query result ----- cut here ------";
 }
 
@@ -55,8 +61,6 @@ void StationScheduleModel::fetch(const QString &name)
 {
     DataProvider *provider = DataProvider::instance();
 
-    connect(provider, SIGNAL(stationScheduleReady(QByteArray,QUrl)),
-            this, SLOT(parse(QByteArray,QUrl)));
     provider->fetchStationSchedule(name);
     setName(name);
 }