Merged and resolved conflicts.
authorKaj Wallin <kaj.wallin@ixonos.com>
Mon, 19 Apr 2010 12:17:36 +0000 (15:17 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Mon, 19 Apr 2010 12:17:36 +0000 (15:17 +0300)
Merge branch 'jskia73' into wallika-own

Conflicts:
src/ui/listviewscreen.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h

.gitignore
src/main.cpp
src/ui/listviewscreen.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/mapviewscreen.cpp
tests/ui/mainwindow/mainwindow_test.cpp [new file with mode: 0644]
tests/ui/mainwindow/mainwindow_test.pro [new file with mode: 0644]

index 37bdac3..182612d 100644 (file)
@@ -15,4 +15,4 @@ Situare
 *.orig
 doc/doxygen/*
 situare
-testtabs
+mainwindow_test
index c00d5ee..5c1a1d4 100644 (file)
@@ -27,5 +27,6 @@ int main(int argc, char *argv[])
     QApplication a(argc, argv);
     MainWindow w;
     w.show();
-    return a.exec();
+    int appRet = a.exec();
+    return appRet;
 }
index 1123488..8e62d0a 100644 (file)
@@ -32,6 +32,7 @@
 ListViewScreen::ListViewScreen(QWidget *parent)
     : QWidget(parent)
 {
+
     m_arrowbutton = new Pixmap(QPixmap(":/resources/arrow_right.png"));
 
     m_personalInfo = new InfoTab;
index b6c02e1..3db3a74 100644 (file)
 #include "mainwindow.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
+//#include "facebookservice/facebookauthentication.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
+    m_loggedIn = false;
     createViews();
-    setCentralWidget(situareViews);
+    setCentralWidget(m_situareViews);
     createMenus();
-    setWindowTitle(tr("View"));
+    setWindowTitle(tr("List view"));
+    this->show();
+
+/*
+    FBAuth = new FacebookAuthentication(this);
+    FBAuth->show();
+    FBAuth->start();
+
+    connect(FBAuth, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
+    connect(FBAuth, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
+*/
+/*
+    connect(this,SIGNAL(testLoginClosed()), this, SLOT(loginScreenClosed()));
+*/
 }
 
 MainWindow::~MainWindow()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    delete toListViewAct;
-    delete toMapViewAct;
-    delete situareViews;
+    delete m_toListViewAct;
+    delete m_toMapViewAct;
+    delete m_situareViews;
 }
 
 void MainWindow::createMenus()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    toListViewAct = new QAction(tr("List"), this);
-    connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
-    toMapViewAct = new QAction(tr("Map"), this);
-    connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
-    viewMenu = menuBar()->addMenu(tr("View"));
-    viewMenu->addAction(toListViewAct);
-    viewMenu->addAction(toMapViewAct);
+    m_toListViewAct = new QAction(tr("List"), this);
+    m_toListViewAct->setObjectName(tr("List"));
+    connect(m_toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
+    m_toMapViewAct = new QAction(tr("Map"), this);
+    m_toMapViewAct->setObjectName(tr("Map"));
+    connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
+    m_viewMenu = menuBar()->addMenu(tr("View"));
+    m_viewMenu->addAction(m_toListViewAct);
+    m_viewMenu->addAction(m_toMapViewAct);
+    m_viewMenu->setObjectName(tr("View Menu"));
+
 }
 
 void MainWindow::createViews()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    situareViews = new QStackedWidget;
-    situareViews->addWidget(new ListViewScreen);
-    situareViews->addWidget(new MapViewScreen);
+    m_situareViews = new QStackedWidget;
+    m_situareViews->addWidget(new ListViewScreen);
+    m_situareViews->addWidget(new MapViewScreen);
 }
 
 void MainWindow::toListView()
