Merge branch 'master' of https://vcs.maemo.org/git/situare
authorlampehe-local <henri.lampela@ixonos.com>
Thu, 29 Apr 2010 09:22:44 +0000 (12:22 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Thu, 29 Apr 2010 09:22:44 +0000 (12:22 +0300)
Conflicts:
src/src.pro
src/ui/mainwindow.cpp

src/engine/engine.cpp [new file with mode: 0644]
src/engine/engine.h [new file with mode: 0644]
src/src.pro
src/ui/listviewscreen.cpp
src/ui/listviewscreen.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h

diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
new file mode 100644 (file)
index 0000000..e356fca
--- /dev/null
@@ -0,0 +1,68 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Kaj Wallin - kaj.wallin@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+#include "engine.h"
+
+SituareEngine::SituareEngine(QMainWindow *parent)
+    : QObject(parent)
+{
+    m_networkManager = new QNetworkAccessManager;
+    m_situareService = new SituareService(this,m_networkManager);
+
+    m_loggedIn = false;
+    m_facebookAuthenticator = new FacebookAuthentication();
+    connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOk()));
+    connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
+}
+
+SituareEngine::~SituareEngine()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void SituareEngine::start()
+{
+    m_facebookAuthenticator->start();
+}
+
+
+void SituareEngine::loginOk()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    m_loggedIn = true;
+    m_facebookAuthenticator->close();
+}
+void SituareEngine::loginScreenClosed()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+    if (m_loggedIn) {
+        emit engine_showMainWindow();
+        return;
+    }
+    else {
+        emit engine_closeMainWindow();
+    }
+}
+void SituareEngine::updateFriendsList()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    //code here
+}
diff --git a/src/engine/engine.h b/src/engine/engine.h
new file mode 100644 (file)
index 0000000..03d2cea
--- /dev/null
@@ -0,0 +1,102 @@
+ /*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Kaj Wallin - kaj.wallin@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+ */
+
+
+#ifndef ENGINE_H
+#define ENGINE_H
+
+#include <QWidget>
+#include <QtDebug>
+#include "facebookservice/facebookauthentication.h"
+#include "situareservice/situareservice.h"
+#include <QNetworkAccessManager>
+
+/**
+* @brief Engine class for Situare Application
+*
+* This class handles all the underlaying login of the Situare
+* application.
+*
+* @class SituareEngine engine.h "engine/engine.h"
+*/
+class SituareEngine : public QObject
+{
+    Q_OBJECT
+public:
+    /**
+    * @brief Constructor
+    *
+    * @param parent
+    */
+    SituareEngine(QMainWindow *parent = 0);
+
+    /**
+    * @brief Destructor
+    */
+    ~SituareEngine();
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Function to start engine component
+    */
+    void start();
+
+public slots:
+    /**
+    * @brief Slot to intercept signal from login screen closure
+    */
+    void loginScreenClosed();
+
+    /**
+    * @brief Slot to intercept signal from successful login
+    */
+    void loginOk();
+
+    void updateFriendsList();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Signal that is emitted when UI must be showed
+    */
+    void engine_showMainWindow();
+
+    /**
+    * @brief Signal that is emitted when UI must be closed
+    */
+    void engine_closeMainWindow();
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
+    QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
+    SituareService *m_situareService; ///< Instance of the situare server communication service
+    bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
+};
+
+#endif // ENGINE_H
index a8dd472..74ea089 100644 (file)
@@ -23,6 +23,7 @@ SOURCES += main.cpp \
     ui/infotab.cpp \
     ui/updatelocation/updatelocationdialog.cpp \
     ui/updatelocation/texteditautoresizer.cpp \
+    engine/engine.cpp \
     user/user.cpp \
     ui/settingsdialog.cpp
 HEADERS += ui/mainwindow.h \
@@ -44,6 +45,7 @@ HEADERS += ui/mainwindow.h \
     facebookservice/facebookcredentials.h \
     facebookservice/facebookauthentication.h \
     facebookservice/facebookcommon.h \
+    engine/engine.h \
     user/user.h \
     ui/settingsdialog.h
 QT += network \
index 3cb9347..43527b4 100644 (file)
@@ -42,7 +42,7 @@ ListViewScreen::ListViewScreen(QWidget *parent)
     m_personalInfo->setTime("1 hour ago");
     m_personalInfo->setAddress("Kiviharjunlenkki 1E, 91910 Oulu");
 
-    m_locationDialog = new UpdateLocationDialog(this);
+
     m_widgetProxy = new QGraphicsProxyWidget();
     m_widgetProxy->setWidget(m_personalInfo);
 
@@ -123,5 +123,5 @@ ListViewScreen::~ListViewScreen()
 void ListViewScreen::updateMessage()
 {
    qDebug() << __PRETTY_FUNCTION__;
-   m_locationDialog->exec();
+//   m_locationDialog->exec();
 }
index 2d746ab..b2cfc3d 100644 (file)
@@ -27,7 +27,7 @@
 #include <QtGui>
 #include "infotab.h"
 #include "pixmap.h"
