Merge branch 'new_panels' into locationlistview
[situare] / src / ui / mainwindow.cpp
index f8fc16a..2b7acce 100644 (file)
@@ -43,6 +43,7 @@
 #include "logindialog.h"
 #include "mapscale.h"
 #include "panelcommon.h"
+#include "routingpanel.h"
 #include "tabbedpanel.h"
 #include "searchdialog.h"
 #include "settingsdialog.h"
@@ -175,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()
@@ -317,18 +321,47 @@ void MainWindow::buildPanels()
 
     buildUserInfoPanel();
     buildFriendListPanel();
+    buildRoutingPanel();
 
     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_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)),
             m_tabbedPanel, SLOT(resizePanel(QSize)));
 }
 
+void MainWindow::buildRoutingPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_routingPanel = new RoutingPanel(this);
+
+    connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
+            m_routingPanel, SLOT(populateLocationListView(const QList<Location>&)));
+
+    connect(m_routingPanel,
+            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()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -345,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()));
@@ -450,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"));
 }