#include <QFileInfo>
#include <QDebug>
#include <QStandardItem>
-#include <QtLocation/QGeoCoordinate>
+#include <QGeoCoordinate>
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTM_USE_NAMESPACE
Q_DECLARE_METATYPE(QGeoCoordinate)
#endif
-static QHash<int, QByteArray> roles;
-
StationListModel::StationListModel(QObject *parent) :
QStandardItemModel(parent)
{
setRowCount(0);
#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";
-#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
- setRoleNames(roles);
+ setRoleNames(roleNames());
#endif
}
QHash<int, QByteArray> StationListModel::roleNames() const
{
+ QHash<int, QByteArray> roles;
+ roles[Qt::DisplayRole] = "name";
+ roles[StationListModel::PositionRole] = "position";
+ roles[StationListModel::StationCodeRole] = "code";
return roles;
}
#include <QtGlobal>
#include <QDebug>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
-#include <QtWebKitWidgets/QtWebKitWidgets>
+#include <QtWebKitWidgets>
#else
#include <QWebElement>
#include <QWebFrame>
#include <QWebPage>
#endif
-static QHash<int, QByteArray> roles;
-
StationScheduleModel::StationScheduleModel(const QString &name, QObject *parent) :
QAbstractListModel(parent),
m_name(name),
{
DataProvider *provider = DataProvider::instance();
- QHash<int, QByteArray> roles;
- roles[TrainRole] = "train";
- roles[DepartureStationRole] = "departureStation";
- roles[DepartureTimeRole] = "departureTime";
- roles[ArrivalStationRole] = "arrivalStation";
- roles[ArrivalTimeRole] = "arrivalTime";
- roles[DetailsUrlRole] = "detailsUrl";
- roles[DelayRole] = "delay";
- 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)));
connect(provider, SIGNAL(error()),
this, SLOT(onNetworkError()));
Settings *settings = Settings::instance();
m_scheduleType = settings->showArrivalsPreferred() ? ArrivalSchedule : DepartureSchedule;
+#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
+ setRoleNames(roleNames());
+#endif
}
const QString &StationScheduleModel::name()
QHash<int, QByteArray> StationScheduleModel::roleNames() const
{
+ QHash<int, QByteArray> roles;
+ roles[TrainRole] = "train";
+ roles[DepartureStationRole] = "departureStation";
+ roles[DepartureTimeRole] = "departureTime";
+ roles[ArrivalStationRole] = "arrivalStation";
+ roles[ArrivalTimeRole] = "arrivalTime";
+ roles[DetailsUrlRole] = "detailsUrl";
+ roles[DelayRole] = "delay";
+ roles[DelayClassRole] = "delayClass";
+ roles[ExpectedPlatformRole] = "expectedPlatform";
+ roles[ActualPlatformRole] = "actualPlatform";
+
return roles;
}