-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfavoriteslist.h
executable file
·55 lines (42 loc) · 1.45 KB
/
favoriteslist.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
#ifndef FAVORITESLIST_H
#define FAVORITESLIST_H
#include <QObject>
#include <QMultiHash>
class RealTimeData;
class FavoritesList : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<QObject *> data READ data NOTIFY dataChanged)
Q_PROPERTY(bool waitingForData READ waitingForData NOTIFY waitingForDataChanged)
public:
explicit FavoritesList(QObject *parent = 0);
~FavoritesList();
QList<QObject *> data() const {
QList<QObject *> list;
foreach (RealTimeData *d, m_data) {
list.append((QObject *)d);
}
return list;
}
bool waitingForData() {
return m_pendingRequests > 0;
}
signals:
void dataChanged();
void waitingForDataChanged();
public Q_SLOTS:
void addFavorite(int stopID, const QString &stopName, const QString &lineName, const QString &destination, const QString &platform, int transportation);
void removeFavorite(int stopID, const QString &lineName, const QString &destination, const QString &platform);
bool isFavorite(int stopID, const QString &line, const QString &destination, const QString &platform);
void refreshData();
private Q_SLOTS:
void processReply();
private:
RealTimeData *getFavorite(int stopID, const QString &line, const QString &destination, const QString &platform);
void save() const;
void load();
QList<RealTimeData *> m_data;
QMultiHash<int, void *> m_stops;
int m_pendingRequests;
};
#endif // FAVORITESLIST_H