-#include "updatelocation/updatelocationdialog.h"
+
 
 /**
 * @brief List View class. Used for displaying List of friends
@@ -62,9 +62,11 @@ public slots:
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
+public:
+    InfoTab *m_personalInfo;    ///< Personal info tab
+
 private:
     QVBoxLayout *m_vbox;    ///< Holds the graphics view
-    InfoTab *m_personalInfo;    ///< Personal info tab
     Pixmap *m_arrowbutton;    ///< Button which reveals/hides the info tab when pressed
     QGraphicsProxyWidget *m_widgetProxy; ///< Embeds InfoTab to graphics view
     QAbstractTransition *m_trans1;    ///< Animation transition from hidden state to visible
@@ -73,7 +75,6 @@ private:
     QPropertyAnimation *m_anim2;    ///< Animation for arrowbutton from hidden to visible
     QPropertyAnimation *m_anim3;    ///< Animation for infotab from visible to hidden
     QPropertyAnimation *m_anim4;    ///< Animation for arrowbutton from visible to hidden
-    UpdateLocationDialog *m_locationDialog; ///< Message dialog
 };
 
 #endif // LISTVIEWTAB_H
index 1560569..c1f8b11 100644 (file)
 #include "settingsdialog.h"
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
+#include "engine/engine.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
-    m_loggedIn = false;
+
     createViews();
     setCentralWidget(m_situareViews);
     createMenus();
     setWindowTitle(tr("List view"));
     this->hide();
 
-    m_facebookAuthenticator = new FacebookAuthentication(this);
-    connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
-    connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
-    m_facebookAuthenticator->start();
+    m_situareEngine = new SituareEngine(this);
+    connect(m_situareEngine, SIGNAL(engine_showMainWindow()), this, SLOT(show()));
+    connect(m_situareEngine, SIGNAL(engine_closeMainWindow()), this, SLOT(close()));
+
+    m_locationDialog = new UpdateLocationDialog(this);
+//    connect(m_listViewScreen->m_personalInfo,
+//            SIGNAL(launchUpdateFriendsStatus()),
+//            m_situareEngine,
+//            SLOT(updateFriendsList()));
+    connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
+            this,SLOT(openLocationUpdateDialog()));
 
-    m_networkManager = new QNetworkAccessManager;
-    m_situareService = new SituareService(this,m_networkManager);
+    m_situareEngine->start();
 }
 
 MainWindow::~MainWindow()
@@ -79,9 +86,12 @@ void MainWindow::createMenus()
 void MainWindow::createViews()
 {
     qDebug() << __PRETTY_FUNCTION__;
+    m_listViewScreen = new ListViewScreen(this);
+    m_mapViewScreen = new MapViewScreen(this);
+
     m_situareViews = new QStackedWidget;
-    m_situareViews->addWidget(new ListViewScreen);
-    m_situareViews->addWidget(new MapViewScreen);
+    m_situareViews->addWidget(m_listViewScreen);
+    m_situareViews->addWidget(m_mapViewScreen);
 }
 
 void MainWindow::toListView()
@@ -117,6 +127,12 @@ void MainWindow::switchView(int nextIndex)
     }
 }
 
+void MainWindow::openLocationUpdateDialog()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    m_locationDialog->exec();
+}
+
 void MainWindow::openSettingsDialog()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -124,21 +140,4 @@ void MainWindow::openSettingsDialog()
     dialog->show();
 }
 
-void MainWindow::loginScreenClosed()
-{
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    if (m_loggedIn) {
-        this->show();
-        return;
-    }
-    else {
-        this->close();
-    }
-}
 
-void MainWindow::loginOK()
-{
-    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
-    m_loggedIn = true;
-    m_facebookAuthenticator->close();
-}
index bd79de8..331d149 100644 (file)
 #include <QtGui/QMainWindow>
 #include <QWidget>
 #include <QDebug>
+#include <QObject>
 #include "facebookservice/facebookauthentication.h"
 #include "situareservice/situareservice.h"
 #include <QNetworkAccessManager>
+#include "engine/engine.h"
+#include "listviewscreen.h"
+#include "mapviewscreen.h"
+#include "updatelocation/updatelocationdialog.h"
 
 class QLabel;
 class QStackedWidget;
@@ -59,7 +64,6 @@ public:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-
 public slots:
     /**
     * @brief Public slot, which open settings dialog
@@ -90,36 +94,28 @@ private:
     /**
     * @brief Method used to switch active view.
     *
-    * @param nextIndex 0 for listview, 1 for mapview
+    * @paraDaily scrum 2010-03-26m nextIndex 0 for listview, 1 for mapview
     */
     void switchView(int);
 
 private slots:
-    /**
-    * @brief Slot to change value of m_loggedIn to true
-    */
-    void loginOK();
-
-    /**
-    * @brief Slot to check login status and exits if necessary
-    */
-    void loginScreenClosed();
-
+    void openLocationUpdateDialog();
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 
 private:
-    FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
-    QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
-    SituareService *m_situareService; ///< Instance of the situare server communication service
-    bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
+    SituareEngine *m_situareEngine;
+
+    ListViewScreen *m_listViewScreen;
+    MapViewScreen *m_mapViewScreen;
     QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
     QAction *m_toListViewAct; ///< Action to trigger switch to list view
     QAction *m_toMapViewAct; ///< Action to trigger switch to map view
     QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
     QMenu *m_viewMenu; ///< Object that hold the view menu items
 
+    UpdateLocationDialog *m_locationDialog; ///< Message dialog
 };
 
 #endif // MAINWINDOW_H