Removed extra files related to listviewscreen
[situare] / src / ui / mainwindow.cpp
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       Jussi Laitinen jussi.laitinen@ixonos.com
8
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.
12
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.
17
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,
21    USA.
22 */
23
24 #include <QtGui>
25 #include "mainwindow.h"
26 #include "mapviewscreen.h"
27 #include "settingsdialog.h"
28 #include "facebookservice/facebookauthentication.h"
29 #include "situareservice/situareservice.h"
30
31 MainWindow::MainWindow(QWidget *parent)
32     : QMainWindow(parent)
33 {
34     qDebug() << __PRETTY_FUNCTION__;
35
36     m_mapViewScreen = new MapViewScreen(this);
37     setCentralWidget(m_mapViewScreen);
38     createMenus();
39     setWindowTitle(tr("Situare"));
40     hide();
41
42     m_locationDialog = new UpdateLocationDialog(this);
43
44     connect(this, SIGNAL(reverseGeoReady(QString)),
45             m_locationDialog, SLOT(setAddress(QString)));
46     connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
47             SIGNAL(statusUpdate(QString,bool)));
48
49     connect(this, SIGNAL(userLocationReady(User*)),
50             m_mapViewScreen, SLOT(userLocationReady(User*)));
51     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
52             m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
53
54     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
55             m_mapViewScreen, SIGNAL(SIG_friendsLocationsReady(QList<User*>&)));
56
57     toggleProgressIndicator(true);
58 }
59
60 void MainWindow::toggleProgressIndicator(bool value)
61 {
62     qDebug() << __PRETTY_FUNCTION__;
63 #ifdef Q_WS_MAEMO_5
64     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
65 #else
66     Q_UNUSED(value);
67 #endif // Q_WS_MAEMO_5
68 }
69
70 void MainWindow::createMenus()
71 {
72     qDebug() << __PRETTY_FUNCTION__;
73     m_toSettingsAct = new QAction(tr("Settings"), this);
74     m_toSettingsAct->setObjectName(tr("Settings"));
75     connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
76     m_viewMenu = menuBar()->addMenu(tr("Main"));
77
78     m_viewMenu->addAction(m_toSettingsAct);
79     m_viewMenu->setObjectName(tr("Menu"));
80 }
81
82 void MainWindow::openLocationUpdateDialog()
83 {
84     qDebug() << __PRETTY_FUNCTION__;
85
86     emit requestReverseGeo();
87     m_locationDialog->exec();
88 }
89
90 void MainWindow::openSettingsDialog()
91 {
92     qDebug() << __PRETTY_FUNCTION__;
93     SettingsDialog *dialog = new SettingsDialog(this);
94     dialog->show();
95 }