1 #ifndef STATIONLISTMODEL_H
2 #define STATIONLISTMODEL_H
6 Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
25 #include <QStandardItemModel>
26 #include <QXmlStreamReader>
29 class StationListModel;
31 class StationListModel : public QStandardItemModel
34 Q_ENUMS(StationListRole)
35 Q_PROPERTY(int count READ rowCount)
38 enum StationListRole {
39 PositionRole = Qt::UserRole + 1, //< QGeoCoordinate - Station coordinate
40 StationCodeRole, //< QString - Station Code (Precise name if the Display name is known to fail)
41 RecentIndicatorRole, //<bool - If the station has been recently looked up
42 LongitudeRole, //< double - Longitude of the station
43 LatitudeRole, //< double - Latitude of the station
46 explicit StationListModel(QObject *parent = 0);
48 bool load(const QString &filename);
50 QHash<int, QByteArray> roleNames() const;
52 // Needed to make SectionScroller happy.
53 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
61 void readStationsElement();
62 void readStationElement();
63 void readPosElement(QStandardItem *item);
64 void readNameElement(QStandardItem *item);
65 void readCodeElement(QStandardItem *item);
66 void skipUnknownElement(const QString &name = QString());
68 QXmlStreamReader m_reader;
71 #endif // STATIONLISTMODEL_H