Moved autoCentering method call from MainWindow to Engine.
[situare] / src / ui / mainwindow.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Kaj Wallin - kaj.wallin@ixonos.com
7
8    Situare is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License
10    version 2 as published by the Free Software Foundation.
11
12    Situare is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with Situare; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20    USA.
21 */
22
23
24 #ifndef MAINWINDOW_H
25 #define MAINWINDOW_H
26
27 #include <QtGui/QMainWindow>
28 #include <QWidget>
29 #include <QDebug>
30 #include <QObject>
31 #include "facebookservice/facebookauthentication.h"
32 #include "situareservice/situareservice.h"
33 #include <QNetworkAccessManager>
34 #include "listviewscreen.h"
35 #include "mapviewscreen.h"
36 #include "updatelocation/updatelocationdialog.h"
37 #include "ui/mainwindow.h"
38
39 class QLabel;
40 class QStackedWidget;
41
42 /**
43 * @brief Main Window Class
44 *
45 * @class MainWindow mainwindow.h "src/ui/mainwindow.h"
46 */
47 class MainWindow : public QMainWindow
48 {
49     Q_OBJECT
50
51 public:
52     /**
53     * @brief Constructor
54     *
55     * @param parent Parent
56     */
57     MainWindow(QWidget *parent = 0);
58
59     /**
60     * @brief Destructor
61     */
62     ~MainWindow();
63
64 /*******************************************************************************
65  * MEMBER FUNCTIONS AND SLOTS
66  ******************************************************************************/
67 public slots:
68
69     /**
70     * @brief Slot for auto centering enabling.
71     *
72     * @param checked true if button state is checked, false otherwise
73     */
74     void autoCenteringToggled(bool checked);
75
76     /**
77     * @brief Public slot, which open settings dialog
78     */
79     void openSettingsDialog();
80
81     /**
82     * @brief Public slot, which initiates toListViewAct action to switch view
83     */
84     void toListView();
85
86     /**
87     * @brief Public slot, which initiates toMapViewAct action to switch view
88     */
89     void toMapView();
90
91     /**
92     * @brief Toggle progress indicator.
93     *
94     * @param state true if progress indicator should be shown, false otherwise
95     */
96     void toggleProgressIndicator(bool state);
97
98 private:
99     /**
100     * @brief Private method to create the Menu items
101     */
102     void createMenus();
103
104     /**
105     * @brief Private method to create List and Map views as a stacked widget
106     */
107     void createViews();
108
109     /**
110     * @brief Method used to switch active view.
111     *
112     * @param nextIndex 0 for listview, 1 for mapview
113     */
114     void switchView(int);
115
116     void showMaemoInformationBox(const QString &message);
117
118 private slots:
119     /**
120     * @brief Private slot, which starts UpdateLocationDialog
121     *
122     */
123     void openLocationUpdateDialog();
124
125     /**
126     * @brief Slot for gps enabling.
127     *
128     * @param checked true if button state is checked, false otherwise
129     */
130     void gpsActionToggled(bool checked);
131
132     /**
133     * @brief Slot for gps timeout.
134     *
135     * Called when request timeout occurs.
136     */
137     void gpsTimeout();
138
139     /**
140     * @brief Slot for gps error.
141     *
142     * @param message error message
143     */
144     void gpsError(const QString &message);
145
146 /*******************************************************************************
147  * SIGNALS
148  ******************************************************************************/
149 signals:
150     /**
151     * @brief Signal for requesting reverseGeo from SituareEngine
152     *
153     */
154     void requestReverseGeo();
155
156     /**
157     * @brief Signals, when address data is ready
158     *
159     * @param address Street address
160     */
161     void reverseGeoReady(const QString &address);
162
163     /**
164     * @brief Signal for requestLocationUpdate from SituareEngine
165     *
166     * @param status Status message
167     * @param publish Publish on Facebook
168     */
169     void statusUpdate(const QString &status, const bool &publish);
170
171     /**
172     * @brief Signal for use location ready.
173     *
174     * @param user User object
175     */
176     void userLocationReady(User *user);
177
178     /**
179     * @brief Signal for friend location ready.
180     *
181     * @param friendsList
182     */
183     void friendsLocationsReady(QList<User *> &friendsList);
184
185     /**
186     * @brief Signal for refreshing user data.
187     *
188     */
189     void refreshUserData();
190
191     /**
192     * @brief Signal for gps position.
193     *
194     * @param position longitude and latitude values
195     */
196     void positionReceived(QPointF position);
197
198     /**
199     * @brief Signal for gps enabling.
200     *
201     * @param enabled true if gps should be enabled
202     */
203     void enableGPS(bool enabled);
204
205     /**
206     * @brief Signal for map auto centering
207     *
208     * @param enabled true if map should auto center to gps location
209     */
210     void enableAutoCentering(bool enabled);
211
212 /*******************************************************************************
213  * DATA MEMBERS
214  ******************************************************************************/
215 private:
216     ListViewScreen *m_listViewScreen; ///< Instance of the list view
217     UpdateLocationDialog *m_locationDialog; ///< Message dialog
218     MapViewScreen *m_mapViewScreen; ///< Instance of the map view
219     QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
220     QAction *m_autoCenteringAct;    ///< Action to auto center map using gps position
221     QAction *m_gpsToggleAct;    ///< Action to trigger gps toggle
222     QAction *m_toListViewAct; ///< Action to trigger switch to list view
223     QAction *m_toMapViewAct; ///< Action to trigger switch to map view
224     QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
225     QMenu *m_viewMenu; ///< Object that hold the view menu items
226 };
227
228 #endif // MAINWINDOW_H