Merge branch 'master' into new_panels
[situare] / src / ui / mainwindow.cpp
index dce7243..446e952 100644 (file)
@@ -4,7 +4,7 @@
 
       Henri Lampela - henri.lampela@ixonos.com
       Kaj Wallin - kaj.wallin@ixonos.com
-      Jussi Laitinen jussi.laitinen@ixonos.com
+      Jussi Laitinen - jussi.laitinen@ixonos.com
       Sami Rämö - sami.ramo@ixonos.com
       Ville Tiensuu - ville.tiensuu@ixonos.com
       Katri Kaikkonen - katri.kaikkonen@ixonos.com
@@ -37,6 +37,8 @@
 #include "fullscreenbutton.h"
 #include "logindialog.h"
 #include "mapscale.h"
+#include "panelcommon.h"
+#include "tabbedpanel.h"
 #include "searchdialog.h"
 #include "settingsdialog.h"
 #include "userinfopanel.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent),
-    m_errorShown(false),
-    m_loggedIn(false),
-    m_refresh(false),
-    m_progressIndicatorCount(0),
-    m_ownLocationCrosshair(0),
-    m_email(),
-    m_password(),
-    m_webView(0),
-    m_fullScreenButton(0),
-    m_indicatorButtonPanel(0),
-    m_mapScale(0),
-    m_cookieJar(0)
+      m_errorShown(false),
+      m_loggedIn(false),
+      m_refresh(false),
+      m_progressIndicatorCount(0),
+      m_ownLocationCrosshair(0),
+      m_email(),
+      m_password(),
+      m_webView(0),
+      m_fullScreenButton(0),
+      m_indicatorButton(0),
+      m_mapScale(0),
+      m_cookieJar(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -81,14 +83,13 @@ MainWindow::MainWindow(QWidget *parent)
     setCentralWidget(new QWidget());
     centralWidget()->setLayout(layout);
 
-    buildFriendListPanel();
-    buildUserInfoPanel();
+    buildPanels();
 
     createMenus();
     setWindowTitle(tr("Situare"));
 
     // set stacking order of widgets
-    m_zoomButtonPanel->stackUnder(m_userPanel);
+    m_zoomButtonPanel->stackUnder(m_tabbedPanel);
     if(m_fullScreenButton) {
         m_fullScreenButton->stackUnder(m_zoomButtonPanel);
         m_osmLicense->stackUnder(m_fullScreenButton);
@@ -156,22 +157,12 @@ void MainWindow::buildFriendListPanel()
 
     m_friendsListPanel = new FriendListPanel(this);
 
-    m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
-
-    m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
-
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
 
     connect(this, SIGNAL(locationItemClicked(QList<QString>)),
             m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
 
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_friendsListPanel, SLOT(resizePanel(QSize)));
-
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_friendsListPanelSidebar, SLOT(resizeSideBar(QSize)));
-
     connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
             this, SIGNAL(findFriend(GeoCoordinate)));
 
@@ -309,45 +300,52 @@ void MainWindow::buildOsmLicense()
             this, SLOT(drawOsmLicense(QSize)));
 }
 
-void MainWindow::buildUserInfoPanel()
+void MainWindow::buildPanels()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_userPanel = new UserInfoPanel(this);
+    buildUserInfoPanel();
+    buildFriendListPanel();
 
-    m_userPanelSidebar = new PanelSideBar(this, LEFT);
+    m_tabbedPanel = new TabbedPanel(this);
+    m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"));
+    m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"));
 
