-
Notifications
You must be signed in to change notification settings - Fork 32
/
fahrplan.h
171 lines (146 loc) · 6.52 KB
/
fahrplan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/****************************************************************************
**
** This file is a part of Fahrplan.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#ifndef FAHRPLAN_H
#define FAHRPLAN_H
#include "parser/parser_definitions.h"
#include "parser/parser_abstract.h"
#include <QObject>
#include <QSettings>
#include <QStringList>
#include <QStringListModel>
class FahrplanBackendManager;
class FahrplanParserThread;
class StationSearchResults;
class Timetable;
class Favorites;
class Trainrestrictions;
class Fahrplan : public QObject
{
Q_OBJECT
Q_PROPERTY(FahrplanParserThread *parser READ parser)
Q_PROPERTY(QString parserName READ parserName NOTIFY parserChanged)
Q_PROPERTY(QString parserShortName READ parserShortName NOTIFY parserChanged)
Q_PROPERTY(QString version READ getVersion CONSTANT)
Q_PROPERTY(bool supportsCalendar READ supportsCalendar CONSTANT)
Q_PROPERTY(StationSearchResults *stationSearchResults READ stationSearchResults CONSTANT)
Q_PROPERTY(Favorites *favorites READ favorites CONSTANT)
Q_PROPERTY(Timetable *timetable READ timetable CONSTANT)
Q_PROPERTY(Trainrestrictions *trainrestrictions READ trainrestrictions CONSTANT)
Q_PROPERTY(QString departureStationName READ departureStationName NOTIFY departureStationChanged)
Q_PROPERTY(QString viaStationName READ viaStationName NOTIFY viaStationChanged)
Q_PROPERTY(QString arrivalStationName READ arrivalStationName NOTIFY arrivalStationChanged)
Q_PROPERTY(QString currentStationName READ currentStationName NOTIFY currentStationChanged)
Q_PROPERTY(QString directionStationName READ directionStationName NOTIFY directionStationChanged)
Q_PROPERTY(QString trainrestrictionName READ trainrestrictionName NOTIFY trainrestrictionChanged)
Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
Q_ENUMS(StationType)
Q_ENUMS(Mode)
public:
enum StationType {
DepartureStation,
ViaStation,
ArrivalStation,
CurrentStation,
DirectionStation
};
enum Mode {
DepartureMode = ParserAbstract::Departure,
ArrivalMode = ParserAbstract::Arrival,
NowMode
};
explicit Fahrplan(QObject *parent = 0);
FahrplanParserThread *parser();
Favorites *favorites() const;
QString parserName() const;
QString parserShortName() const;
QString getVersion();
bool supportsCalendar();
StationSearchResults *stationSearchResults() const;
Timetable *timetable() const;
Trainrestrictions *trainrestrictions() const;
QString departureStationName() const;
QString viaStationName() const;
QString arrivalStationName() const;
QString currentStationName() const;
QString directionStationName() const;
QString trainrestrictionName() const;
Fahrplan::Mode mode() const;
void setMode(Fahrplan::Mode mode);
QDateTime dateTime() const;
void setDateTime(const QDateTime &dateTime);
Q_INVOKABLE bool timeFormat24h() const;
public slots:
QStringList getParserList();
void setParser(int index);
void storeSettingsValue(const QString &key, const QString &value);
QString getSettingsValue(const QString &key, const QString &defaultValue);
void swapStations(StationType type1, StationType type2);
void resetStation(StationType type);
void findStationsByName(const QString &stationName);
void findStationsByCoordinates(qreal longitude, qreal latitude);
void getTimeTable();
void searchJourney();
void addJourneyDetailResultToCalendar(JourneyDetailResultList *result);
void setTrainrestriction(int index);
signals:
void departureStationChanged();
void viaStationChanged();
void arrivalStationChanged();
void currentStationChanged();
void directionStationChanged();
void trainrestrictionChanged();
void modeChanged();
void dateTimeChanged();
void parserStationsResult();
void parserJourneyResult(JourneyResultList *result);
void parserJourneyDetailsResult(JourneyDetailResultList *result);
void parserTimeTableResult();
void parserErrorOccured(const QString &msg);
void parserChanged(const QString &name, int index);
void addCalendarEntryComplete(bool success);
private slots:
void setStation(Fahrplan::StationType type, const Station &station);
void onParserChanged(const QString &name, int index);
void onStationSearchResults(const StationsList &result);
void onTimetableResult(const TimetableEntriesList &timetableEntries);
void bindParserSignals();
private:
static FahrplanBackendManager *m_parser_manager;
static StationSearchResults *m_stationSearchResults;
static Favorites *m_favorites;
static Timetable *m_timetable;
static Trainrestrictions *m_trainrestrictions;
QSettings *settings;
Station m_departureStation;
Station m_viaStation;
Station m_arrivalStation;
Station m_currentStation;
Station m_directionStation;
int m_trainrestriction;
Mode m_mode;
QDateTime m_dateTime;
Station getStation(StationType type) const;
void loadStations();
void saveStationToSettings(const QString &key, const Station &station);
Station loadStationFromSettigns(const QString &key);
};
Q_DECLARE_METATYPE(Fahrplan::StationType)
Q_DECLARE_METATYPE(Fahrplan::Mode)
#endif // FAHRPLAN_H