@@ -79,24 +98,38 @@ void MainWindow::switchView(int nextIndex)
 {
     qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
     if (nextIndex < 0 || nextIndex > 1) {
-        qDebug() << tr("Illegal parameter value in MainWindow::switchView");
+        qDebug() << "Illegal parameter value in MainWindow::switchView";
         return;
     }
-    situareViews->setCurrentIndex(nextIndex);
-    switch (situareViews->currentIndex()) {
+    m_situareViews->setCurrentIndex(nextIndex);
+    switch (m_situareViews->currentIndex()) {
         case 0:
-            setWindowTitle(tr("List"));
+            setWindowTitle(tr("List view"));
             break;
         case 1:
-            setWindowTitle(tr("Map"));
+            setWindowTitle(tr("Map view"));
             break;
         default:
-            qDebug() << tr("Illegal switch value in MainWindow::switchView");
+            qDebug() << "Illegal switch value in MainWindow::switchView";
             break;
     }
 }
 
-int MainWindow::getViewIndex()
+void MainWindow::loginScreenClosed()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+    if (m_loggedIn) {
+        //this->show();
+        return;
+    }
+    else {
+        this->close();
+    }
+}
+
+void MainWindow::loginOK()
 {
-    return situareViews->currentIndex();
+    qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+    m_loggedIn = true;
+    //FBAuth->close();
 }
index 4377605..1920749 100644 (file)
 #include <QtGui/QMainWindow>
 #include <QWidget>
 #include <QDebug>
+//#include "facebookservice/facebookauthentication.h"
 
 class QLabel;
 class QStackedWidget;
 
 /**
-* @Main Window Class
+* @brief Main Window Class
 *
 * @class MainWindow mainwindow.h "src/ui/mainwindow.h"
 */
@@ -41,72 +42,70 @@ class MainWindow : public QMainWindow
     Q_OBJECT
 
 public:
+    /**
+    * @brief Constructor
+    *
+    * @param parent Parent
+    */
     MainWindow(QWidget *parent = 0);
-    ~MainWindow();
 
     /**
-    * @brief Public method to get current index of the view. Used for Unit testing
-    *
-    * @fn getViewIndex
+    * @brief Destructor
     */
-    int getViewIndex();
+    ~MainWindow();
 
-private:
+public slots:
     /**
-    * @brief Private method to create List and Map views as a stacked widget
-    *
-    * @fn createViews
+    * @brief Public slot, which initiates toListViewAct action to switch view
     */
-    void createViews();
+    void toListView();
+
     /**
-    * @brief Widget Stack object for the List and Map Views
-    *
-    * @var situareViews
+    * @brief Public slot, which initiates toMapViewAct action to switch view
     */
-    QStackedWidget *situareViews;
+    void toMapView();
 
+private:
     /**
     * @brief Private method to create the Menu items
-    *
-    * @fn createMenus
     */
     void createMenus();
-    QMenu *viewMenu;
 
     /**
-    * @brief Action item for changing view to List View
-    *
-    * @var toListViewAct
-    */
-    QAction *toListViewAct;
-    /**
-    * @brief Action item for changing view to Map View
-    *
-    * @var toMapViewAct
+    * @brief Private method to create List and Map views as a stacked widget
     */
-    QAction *toMapViewAct;
+    void createViews();
 
     /**
     * @brief Method used to switch active view.
     *
-    * @fn switchView
-    * @param int 0 for listview, 1 for mapview
+    * @param nextIndex 0 for listview, 1 for mapview
     */
     void switchView(int);
 
-public slots:
+private:
+    bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
+    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
+    QMenu *m_viewMenu; ///< Object that hold the view menu items
+
+    QAction *m_openUpdateDialog; ///< DUMMY item used to launch location update dialog
+private slots:
     /**
-    * @brief Public slot, which initiates toListViewAct action to switch view
-    *
-    * @fn toListView
+    * @brief Slot to change value of m_loggedIn to true
     */
-    void toListView();
+    void loginOK();
+
     /**
-    * @brief Public slot, which initiates toMapViewAct action to switch view
-    *
-    * @fn toMapView
+    * @brief Slot to check login status and exits if necessary
     */
-    void toMapView();
+    void loginScreenClosed();
+
+    /**
+    * @brief DUMMY slot to open update location dialog
+    */
+    void openUpdateDialog();
 };
 
 #endif // MAINWINDOW_H
