Small change to text element.
[jspeed] / src / poialerts.h
1 /*
2  * This file is part of jSpeed.
3  *
4  * jSpeed is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * jSpeed is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with jSpeed.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18
19 #ifndef POIALERTS_H
20 #define POIALERTS_H
21
22 #include <QtCore/QList>
23 #include <QtCore/QSet>
24 #include <QtCore/QQueue>
25 #include "poireader.h"
26
27 class QString;
28
29 class PoiAlerts : public QObject
30 {
31     Q_OBJECT
32
33 public:
34     static int const POI_ALERT_INTERVAL = 120;
35     static int const IN_ROUTE_MARGIN = 22;
36     static PoiAlerts& instance();
37     static QString getPoiDir();
38     ~PoiAlerts();
39     bool start();
40     void end();
41     double getCurrentDistance() const;
42     QString getCurrentPoi() const;
43     bool poiInView() const;
44     QString const& error() const;
45
46 signals:
47     void visibilityChanged(bool visible);
48
49 public slots:
50     bool loadConfig();
51
52 private slots:
53     void onDataUpdated();
54     void removePlayed();
55
56 private:
57     PoiAlerts();
58     bool loadPois();
59     void playSound(int poiIndex);
60     static double calculateDistance(double latitude1, double longitude1,
61                                     double latitude2, double longitude2);
62     static double calculateTrack(double latitude1, double longitude1,
63                                  double latitude2, double longitude2);
64     QString file_;
65     bool onlyOnRoute_;
66     QList<PoiReader::Poi> pois_;
67     QQueue<int> playedSounds_;
68     bool enabled_;
69     double distance_;
70     double travelled_;
71     PoiReader::Poi* currentPoi_;
72     bool loaded_;
73     QString error_;
74
75 };
76
77 #endif