Locations selectors and edit window implemented.
[ptas] / zouba / src / locations.h
1 #ifndef LOCATIONS_H
2 #define LOCATIONS_H
3
4 #include "location.h"
5
6 #include <QHash>
7 #include <QList>
8 #include <QString>
9 #include <QObject>
10
11 class Locations: public QObject
12 {
13     Q_OBJECT
14
15 public:
16     static Locations *GetInstance();
17     //static void destroyLocations();
18
19     bool addEditLocation(Location *location);
20     bool removeLocation(Location *location);
21
22     bool increaseLocationIndex(const QString &label);
23     bool lowerLocationIndex(const QString &label);
24
25     Location *getLocation(const QString &label) const;
26     Location *getLocation(const int&) const;
27     Location *getGpsLocation() const;
28     int size() const;
29
30     //const QHash<QString, Location *>& getLocations() const;
31
32 signals:
33     void locationsChanged();
34
35 private:
36     Locations();
37     //~Locations();
38     Locations(const Locations&);
39     void operator=(const Locations&);
40
41     void restoreLocations();
42     void saveLocation(Location *location);
43     bool findLabel(const int &index, QString &label) const;
44     void changeIndex(const QString &label, const int &index, bool signal = true);
45
46     QHash<QString, Location*> m_locationStorage;
47     QList<QString> m_indexStorage;
48     Location* m_gpsLocation;
49
50     static Locations *m_instance;
51 };
52 #endif // LOCATIONS_H