Sailfish port mostly done, bumped version to 6.0
authorLuciano Montanaro <mikelima@cirulla.net>
Wed, 6 Nov 2013 00:05:52 +0000 (01:05 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Wed, 6 Nov 2013 00:05:52 +0000 (01:05 +0100)
application/application.pro
application/main.cpp
application/resources/sailfish/qml/pages/StationListPage.js
application/resources/sailfish/qml/pages/StationListPage.qml
application/stationlistproxymodel.cpp
application/stationscheduleitem.cpp
application/stationscheduleitem.h
application/stationschedulemodel.cpp

index b3d2db7..a89d325 100755 (executable)
@@ -4,12 +4,12 @@
 #
 #-------------------------------------------------
 
-VERSION = 0.5.1
+VERSION = 0.6.0
 USE_RESOURCES = 0
 
 QT += network
 CONFIG += qt
-#CONFIG += link_pkgconfig
+CONFIG += link_pkgconfig
 
 lessThan(QT_MAJOR_VERSION, 5) {
     QT += webkit
@@ -132,8 +132,11 @@ QMLSOURCES = \
     resources/harmattan/qml/DelayIndicator.qml \
     resources/harmattan/qml/StationScheduleDelegate.qml \
     resources/sailfish/qml/main.qml \
+    resources/sailfish/qml/pages/AboutPage.qml \
     resources/sailfish/qml/pages/StationListPage.qml \
-    resources/sailfish/qml/pages/StationPage.qml
+    resources/sailfish/qml/pages/StationPage.qml \
+    resources/sailfish/qml/pages/components/DelayIndicator.qml \
+    resources/sailfish/qml/pages/components/StationScheduleDelegate.qml
 
 OTHER_FILES += \
     resources/sailfish/applications/quandoparte.desktop \
@@ -250,6 +253,7 @@ harmattan {
         qml.files = resources/sailfish/qml/*.qml \
                     resources/sailfish/qml/*.js \
                     resources/sailfish/qml/pages \
+                    resources/sailfish/qml/pages/components \
                     resources/sailfish/qml/cover
         qml.path = $$DATADIR/qml
         INSTALLS += qml
index 16eb301..484529b 100644 (file)
@@ -27,7 +27,7 @@ Boston, MA 02110-1301, USA.
 
 #include <QtGlobal>
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
-#include <QtGui/QGuiApplication>
+#include <QtWidgets/QApplication>
 #else
 #include <QtGui/QApplication>
 #endif
@@ -47,7 +47,7 @@ Boston, MA 02110-1301, USA.
 Q_DECL_EXPORT int main(int argc, char *argv[])
 {
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
-    QScopedPointer< QGuiApplication > a(new QGuiApplication(argc, argv));
+    QScopedPointer< QApplication > a(new QApplication(argc, argv));
 #elif TARGET_PLATFORM_HARMATTAN
     QScopedPointer< QApplication > a(MDeclarativeCache::qApplication(argc, argv));
 #else
index 858b36e..7a06bc2 100644 (file)
@@ -35,11 +35,16 @@ function highlightSearch(s, color)
 {
     // TODO compile RegExp on change, or find a way to cleanly use
     // stationListProxyModel.filterRegExp
-    if (searchField.text.length) {
-        var r = new RegExp(searchField.text, 'i')
+    if (searchPattern.length) {
+        var r = new RegExp(searchPattern, 'i')
         var match = r.exec(s)
-        return s.replace(r, '<span style="text-decoration:underline;color:' + color + ';">' +
-                         match + '</span>')
+       console.log('s is ' + s);
+       if (match) {
+               return s.replace(r, '<font color="' + color + '">' +
+                               match + '</font>')
+       } else {
+               return s
+       }
     } else {
         return s
     }
index 7d6deca..f65f57d 100644 (file)
@@ -4,101 +4,68 @@ import net.cirulla.quandoparte 1.0
 import "StationListPage.js" as Private
 
 Page {
-    property variant stationView
     id: stationListPage
+    property variant stationView
+    property string searchPattern
     Binding {
         target: stationListProxyModel
         property: "searchPattern"
-        value: searchField.text
-    }
-    Binding {
-        target: stationListProxyModel
-        property: "sortingMode"
-        value: header.currentIndex
-    }
-    Binding {
-        target: stationListView
-        property: "section.property"
-        value: header.currentIndex === 0 ? "name" : ""
+        value: stationListPage.searchPattern
     }
     SilicaListView {
         id: stationListView
         clip: true
         width: parent.width
         cacheBuffer: 10
-        anchors.fill: parent
+        anchors.top: parent.top
+        anchors.bottom: parent.bottom
         model:  stationListProxyModel
-        header: Column {
-            ComboBox {
-                id: header
-                currentIndex: stationListProxyModel.sortingMode
-                menu: ContextMenu {
-                    MenuItem {
-                        text: qsTr("by Name")
-                    }
-                    MenuItem {
-                        text: qsTr("by Distance")
-                    }
-                    MenuItem {
-                        text: qsTr("Recently Seen")
-                    }
-                }
-                label: qsTr("Stations")
+        PullDownMenu {
+            MenuItem {
+                text: qsTr("About Quando Parte")
+                onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
+            }
+            MenuItem {
+                text: qsTr("Stations by Name")
+                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.AlphaSorting
+            }
+            MenuItem {
+                text: qsTr("Stations by Distance")
+                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.DistanceSorting
             }
-            SearchField {
-                id: searchField
-                placeholderText: qsTr("Search station...")
+            MenuItem {
+                text: qsTr("Stations Recently Seen")
+                onClicked: stationListProxyModel.sortingMode = StationListProxyModel.RecentUsageSorting
             }
         }
+        header: SearchField {
+            id: searchField
+            placeholderText: qsTr("Search station...")
+            onTextChanged: stationListPage.searchPattern = searchField.text
+            width: stationListPage.width
+        }
+        delegate: BackgroundItem {
+            id: listItem
+            height: Theme.itemSizeSmall
+            width: parent.width
+            Label {
+                id: mainText
+                x: Theme.paddingLarge
+                textFormat: Text.StyledText
+                text: model.name ? Private.highlightSearch(model.name, Theme.highlightColor) : ""
+            }
+            onClicked: Private.loadStation(model.name, model.code)
+        }
         section {
             criteria: ViewSection.FirstCharacter
-            delegate: Item {
-                width: parent.width
-                height: Theme.itemSizeSmall
-                anchors {
-                    margins: Theme.paddingMedium
-                }
-               Image {
-                   anchors {
-                       left: parent.left
-                       right: sectionLabel.left
-                       verticalCenter: parent.verticalCenter
-                       margins: Theme.paddingMedium
-                   }
-                   source: "image://theme/meegotouch-separator-" + (theme.inverted ? "inverted-" : "") + "background-horizontal"
-               }
-               Label {
-                   id: sectionLabel
-                   anchors {
-                       right: sectionRightMargin.left
-                       verticalCenter: parent.verticalCenter
-                   }
-                   text: section
-               }
-                Item {
-                    id: sectionRightMargin
-                    anchors {
-                        right: parent.right
-                    }
-                    width: Theme.paddingMedium
-                    height: Theme.paddingMedium
-                }
-            }
             delegate: BackgroundItem {
-                id: listItem
                 height: Theme.itemSizeSmall
                 width: parent.width
                 Label {
-                    id: mainText
-                    x: Theme.paddingLarge
-                    text: Private.highlightSearch(model.name, Theme.highlightColor)
+                    id: sectionLabel
+                    text: section
                 }
-                onClicked: Private.loadStation(model.name, model.code)
             }
         }
     }
-    ScrollDecorator {
-        id: decorator
-        flickable: stationListView
-    }
 }
index 44ad3b5..919f17a 100644 (file)
@@ -167,11 +167,13 @@ void StationListProxyModel::forceSortingMode(SortingMode mode)
         break;
     }
     if (mode == StationListProxyModel::DistanceSorting) {
-        positionInfoSource->startUpdates();
+        if (positionInfoSource) {
+            positionInfoSource->startUpdates();
+        }
     } else {
-#if 0
-        positionInfoSource->stopUpdates();
-#endif
+        if (positionInfoSource) {
+            positionInfoSource->stopUpdates();
+        }
     }
     invalidate();
     sort(0);
index 244cbb7..af4d997 100644 (file)
@@ -131,7 +131,7 @@ int StationScheduleItem::delayClass()
     return d->delayClass;
 }
 
-void StationScheduleItem::setDelayClass(const int value)
+void StationScheduleItem::setDelayClass(int value)
 {
     d->delayClass = value;
 }
index 8205318..156438f 100644 (file)
@@ -56,7 +56,7 @@ public:
     void setDelay(const QString &value);
 
     int delayClass();
-    void setDelayClass(const int value);
+    void setDelayClass(int value);
 
     QString &expectedPlatform();
     void setExpectedPlatform(const QString &value);
index 96b1f4c..c3fb03d 100644 (file)
@@ -220,7 +220,6 @@ void StationScheduleModel::parse(const QByteArray &htmlReply, const QUrl &baseUr
 
     emit layoutAboutToBeChanged();
     beginResetModel();
-#if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0))
     QWebPage page;
     page.mainFrame()->setContent(htmlReply, "text/html", baseUrl);
     QWebElement doc = page.mainFrame()->documentElement();
@@ -280,7 +279,6 @@ void StationScheduleModel::parse(const QByteArray &htmlReply, const QUrl &baseUr
         if (current.isNull())
             break;
     }
-#endif
     endResetModel();
     emit layoutChanged();
 }