Moved location update logic to new class called UpdateLocation.
[situare] / src / engine / updatelocation.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20 */
21
22
23 #ifndef UPDATELOCATION_H
24 #define UPDATELOCATION_H
25
26 #include <QObject>
27
28 /**
29   * @brief Controller for location update
30   *
31   * @author Sami Rämö (at) ixonos.com
32   */
33 class UpdateLocation : public QObject
34 {
35     Q_OBJECT
36
37     /**
38     * @brief Message text
39     *
40     * @property message
41     */
42     Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
43
44     /**
45     * @brief Publish on FB wall setting
46     *
47     * @property publish
48     */
49     Q_PROPERTY(bool publish READ publish WRITE setPublish NOTIFY publishChanged)
50
51 public:
52     /**
53       * @brief Constructor
54       *
55       * Read unsent message from settigs.
56       */
57     explicit UpdateLocation(QObject *parent = 0);
58
59     /**
60       * @brief Destructor
61       *
62       * Save unsent message to settings.
63       */
64     ~UpdateLocation();
65
66     /**
67       * @brief Getter for message.
68       *
69       * @returns Message
70       */
71     QString message() const;
72
73     /**
74       * @brief Getter for publish setting
75       *
76       * @returns True is update should be published on FB wall.
77       */
78     bool publish() const;
79
80 public slots:
81     /**
82       * @brief Clear data.
83       */
84     void clear();
85
86     /**
87       * @brief Send location update
88       *
89       * Emits locationUpdate() signal.
90       */
91     void send();
92
93     /**
94       * @brief Setter for message
95       *
96       * @param message New message.
97       */
98     void setMessage(const QString &message);
99
100     /**
101       * @brief Setter for publish setting
102       *
103       * @param publish True is update should be published on FB wall.
104       */
105     void setPublish(bool publish);
106
107 signals:
108     /**
109     * @brief Send location update
110     *
111     * @param status Status message
112     * @param publish Publish on Facebook?
113     */
114     void locationUpdate(const QString &status, bool publish);
115
116     /**
117       * @brief Notifies that message has changed
118       */
119     void messageChanged();
120
121     /**
122       * @brief Notifies that publish setting has changed
123       */
124     void publishChanged();
125
126 private:
127     bool m_publish;         ///< Should the update be published on FB wall
128     QString m_message;      ///< Location update message
129 };
130
131 #endif // UPDATELOCATION_H