Merge branch 'new_panels' into locationlistview
[situare] / src / ui / mainwindow.cpp
index 570dc67..2b7acce 100644 (file)
    USA.
 */
 
-#include <QtGui>
-#include <QtWebKit>
+#include <QAction>
+#include <QApplication>
+#include <QMenuBar>
+#include <QMessageBox>
 #include <QtAlgorithms>
+#include <QtWebKit>
 
+///< @todo sort
 #include "facebookservice/facebookauthentication.h"
 #include "map/mapcommon.h"
 #include "map/mapview.h"
@@ -63,7 +67,7 @@ MainWindow::MainWindow(QWidget *parent)
       m_refresh(false),
       m_progressIndicatorCount(0),
       m_ownLocationCrosshair(0),
-      m_email(),
+      m_email(), ///< @todo WTF?!?!?!?
       m_password(),
       m_webView(0),
       m_fullScreenButton(0),
@@ -172,10 +176,13 @@ void MainWindow::buildFriendListPanel()
             m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
 
     connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
-            this, SIGNAL(findFriend(GeoCoordinate)));
+            this, SIGNAL(centerToCoordinates(GeoCoordinate)));
 
     connect(this, SIGNAL(friendImageReady(User*)),
             m_friendsListPanel, SLOT(friendImageReady(User*)));
+
+    connect(m_friendsListPanel, SIGNAL(routeToFriend(const GeoCoordinate&)),
+            this, SIGNAL(routeTo(const GeoCoordinate&)));
 }
 
 void MainWindow::buildIndicatorButtonPanel()
@@ -321,7 +328,7 @@ void MainWindow::buildPanels()
     m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png"));
     m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
 
-    connect(m_tabbedPanel, SIGNAL(tabChanged()),
+    connect(m_tabbedPanel, SIGNAL(panelClosed()),
             m_friendsListPanel, SLOT(clearFriendListFilter()));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
@@ -341,6 +348,18 @@ void MainWindow::buildRoutingPanel()
             SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
             this,
             SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+
+    connect(m_routingPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
+            this, SIGNAL(routeTo(const GeoCoordinate&)));
+
+    connect(this, SIGNAL(routeParsed(Route&)),
+            m_routingPanel, SLOT(setRoute(Route&)));
+
+    connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
+            this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+    connect(m_routingPanel, SIGNAL(requestSearchLocation()),
+            this, SLOT(startLocationSearch()));
 }
 
 void MainWindow::buildUserInfoPanel()
@@ -359,7 +378,7 @@ void MainWindow::buildUserInfoPanel()
             m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
 
     connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
-            this, SIGNAL(findUser(GeoCoordinate)));
+            this, SIGNAL(centerToCoordinates(GeoCoordinate)));
 
     connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
@@ -464,17 +483,11 @@ void MainWindow::createMenus()
     connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
             this, SIGNAL(gpsTriggered(bool)));
 
-    /// @todo remove when not needed!
-    m_searchLocationAct = new QAction(tr("Location search"), this);
-    connect(m_searchLocationAct, SIGNAL(triggered()),
-            this, SLOT(startLocationSearch()));
-
     // build the actual menu
     m_viewMenu = menuBar()->addMenu(tr("Main"));
     m_viewMenu->addAction(m_loginAct);
     m_viewMenu->addAction(m_toSettingsAct);
     m_viewMenu->addAction(m_gpsToggleAct);
-    m_viewMenu->addAction(m_searchLocationAct); /// @todo remove when not needed!
     m_viewMenu->setObjectName(tr("Menu"));
 }
 
@@ -527,9 +540,10 @@ void MainWindow::drawFullScreenButton(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
-    if(m_fullScreenButton)
+    if (m_fullScreenButton) {
         m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
                                  size.height() - m_fullScreenButton->size().height());
+    }
 }
 
 void MainWindow::drawMapScale(const QSize &size)
@@ -538,7 +552,6 @@ 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();
 
     m_mapScale->move(LEFT_SCALE_MARGIN,
                      size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
@@ -926,6 +939,8 @@ void MainWindow::showPanels()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+///< @todo check how this is called and can this method be removed
+
     drawFullScreenButton(m_viewPortSize);
 
 //    if(m_loggedIn) {
@@ -989,6 +1004,8 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+///< @todo can this be removed?
+
 //    if(!m_loggedIn) {
 //        m_friendsListPanel->closePanel();
 //        m_friendsListPanel->hide();