index 1bd35eb..d5bfd08 100644 (file)
@@ -36,4 +36,5 @@ MapViewScreen::MapViewScreen(QWidget *parent)
    mapView->setScene(mapEngine->scene());
    connect(mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int)));
    mapEngine->setViewLocation(QPointF(25.5000, 65.0000));
+   setObjectName(tr("Map view"));
 }
diff --git a/tests/ui/mainwindow/mainwindow_test.cpp b/tests/ui/mainwindow/mainwindow_test.cpp
new file mode 100644 (file)
index 0000000..5bff78e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+   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 <QtTest/QtTest>
+#include <QtCore>
+#include <QtGui>
+
+#include "ui/mapviewscreen.h"
+#include "ui/listviewscreen.h"
+#include "ui/mainwindow.h"
+//#include "facebook_service/fbauthentication/fbauthentication.h"
+
+class testMainWindow : public QObject
+{
+    Q_OBJECT
+private slots:
+    void testViewSwitch();
+    void verifyStackItems();
+//    void verifyMenuItems();  //NON-WORKING
+};
+
+void testMainWindow::testViewSwitch()
+{
+    MainWindow mainwindow;
+    QStackedWidget *m_testStack = dynamic_cast<QStackedWidget*>(mainwindow.centralWidget());
+    mainwindow.toListView();
+    QCOMPARE(m_testStack->currentIndex(), 0);
+    QCOMPARE(mainwindow.windowTitle(),QString(tr("List view")));
+    mainwindow.toMapView();
+    QCOMPARE(m_testStack->currentIndex(), 1);
+    QCOMPARE(mainwindow.windowTitle(),QString(tr("Map view")));
+    mainwindow.toMapView();
+    QCOMPARE(m_testStack->currentIndex(), 1);
+    QCOMPARE(mainwindow.windowTitle(),QString(tr("Map view")));
+    mainwindow.toListView();
+    QCOMPARE(m_testStack->currentIndex(), 0);
+    QCOMPARE(mainwindow.windowTitle(),QString(tr("List view")));
+}
+void testMainWindow::verifyStackItems()
+{
+    MainWindow mainwindow;
+    QStackedWidget *m_testStack = dynamic_cast<QStackedWidget*>(mainwindow.centralWidget());
+    QCOMPARE(m_testStack->count(), 2);
+    QCOMPARE(m_testStack->widget(0)->objectName(),QString(tr("List view")));
+    QCOMPARE(m_testStack->widget(1)->objectName(),QString(tr("Map view")));
+}
+
+/* NON-WORKING TEST
+void testMainWindow::verifyMenuItems()
+{
+    MainWindow mainwindow;
+    QWidget *m_testMenu = mainwindow.menuWidget();
+    qDebug() << m_testMenu->actions();
+}
+*/
+
+QTEST_MAIN(testMainWindow)
+#include "mainwindow_test.moc"
diff --git a/tests/ui/mainwindow/mainwindow_test.pro b/tests/ui/mainwindow/mainwindow_test.pro
new file mode 100644 (file)
index 0000000..2801d54
--- /dev/null
@@ -0,0 +1,26 @@
+CONFIG += qtestlib
+TEMPLATE = app
+TARGET = mainwindow_test
+DEPENDPATH += .
+INCLUDEPATH += . \
+    ../../../src/
+SOURCES += mainwindow_test.cpp \
+    ../../../src/map/mapview.cpp \
+    ../../../src/map/maptile.cpp \
+    ../../../src/map/mapscene.cpp \
+    ../../../src/map/mapfetcher.cpp \
+    ../../../src/map/mapengine.cpp \
+    ../../../src/ui/mapviewscreen.cpp \
+    ../../../src/ui/mainwindow.cpp \
+    ../../../src/ui/listviewscreen.cpp
+HEADERS += ../../../src/map/mapview.h \
+    ../../../src/map/maptile.h \
+    ../../../src/map/mapscene.h \
+    ../../../src/map/mapfetcher.h \
+    ../../../src/map/mapengine.h \
+    ../../../src/ui/mapviewscreen.h \
+    ../../../src/ui/mainwindow.h \
+    ../../../src/ui/listviewscreen.h
+
+QT += webkit \
+    network