2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Jussi Laitinen jussi.laitinen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare 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
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "mainwindow.h"
26 #include "listviewscreen.h"
27 #include "mapviewscreen.h"
28 #include "settingsdialog.h"
29 #include "facebookservice/facebookauthentication.h"
30 #include "situareservice/situareservice.h"
32 MainWindow::MainWindow(QWidget *parent)
35 qDebug() << __PRETTY_FUNCTION__;
38 setCentralWidget(m_situareViews);
40 setWindowTitle(tr("List view"));
43 m_locationDialog = new UpdateLocationDialog(this);
44 connect(m_listViewScreen,SIGNAL(launchUpdateDialog()),
45 this,SLOT(openLocationUpdateDialog()));
47 connect(this, SIGNAL(reverseGeoReady(QString)),
48 m_locationDialog, SLOT(setAddress(QString)));
49 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
50 SIGNAL(statusUpdate(QString,bool)));
52 connect(this, SIGNAL(userLocationReady(User*)),
53 m_mapViewScreen, SLOT(userLocationReady(User*)));
54 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
55 m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
57 connect(this, SIGNAL(userLocationReady(User*)),
58 m_listViewScreen, SLOT(userDataReceived(User*)));
59 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
60 m_listViewScreen, SLOT(friendInfoReceived(QList<User*>&)));
61 connect(m_listViewScreen, SIGNAL(updateFriendsData()),
62 this, SIGNAL(refreshUserData()));
64 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
65 m_mapViewScreen, SIGNAL(SIG_friendsLocationsReady(QList<User*>&)));
67 this->toggleProgressIndicator(true);
70 MainWindow::~MainWindow()
72 qDebug() << __PRETTY_FUNCTION__;
73 delete m_toListViewAct;
74 delete m_toMapViewAct;
75 delete m_toSettingsAct;
76 delete m_situareViews;
79 void MainWindow::toggleProgressIndicator(bool value)
81 qDebug() << __PRETTY_FUNCTION__;
83 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
86 #endif // Q_WS_MAEMO_5
89 void MainWindow::createMenus()
91 qDebug() << __PRETTY_FUNCTION__;
92 m_toListViewAct = new QAction(tr("List"), this);
93 m_toListViewAct->setObjectName(tr("List"));
94 connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
95 m_toMapViewAct = new QAction(tr("Map"), this);
96 m_toMapViewAct->setObjectName(tr("Map"));
97 connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
98 m_toSettingsAct = new QAction(tr("Settings"), this);
99 m_toSettingsAct->setObjectName(tr("Settings"));
100 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
101 m_viewMenu = menuBar()->addMenu(tr("View"));
102 m_viewMenu->addAction(m_toListViewAct);
103 m_viewMenu->addAction(m_toMapViewAct);
104 m_viewMenu->addAction(m_toSettingsAct);
105 m_viewMenu->setObjectName(tr("View Menu"));
108 void MainWindow::createViews()
110 qDebug() << __PRETTY_FUNCTION__;
111 m_listViewScreen = new ListViewScreen(this);
112 m_mapViewScreen = new MapViewScreen(this);
114 m_situareViews = new QStackedWidget;
115 m_situareViews->addWidget(m_listViewScreen);
116 m_situareViews->addWidget(m_mapViewScreen);
119 void MainWindow::toListView()
121 qDebug() << __PRETTY_FUNCTION__;
125 void MainWindow::toMapView()
127 qDebug() << __PRETTY_FUNCTION__;
131 void MainWindow::switchView(int nextIndex)
133 qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
134 if (nextIndex < 0 || nextIndex > 1) {
135 qDebug() << "Illegal parameter value in MainWindow::switchView";
138 m_situareViews->setCurrentIndex(nextIndex);
139 switch (m_situareViews->currentIndex()) {
141 setWindowTitle(tr("List view"));
144 setWindowTitle(tr("Map view"));
147 qDebug() << "Illegal switch value in MainWindow::switchView";
152 void MainWindow::openLocationUpdateDialog()
154 qDebug() << __PRETTY_FUNCTION__;
156 emit requestReverseGeo();
157 m_locationDialog->exec();
160 void MainWindow::openSettingsDialog()
162 qDebug() << __PRETTY_FUNCTION__;
163 SettingsDialog *dialog = new SettingsDialog(this);