stationlistproxymodel.cpp \
settings.cpp \
dataprovider.cpp \
- stationschedulemodel.cpp
+ stationschedulemodel.cpp \
+ stationscheduleitem.cpp
HEADERS += \
$$PLATFORM_HEADERS \
stationlistproxymodel.h \
settings.h \
dataprovider.h \
- stationschedulemodel.h
+ stationschedulemodel.h \
+ stationscheduleitem.h
FORMS += \
settingsdialog.ui \
qml.path = $$DATADIR/qml
INSTALLS += qml
}
+
+
#! /bin/sh
-BASEURL=http://jxapi.openstreetmap.org/xapi/api/0.6
-#BASEURL=http://open.mapquestapi.com/xapi/api/0.6
+#BASEURL=http://jxapi.openstreetmap.org/xapi/api/0.6
+BASEURL=http://open.mapquestapi.com/xapi/api/0.6
-curl --location --globoff "$BASEURL/node[railway=station][bbox=8,46,14,47]" -o nord.osm
+#curl --location --globoff "$BASEURL/node[railway=station][bbox=8,46,14,47]" -o nord.osm
curl --location --globoff "$BASEURL/node[railway=station][bbox=6.7,44,10,46]" -o nordovest.osm
curl --location --globoff "$BASEURL/node[railway=station][bbox=10,44,14,46]" -o nordest.osm
+exit 0
curl --location --globoff "$BASEURL/node[railway=station][bbox=7.5,43.5,8.5,44]" -o liguria.osm
curl --location --globoff "$BASEURL/node[railway=station][bbox=10,42,15,44]" -o centronord.osm
curl --location --globoff "$BASEURL/node[railway=station][bbox=12,40,17,42]" -o centrosud.osm
curl --location --globoff "$BASEURL/node[railway=halt][bbox=12,36.5,16.5,38]" -o h-sicilia.osm
curl --location --globoff "$BASEURL/node[railway=halt][bbox=17.3,39.5,19,41]" -o h-puglia.osm
curl --location --globoff "$BASEURL/node[railway=halt][bbox=8,38.7,10,41.3]" -o h-sardegna.osm
+exit 0
curl --location --globoff "$BASEURL/way[railway=station][bbox=8,46,14,47]" -o w-nord.osm
curl --location --globoff "$BASEURL/way[railway=station][bbox=6.7,44,10,46]" -o w-nordovest.osm
#include <QWebElement>
#include <QWebFrame>
#include <QWebPage>
-
StationScheduleModel::StationScheduleModel(const QString &name, QObject *parent) :
- QStringListModel(parent),
+ QAbstractListModel(parent),
m_name(name)
{
DataProvider *provider = DataProvider::instance();
+ QHash<int, QByteArray> roles;
+ roles[DepartureStationRole] = "departureStation";
+ roles[DepartureTimeRole] = "departureTime";
+ roles[ArrivalStationRole] = "arrivalStation";
+ roles[ArrivalTimeRole] = "ArrivalTime";
+ roles[DetailsUrlRole] = "DetailsUrl";
+ roles[DelayRole] = "delay";
+ roles[DelayClassRole] = "delayClassRole";
+ setRoleNames(roles);
connect(provider, SIGNAL(stationScheduleReady(QByteArray,QUrl)),
this, SLOT(parse(QByteArray,QUrl)));
}
}
+StationScheduleItem &parseResult(QWebElement &result)
+{
+
+}
+
void StationScheduleModel::parse(const QByteArray &htmlReply, const QUrl &baseUrl)
{
Q_UNUSED(baseUrl);
if (current.classes().contains("bloccorisultato")) {
departures << current.toPlainText();
}
- current.addClass("departures");
+ StationScheduleItem schedule = parseResult(current);
+ if (schedule.isValid()) {
+ m_schedules << schedule;
+ }
current = current.nextSibling();
qDebug() << "marking as departures";
if (current.isNull())
if (current.classes().contains("bloccorisultato")) {
arrivals << current.toPlainText();
}
- current.addClass("arrivals");
current = current.nextSibling();
qDebug() << "marking as arrival";
if (current.isNull())
break;
}
- setStringList(departures);
qDebug() << "departures list contain:";
qDebug() << departures;
qDebug() << "arrivals list contain:";
#ifndef STATIONSCHEDULEMODEL_H
#define STATIONSCHEDULEMODEL_H
+#include "stationscheduleitem.h"
+
#include <QObject>
-#include <QStringListModel>
+#include <QAbstractListModel>
#include <QUrl>
-class StationScheduleModel : public QStringListModel
+class StationScheduleModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ enum StationRoles {
+ RefRole = Qt::UserRole +1,
+ DepartureStationRole,
+ DepartureTimeRole,
+ ArrivalStationRole,
+ ArrivalTimeRole,
+ DetailsUrlRole,
+ DelayRole,
+ DelayClassRole
+ };
+
public:
explicit StationScheduleModel(const QString &name = "", QObject *parent = 0);
QString &name();
void setName(const QString &name);
+ int rowCount(const QModelIndex &parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
signals:
void nameChanged();
private:
QString m_name;
- QStringList departures;
- QStringList arrivals;
+ QList<StationScheduleItem> m_schedules;
};
#endif // STATIONSCHEDULEMODEL_H