Don't connect to GraphUpdated more than once.
[harmattan/cameraplus] / src / geocode.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef GEOCODE_H
24 #define GEOCODE_H
25
26 #include <QObject>
27 #include <QGeoSearchReply>
28 #include <QGeoServiceProvider>
29 #include <QGeoSearchManager>
30
31 using namespace QtMobility;
32
33 class Geocode : public QObject {
34   Q_OBJECT
35   Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged);
36   Q_PROPERTY(QString country READ country NOTIFY countryChanged);
37   Q_PROPERTY(QString city READ city NOTIFY cityChanged);
38   Q_PROPERTY(QString suburb READ suburb NOTIFY suburbChanged);
39
40 public:
41   Geocode(QObject *parent = 0);
42   ~Geocode();
43
44   bool isActive() const;
45   void setActive(bool active);
46
47   QString country() const;
48   QString city() const;
49   QString suburb() const;
50
51 public slots:
52   void search(double longitude, double latitude);
53
54 signals:
55   void activeChanged();
56   void countryChanged();
57   void cityChanged();
58   void suburbChanged();
59
60 private slots:
61   void finished(QGeoSearchReply *reply);
62   void error(QGeoSearchReply *reply, const QGeoSearchReply::Error& error,
63              const QString& errorString = QString());
64
65 private:
66   void clear();
67
68   QGeoServiceProvider *m_provider;
69   QGeoSearchManager *m_manager;
70   QGeoSearchReply *m_reply;
71
72   bool m_active;
73   QString m_country;
74   QString m_city;
75   QString m_suburb;
76 };
77
78 #endif /* GEOCODE_H */