-    m_userPanelSidebar->stackUnder(m_friendsListPanel);
-    m_userPanel->stackUnder(m_userPanelSidebar);
+    connect(m_tabbedPanel, SIGNAL(panelOpened()),
+            m_friendsListPanel, SLOT(clearFriendListFilter()));
+
+    connect(m_mapView, SIGNAL(viewResized(QSize)),
+            m_tabbedPanel, SLOT(resizePanel(QSize)));
+}
+
+void MainWindow::buildUserInfoPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_userInfoPanel = new UserInfoPanel(this);
 
     connect(this, SIGNAL(userLocationReady(User*)),
-            m_userPanel, SLOT(userDataReceived(User*)));
+            m_userInfoPanel, SLOT(userDataReceived(User*)));
 
     connect(this, SIGNAL(reverseGeoReady(QString)),
-            m_userPanel, SIGNAL(reverseGeoReady(QString)));
+            m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
 
     connect(this, SIGNAL(clearUpdateLocationDialogData()),
-            m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
-
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_userPanel, SLOT(resizePanel(QSize)));
+            m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
 
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_userPanelSidebar, SLOT(resizeSideBar(QSize)));
-
-    connect(m_userPanel, SIGNAL(findUser(GeoCoordinate)),
+    connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
             this, SIGNAL(findUser(GeoCoordinate)));
 
-    connect(m_userPanel, SIGNAL(requestReverseGeo()),
+    connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
 
-    connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
+    connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
             this, SIGNAL(statusUpdate(QString,bool)));
 
-    connect(m_userPanel, SIGNAL(refreshUserData()),
+    connect(m_userInfoPanel, SIGNAL(refreshUserData()),
             this, SIGNAL(refreshUserData()));
 
-    connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
+    connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
             this, SLOT(buildInformationBox(QString, bool)));
 }
 
@@ -504,16 +502,9 @@ void MainWindow::drawFullScreenButton(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
-    if(m_fullScreenButton) {
-        if(m_loggedIn) {
-            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
-                                     - PANEL_PEEK_AMOUNT,
-                                     size.height() - m_fullScreenButton->size().height());
-        } else {
-            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
-                                     size.height() - m_fullScreenButton->size().height());
-        }
-    }
+    if(m_fullScreenButton)
+        m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
+                                 size.height() - m_fullScreenButton->size().height());
 }
 
 void MainWindow::drawMapScale(const QSize &size)
@@ -522,9 +513,9 @@ void MainWindow::drawMapScale(const QSize &size)
 
     const int LEFT_SCALE_MARGIN = 10;
     const int BOTTOM_SCALE_MARGIN = 2;
-    qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
+//    qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
-    m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
+    m_mapScale->move(LEFT_SCALE_MARGIN,
                      size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
 }
 
@@ -533,7 +524,7 @@ void MainWindow::drawOsmLicense(const QSize &size)
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
     m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
-                       - PANEL_PEEK_AMOUNT,
+                       - PANEL_BAR_WIDTH,
                        size.height() - m_osmLicense->fontMetrics().height());
 }
 
@@ -912,17 +903,17 @@ void MainWindow::showPanels()
 
     drawFullScreenButton(m_viewPortSize);
 
-    if(m_loggedIn) {
-        if(!m_friendsListPanel->isVisible()) {
-            m_friendsListPanel->show();
-            m_friendsListPanelSidebar->show();
-        }
+//    if(m_loggedIn) {
+//        if(!m_friendsListPanel->isVisible()) {
+//            m_friendsListPanel->show();
+//            m_friendsListPanelSidebar->show();
+//        }
 
-        if(!m_userPanel->isVisible()) {
-            m_userPanel->show();
-            m_userPanelSidebar->show();
-        }
-    }
+//        if(!m_userPanel->isVisible()) {
+//            m_userPanel->show();
+//            m_userPanelSidebar->show();
+//        }
+//    }
 }
 
 void MainWindow::startLocationSearch()
@@ -973,14 +964,15 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(!m_loggedIn) {
-        m_friendsListPanel->closePanel();
-        m_friendsListPanel->hide();
-        m_friendsListPanelSidebar->hide();
-        m_userPanel->closePanel();
-        m_userPanel->hide();
-        m_userPanelSidebar->hide();
-    }
+//    if(!m_loggedIn) {
+//        m_friendsListPanel->closePanel();
+//        m_friendsListPanel->hide();
+//        m_friendsListPanelSidebar->hide();
+
+//        m_userPanel->closePanel();
+//        m_userPanel->hide();
+//        m_userPanelSidebar->hide();
+//    }
 }
 
 const QString MainWindow::username()