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 FavoriteIndicatorRole, //<bool - If the station has been marked as favorite
43 LongitudeRole, //< double - Longitude of the station
44 LatitudeRole, //< double - Latitude of the station
45 SectionRole //< Qstring - The section the station belongs to (depends on the sorting mode)
48 explicit StationListModel(QObject *parent = 0);
50 bool load(const QString &filename);
52 QHash<int, QByteArray> roleNames() const;
54 // Needed to make SectionScroller happy.
55 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
63 void readStationsElement();
64 void readStationElement();
65 void readPosElement(QStandardItem *item);
66 void readNameElement(QStandardItem *item);
67 void readCodeElement(QStandardItem *item);
68 void skipUnknownElement(const QString &name = QString());
70 QXmlStreamReader m_reader;
73 #endif // STATIONLISTMODEL_H