From: Luciano Montanaro Date: Wed, 6 Nov 2013 00:05:52 +0000 (+0100) Subject: Sailfish port mostly done, bumped version to 6.0 X-Git-Tag: tags/0.6.0~6 X-Git-Url: https://vcs.maemo.org/git/?p=quandoparte;a=commitdiff_plain;h=487f17f8db0edfa58e33202320974d34043fa062 Sailfish port mostly done, bumped version to 6.0 --- diff --git a/application/application.pro b/application/application.pro index b3d2db7..a89d325 100755 --- a/application/application.pro +++ b/application/application.pro @@ -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 diff --git a/application/main.cpp b/application/main.cpp index 16eb301..484529b 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -27,7 +27,7 @@ Boston, MA 02110-1301, USA. #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) -#include +#include #else #include #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 diff --git a/application/resources/sailfish/qml/pages/StationListPage.js b/application/resources/sailfish/qml/pages/StationListPage.js index 858b36e..7a06bc2 100644 --- a/application/resources/sailfish/qml/pages/StationListPage.js +++ b/application/resources/sailfish/qml/pages/StationListPage.js @@ -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, '' + - match + '') + console.log('s is ' + s); + if (match) { + return s.replace(r, '' + + match + '') + } else { + return s + } } else { return s } diff --git a/application/resources/sailfish/qml/pages/StationListPage.qml b/application/resources/sailfish/qml/pages/StationListPage.qml index 7d6deca..f65f57d 100644 --- a/application/resources/sailfish/qml/pages/StationListPage.qml +++ b/application/resources/sailfish/qml/pages/StationListPage.qml @@ -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 - } } diff --git a/application/stationlistproxymodel.cpp b/application/stationlistproxymodel.cpp index 44ad3b5..919f17a 100644 --- a/application/stationlistproxymodel.cpp +++ b/application/stationlistproxymodel.cpp @@ -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); diff --git a/application/stationscheduleitem.cpp b/application/stationscheduleitem.cpp index 244cbb7..af4d997 100644 --- a/application/stationscheduleitem.cpp +++ b/application/stationscheduleitem.cpp @@ -131,7 +131,7 @@ int StationScheduleItem::delayClass() return d->delayClass; } -void StationScheduleItem::setDelayClass(const int value) +void StationScheduleItem::setDelayClass(int value) { d->delayClass = value; } diff --git a/application/stationscheduleitem.h b/application/stationscheduleitem.h index 8205318..156438f 100644 --- a/application/stationscheduleitem.h +++ b/application/stationscheduleitem.h @@ -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); diff --git a/application/stationschedulemodel.cpp b/application/stationschedulemodel.cpp index 96b1f4c..c3fb03d 100644 --- a/application/stationschedulemodel.cpp +++ b/application/stationschedulemodel.cpp @@ -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(); }