Added RoutingPanel class and connected signals from/to panel.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 11 Aug 2010 09:16:37 +0000 (12:16 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 11 Aug 2010 09:16:37 +0000 (12:16 +0300)
src/engine/engine.cpp
src/map/mapengine.cpp
src/map/mapengine.h
src/src.pro
src/ui/listview.cpp
src/ui/listview.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/routingpanel.cpp [new file with mode: 0644]
src/ui/routingpanel.h [new file with mode: 0644]

index 1590cb9..a05ccfc 100644 (file)
@@ -651,8 +651,9 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(findFriend(GeoCoordinate)),
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
+    // signals from routing tab
     connect(m_ui, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
-            m_mapEngine, SLOT(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+            m_mapEngine, SLOT(showMapArea(GeoCoordinate&,GeoCoordinate&)));
 
     // signals from distence indicator button
     connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
index 1d89aa3..be0648f 100644 (file)
@@ -300,17 +300,6 @@ bool MapEngine::isCenterTileChanged(SceneCoordinate coordinate)
     return (centerTile != temp);
 }
 
-void MapEngine::locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QRect area;
-    area.setTopRight(SceneCoordinate(neBound).toPointF().toPoint());
-    area.setBottomLeft(SceneCoordinate(swBound).toPointF().toPoint());
-
-    centerAndZoomTo(area, false);
-}
-
 void MapEngine::mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -495,6 +484,17 @@ void MapEngine::setTilesGridSize(const QSize &viewSize)
     m_tilesGridSize.setWidth(gridWidth);
 }
 
