8adc16399d342fe0a552d56b2b08f1a35aeaea8b
[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 = 20;
36     static PoiAlerts& instance();
37     static QString getPoiDir();
38     ~PoiAlerts();
39     bool start();
40     void end();
41     void startTest();
42     double getCurrentDistance() const;
43     QString getCurrentPoi() const;
44     bool poiInView() const;
45     QString const& error() const;
46
47 public slots:
48     bool loadConfig();
49
50 private slots:
51     void onDataUpdated();
52     void removePlayed();
53
54 private:
55     PoiAlerts();
56     bool loadPois();
57     void playSound(int poiIndex);
58     static double calculateDistance(double latitude1, double longitude1,
59                                     double latitude2, double longitude2);
60     static double calculateTrack(double latitude1, double longitude1,
61                                  double latitude2, double longitude2);
62     QString file_;
63     bool onlyOnRoute_;
64     QList<PoiReader::Poi> pois_;
65     QQueue<int> playedSounds_;
66     bool enabled_;
67     int distance_;
68     double travelled_;
69     PoiReader::Poi* currentPoi_;
70     double currentDistance_;
71     bool loaded_;
72     QString error_;
73
74 };
75
76 #endif