#include "view.h"
#endif
-#ifdef TARGET_PLATFORM_SAILFISH
+#include <QtGlobal>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
#include <QtGui/QGuiApplication>
#else
#include <QtGui/QApplication>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
-#ifdef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
QScopedPointer< QGuiApplication > a(new QGuiApplication(argc, argv));
#elif TARGET_PLATFORM_HARMATTAN
QScopedPointer< QApplication > a(MDeclarativeCache::qApplication(argc, argv));
#include <QFileInfo>
#include <QDebug>
#include <QStandardItem>
-#ifndef TARGET_PLATFORM_SAILFISH
-#include <QGeoCoordinate>
-#endif
+#include <QtLocation/QGeoCoordinate>
-#ifndef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTM_USE_NAMESPACE
Q_DECLARE_METATYPE(QGeoCoordinate)
#endif
QStandardItemModel(parent)
{
setRowCount(0);
-#ifndef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QHash<int, QByteArray> roles;
#endif
roles[Qt::DisplayRole] = "name";
roles[StationListModel::PositionRole] = "position";
roles[StationListModel::StationCodeRole] = "code";
-#ifndef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
setRoleNames(roles);
#endif
}
void StationListModel::readPosElement(QStandardItem *item)
{
QStringList coordinates = m_reader.readElementText().split(",");
-#ifndef TARGET_PLATFORM_SAILFISH
QGeoCoordinate pos = QGeoCoordinate(coordinates[0].toDouble(), coordinates[1].toDouble());
item->setData(QVariant::fromValue(pos), PositionRole);
-#endif
m_reader.readElementText();
if (m_reader.isEndElement()) {
m_reader.readNext();
#include "settings.h"
#include "stationlistmodel.h"
+#include <QtGlobal>
#include <QDebug>
-#ifndef TARGET_PLATFORM_SAILFISH
-#include <QGeoCoordinate>
+#include <QtLocation/QGeoCoordinate>
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTM_USE_NAMESPACE
Q_DECLARE_METATYPE(QGeoCoordinate)
StationListProxyModel::StationListProxyModel(QObject *parent) :
QSortFilterProxyModel(parent),
-#ifndef TARGET_PLATFORM_SAILFISH
positionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)),
m_here(44.5, 9.0),
-#endif
m_filterRecentOnly(false)
{
Settings *settings = Settings::instance();
setFilterCaseSensitivity(Qt::CaseInsensitive);
setSortCaseSensitivity(Qt::CaseInsensitive);
setDynamicSortFilter(true);
-#ifndef TARGET_PLATFORM_SAILFISH
if (positionInfoSource) {
qDebug() << "position info source available";
connect(positionInfoSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
} else {
qDebug() << "No position info source available";
}
-#endif
connect(settings, SIGNAL(recentStationsChanged()),
this, SLOT(updateRecentStations()));
updateRecentStations();
int role = sortRole();
if (role == StationListModel::PositionRole) {
-#ifdef TARGET_PLATFORM_SAILFISH
- return 0;
-#else
QGeoCoordinate first = left.data(role).value<QGeoCoordinate>();
QGeoCoordinate second = right.data(role).value<QGeoCoordinate>();
return first.distanceTo(m_here) < second.distanceTo(m_here);
-#endif
} else {
return QString::compare(left.data(role).toString(),
right.data(role).toString(),
}
-#ifndef TARGET_PLATFORM_SAILFISH
-void StationListProxyModel::setUserPosition(const QtMobility::QGeoCoordinate &pos)
+void StationListProxyModel::setUserPosition(const QGeoCoordinate &pos)
{
qDebug() << "Position is now" << pos;
m_here = pos;
invalidate();
}
}
-#endif
void StationListProxyModel::setRecentStations(const QStringList &stations)
{
default:
break;
}
-#ifndef TARGET_PLATFORM_SAILFISH
if (mode == StationListProxyModel::DistanceSorting) {
positionInfoSource->startUpdates();
} else {
positionInfoSource->stopUpdates();
}
-#endif
invalidate();
sort(0);
}
-#ifndef TARGET_PLATFORM_SAILFISH
-void StationListProxyModel::updatePosition(const QtMobility::QGeoPositionInfo &update)
+void StationListProxyModel::updatePosition(const QGeoPositionInfo &update)
{
qDebug() << "Position update received" << update;
if (update.isValid()) {
}
}
}
-#endif
*/
+#include <QtGlobal>
#include <QSortFilterProxyModel>
-#ifndef TARGET_PLATFORM_SAILFISH
-#include <QGeoCoordinate>
-#include <QGeoPositionInfoSource>
-#endif
+#include <QtLocation/QGeoCoordinate>
+#include <QtLocation/QGeoPositionInfoSource>
#include <QMetaType>
#include <QStringList>
-#ifndef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTM_USE_NAMESPACE
#endif
SortingMode sortingMode();
void setSortingMode(SortingMode mode);
-#ifndef TARGET_PLATFORM_SAILFISH
Q_INVOKABLE void setUserPosition(const QGeoCoordinate &pos);
-#endif
Q_INVOKABLE void setRecentStations(const QStringList &stations);
Q_INVOKABLE void setRecentOnlyFilter(bool);
void forceSortingMode(SortingMode mode);
private slots:
-#ifndef TARGET_PLATFORM_SAILFISH
void updatePosition(const QGeoPositionInfo &update);
-#endif
void updateRecentStations(void);
private:
QString m_searchPattern;
-#ifndef TARGET_PLATFORM_SAILFISH
QGeoPositionInfoSource *positionInfoSource;
QGeoCoordinate m_here;
-#endif
QStringList m_stations;
SortingMode m_sortingMode;
bool m_filterRecentOnly;
#include "dataprovider.h"
#include "settings.h"
+#include <QtGlobal>
#include <QDebug>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
+#include <QtWebKitWidgets/QtWebKitWidgets>
+#else
#include <QWebElement>
-#ifndef TARGET_PLATFORM_SAILFISH
#include <QWebFrame>
-#endif
#include <QWebPage>
+#endif
+
+static QHash<int, QByteArray> roles;
StationScheduleModel::StationScheduleModel(const QString &name, QObject *parent) :
QAbstractListModel(parent),
roles[DelayClassRole] = "delayClass";
roles[ExpectedPlatformRole] = "expectedPlatform";
roles[ActualPlatformRole] = "actualPlatform";
+#if (QT_VERSION <= QT_VERSION_CHECK(5, 0, 0))
setRoleNames(roles);
+#endif
connect(provider, SIGNAL(stationScheduleReady(QByteArray,QUrl)),
this, SLOT(parse(QByteArray,QUrl)));
}
}
+QHash<int, QByteArray> StationScheduleModel::roleNames() const
+{
+ return roles;
+}
+
StationScheduleModel::ScheduleType StationScheduleModel::type()
{
return m_scheduleType;
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();
if (current.isNull())
break;
}
+#endif
endResetModel();
emit layoutChanged();
}
const QString &error();
void setError(const QString &code);
+ QHash<int, QByteArray> roleNames() const;
+
signals:
void nameChanged();
void codeChanged();
#include "stationlistproxymodel.h"
#include "stationschedulemodel.h"
+#include <QtGlobal>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QModelIndex>
-#include <QtConcurrentRun>
-#ifdef TARGET_PLATFORM_SAILFISH
-#include <QtQuick>
+#include <QtConcurrent/QtConcurrentRun>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+#include <QtQuick/QtQuick>
#else
#include <QtDeclarative>
#endif
#endif
}
-#ifdef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
View::View(QWindow *parent) :
QQuickView(parent),
#else
qmlRegisterType<StationScheduleModel>(
"net.cirulla.quandoparte", 1, 0, "StationScheduleModel");
-#ifdef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
QQmlContext *context = this->rootContext();
#else
QDeclarativeContext *context = this->rootContext();
*/
+#include <QtGlobal>
#include <QFuture>
-#ifdef TARGET_PLATFORM_SAILFISH
-#include <QQuickView>
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+#include <QtQuick/QQuickView>
#else
#include <QDeclarativeView>
#endif
class StationListProxyModel;
class View :
-#ifdef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
public QQuickView
#else
public QDeclarativeView
{
Q_OBJECT
public:
-#ifdef TARGET_PLATFORM_SAILFISH
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
explicit View(QWindow *parent = 0);
#else
explicit View(QWidget *parent = 0);