Fix error reporting in the station page
[quandoparte] / application / stationlistmodel.h
1 #ifndef STATIONLISTMODEL_H
2 #define STATIONLISTMODEL_H
3
4 /*
5
6 Copyright (C) 2011 Luciano Montanaro <mikelima@cirulla.net>
7
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.
12
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.
17
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.
22
23 */
24
25 #include <QStandardItemModel>
26 #include <QXmlStreamReader>
27
28 class QStandardItem;
29 class StationListModel;
30
31 class StationListModel : public QStandardItemModel
32 {
33     Q_OBJECT
34     Q_ENUMS(StationListRole)
35 public:
36     enum StationListRole {
37         PositionRole = Qt::UserRole + 1, //< QGeoCoordinate - Station coordinate
38         StationCodeRole, //< QString - Station Code (Precise name if the Display name is known to fail)
39         RecentIndicatorRole //<bool - If the station has been recently looked up
40     };
41
42     explicit StationListModel(QObject *parent = 0);
43
44     bool load(const QString &filename);
45
46 signals:
47
48 public slots:
49
50 private:
51     void readStationsElement();
52     void readStationElement();
53     void readPosElement(QStandardItem *item);
54     void readNameElement(QStandardItem *item);
55     void readCodeElement(QStandardItem *item);
56     void skipUnknownElement();
57
58     QXmlStreamReader m_reader;
59 };
60
61 #endif // STATIONLISTMODEL_H