+void MapEngine::showMapArea(GeoCoordinate &swBound, GeoCoordinate &neBound)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QRect area;
+    area.setTopRight(SceneCoordinate(neBound).toPointF().toPoint());
+    area.setBottomLeft(SceneCoordinate(swBound).toPointF().toPoint());
+
+    centerAndZoomTo(area, false);
+}
+
 void MapEngine::updateViewTilesSceneRect()
 {
     qDebug() << __PRETTY_FUNCTION__;
index b498ac2..f60a9bf 100644 (file)
@@ -269,15 +269,6 @@ private slots:
     void gpsPositionUpdate(GeoCoordinate position, qreal accuracy);
 
     /**
-    * @brief Called when location item is clicked.
-    *
-    * Calls centerAndZoomTo() with bounds.
-    * @param swBound south-west bound of location item
-    * @param neBound north-east bound of location item
-    */
-    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
-
-    /**
      * @brief Slot for received map tile images
      *
      * Does receive map tile images from MapFetcher. Calls MapScene::addTile() for creating and adding
@@ -325,6 +316,15 @@ private slots:
     void setRoute(Route &route);
 
     /**
+    * @brief Shows map area defined by bounds.
+    *
+    * Calls centerAndZoomTo() with area defined by bounds.
+    * @param swBound south-west bound of location item
+    * @param neBound north-east bound of location item
+    */
+    void showMapArea(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
+    /**
      * @brief Slot for actions after view zoom is finished
      *
      * Does run removeOutOfViewTiles
index 2978f35..ae1a7bf 100644 (file)
@@ -74,7 +74,8 @@ SOURCES += main.cpp \
     ui/panelbar.cpp \
     ui/panelcontent.cpp \
     ui/panelbase.cpp \
-    user/user.cpp
+    user/user.cpp \
+    ui/routingpanel.cpp
 HEADERS += application.h \
     common.h \
     engine/engine.h \
@@ -151,7 +152,8 @@ HEADERS += application.h \
     ui/tabbedpanel.h \
     ui/panelbar.h \
     ui/panelcontent.h \
-    ui/panelbase.h
+    ui/panelbase.h \
+    ui/routingpanel.h
 QT += network \
     webkit
 
index 051f17c..b6f2d20 100644 (file)
@@ -151,8 +151,6 @@ void ListView::listItemClicked(QListWidgetItem *item)
     }
 }
 
-
-
 ListItem *ListView::listItem(const QString &itemID)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -160,6 +158,25 @@ ListItem *ListView::listItem(const QString &itemID)
     return dynamic_cast<ListItem*>(m_listItems.value(itemID));
 }
 
+ListItem *ListView::listItemAt(int index)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QHashIterator<QString, ListItem*> itemIterator(m_listItems);
+    ListItem *item = 0;
+    int counter = 0;
+
+    while (itemIterator.hasNext()) {
+        itemIterator.next();
+        if (index == counter) {
+            item = itemIterator.value();
+            break;
+        }
+        counter++;
+    }
+
+    return item;
+}
 
 ListView::~ListView()
 {
index 8e98a4b..7288728 100644 (file)
@@ -138,6 +138,14 @@ public:
     */
     ListItem *listItem(const QString &itemID);
 
+    /**
+    * @brief Returns ListItem by index.
+    *
+    * @param index item's index
+    * @return ListItem
+    */
+    ListItem *listItemAt(int index);
+
 protected slots:
     /**
     * @brief Slot for list item clicked.
index 2cd5ed9..f30bdca 100644 (file)
@@ -38,6 +38,7 @@
 #include "logindialog.h"
 #include "mapscale.h"
 #include "panelcommon.h"
+#include "routingpanel.h"
 #include "tabbedpanel.h"
 #include "searchdialog.h"
 #include "settingsdialog.h"
@@ -302,15 +303,30 @@ 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_mapView, SIGNAL(viewResized(QSize)),
             m_tabbedPanel, SLOT(resizePanel(QSize)));
 }
 
+void MainWindow::buildRoutingPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_routingPanel = new RoutingPanel(this);
+
+    connect(this, SIGNAL(locationDataParsed(QList<Location>&)),
+            m_routingPanel, SLOT(populateLocationListView(QList<Location>&)));
+
+    connect(m_routingPanel, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
+            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+}
+
 void MainWindow::buildUserInfoPanel()
 {
     qDebug() << __PRETTY_FUNCTION__;
index 5113967..32cf580 100644 (file)
@@ -46,6 +46,7 @@ class GeoCoordinate;
 class MapScale;
 class MapScene;
 class MapView;
+class RoutingPanel;
 class TabbedPanel;
 class SettingsDialog;
 class SceneCoordinate;
@@ -256,6 +257,11 @@ private:
     void buildPanels();
 
     /**
+     * @brief Build routing panel and connect slots
+     */
+    void buildRoutingPanel();
+
+    /**
      * @brief Build user info panel and connect slots
      */
     void buildUserInfoPanel();
@@ -667,6 +673,7 @@ private:
     MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
     NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
+    RoutingPanel *m_routingPanel;           ///< Instance of routing panel
     TabbedPanel *m_tabbedPanel;             ///< Widget for tabbed panels
     UserInfoPanel *m_userInfoPanel;         ///< Instance of the user information panel
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
diff --git a/src/ui/routingpanel.cpp b/src/ui/routingpanel.cpp
new file mode 100644 (file)
index 0000000..1144145
--- /dev/null
@@ -0,0 +1,47 @@
+#include "coordinates/geocoordinate.h"
+#include "locationlistitem.h"
+#include "locationlistview.h"
+#include "extendedlistitemdelegate.h"
+#include "routing/location.h"
+#include "panelcommon.h"
+
+#include "routingpanel.h"
+
+RoutingPanel::RoutingPanel(QWidget *parent)
+    : QWidget(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QVBoxLayout *routingLayout = new QVBoxLayout;
+    routingLayout->setContentsMargins(PANEL_MARGIN_LEFT, 0, PANEL_MARGIN_RIGHT, 0);
+    setLayout(routingLayout);
+
+    m_locationListView = new LocationListView(this);
+    m_locationListView->setItemDelegate(new ExtendedListItemDelegate(this));
+    routingLayout->addWidget(m_locationListView);
+
+    connect(m_locationListView, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)),
+            this, SIGNAL(locationItemClicked(GeoCoordinate&,GeoCoordinate&)));
+}
+
+void RoutingPanel::populateLocationListView(QList<Location> &locations)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_locationListView->clearList();
+
+    for (int i = 0; i < locations.size(); ++i) {
+        LocationListItem *item = new LocationListItem();
+        item->setLocationData(locations.at(i));
+        m_locationListView->addListItem(QString::number(i), item);
+    }
+
+    //openPanel();
+
+    if (locations.size() == 1) {
+        ListItem *item = m_locationListView->listItemAt(0);
+
+        if (item)
+            m_locationListView->listItemClicked(item);
+    }
+}
diff --git a/src/ui/routingpanel.h b/src/ui/routingpanel.h
new file mode 100644 (file)
index 0000000..73cb03f
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Jussi Laitinen - jussi.laitinen@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 ROUTINGPANEL_H
+#define ROUTINGPANEL_H
+
+#include <QtGui>
+
+class ExtendedListItemDelegate;
+class GeoCoordinate;
+class LocationListView;
+class Location;
+
+/**
+ * @brief Class for sliding routing panel
+ *
+ * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ */
+class RoutingPanel : public QWidget
+{
+    Q_OBJECT
+
+public:
+    /**
+     * @brief Default constructor
+     *
+     * @param parent
+     */
+    RoutingPanel(QWidget *parent = 0);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+private slots:
+    /**
+    * @brief Populates location list view.
+    *
+    * @param result list of Location objects
+    */
+    void populateLocationListView(QList<Location> &locations);
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Signal for location item clicked.
+    *
+    * @param swBound south-west bound GeoCoordinate
+    * @param neBound north-east bound GeoCoordinate
+    */
+    void locationItemClicked(GeoCoordinate &swBound, GeoCoordinate &neBound);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    LocationListView *m_locationListView;   ///< Location list view
+};
+
+#endif // ROUTINGPANEL_H