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