Added RouteWaypointList- and RouteWaypointListView classes.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 13 Aug 2010 12:22:14 +0000 (15:22 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 13 Aug 2010 12:22:14 +0000 (15:22 +0300)
13 files changed:
images.qrc
src/engine/engine.cpp
src/routing/routingservice.cpp
src/src.pro
src/ui/locationlistitem.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/routewaypointlistitem.cpp [new file with mode: 0644]
src/ui/routewaypointlistitem.h [new file with mode: 0644]
src/ui/routewaypointlistview.cpp [new file with mode: 0644]
src/ui/routewaypointlistview.h [new file with mode: 0644]
src/ui/routingpanel.cpp
src/ui/routingpanel.h

index 83af30b..28d33f3 100644 (file)
         <file>res/images/walk_icon_gray.png</file>
         <file>res/images/zoom_in.png</file>
         <file>res/images/zoom_out.png</file>
+        <file>res/images/arrow_turn_continue.png</file>
+        <file>res/images/arrow_turn_left.png</file>
+        <file>res/images/arrow_turn_right.png</file>
+        <file>res/images/arrow_turn_sharp_left.png</file>
+        <file>res/images/arrow_turn_sharp_right.png</file>
+        <file>res/images/arrow_turn_slight_left.png</file>
+        <file>res/images/arrow_turn_slight_right.png</file>
+        <file>res/images/arrow_turn_start.png</file>
     </qresource>
 </RCC>
index 81455ee..57c14be 100644 (file)
@@ -667,11 +667,7 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(refreshUserData()),
             this, SLOT(refreshUserData()));
 
-    connect(m_ui, SIGNAL(findUser(GeoCoordinate)),
-            m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
-
-    // signals from friend list tab
-    connect(m_ui, SIGNAL(findFriend(GeoCoordinate)),
+    connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
 
@@ -736,6 +732,9 @@ void SituareEngine::signalsFromRoutingService()
 
     connect(m_routingService, SIGNAL(routeParsed(Route&)),
             m_mapEngine, SLOT(setRoute(Route&)));
+
+    connect(m_routingService, SIGNAL(routeParsed(Route&)),
+            m_ui, SIGNAL(routeParsed(Route&)));
 }
 
 void SituareEngine::signalsFromSituareService()
index 4746dc4..ed0842c 100644 (file)
@@ -105,7 +105,7 @@ void RoutingService::parseRouteData(const QByteArray &jsonReply)
                 segment.setLengthCaption(list.at(4));
                 segment.setEarthDirection(list.at(5));
                 segment.setAzimuth(list.at(6).toDouble());
-                if (list.count() == 8) {
+                if (list.count() == 9) {
                     segment.setTurnType(list.at(7));
                     segment.setTurnAngle(list.at(8).toDouble());
                 }
index 6adbdef..8ea4422 100644 (file)
@@ -76,7 +76,9 @@ SOURCES += main.cpp \
     ui/panelcontent.cpp \
     ui/panelbase.cpp \
     user/user.cpp \
-    ui/routingpanel.cpp
+    ui/routingpanel.cpp \
+    ui/routewaypointlistview.cpp \
+    ui/routewaypointlistitem.cpp
 HEADERS += application.h \
     common.h \
     engine/engine.h \
@@ -155,7 +157,9 @@ HEADERS += application.h \
     ui/panelbar.h \
     ui/panelcontent.h \
     ui/panelbase.h \
-    ui/routingpanel.h
+    ui/routingpanel.h \
+    ui/routewaypointlistview.h \
+    ui/routewaypointlistitem.h
 QT += network \
     webkit
 
index 19b4f3a..b5fa821 100644 (file)
@@ -45,9 +45,9 @@ public:
     */
     ~LocationListItem();
 
-/*******************************************************************************
- * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
- ******************************************************************************/
+/******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
 public:
     /**
     * @brief Returns location bounds in parameters.
@@ -64,10 +64,6 @@ public:
     */
     GeoCoordinate coordinates() const;
 
-/******************************************************************************
-* MEMBER FUNCTIONS AND SLOTS
-******************************************************************************/
-public:
     /**
     * @brief Set location data for this item.
     *
index 8a9a67d..24b6efb 100644 (file)
@@ -172,7 +172,7 @@ 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*)));
@@ -347,6 +347,12 @@ void MainWindow::buildRoutingPanel()
 
     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)));
 }
 
 void MainWindow::buildUserInfoPanel()
@@ -365,7 +371,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()));
index 687f047..5eb59c9 100644 (file)
@@ -47,6 +47,7 @@ class GeoCoordinate;
 class MapScale;
 class MapScene;
 class MapView;
+class Route;
 class RoutingPanel;
 class TabbedPanel;
 class SettingsDialog;
@@ -430,6 +431,13 @@ signals:
     void cancelLoginProcess();
 
     /**
+     * @brief Signal for centering to coordinates.
+     *
+     * @param coordinates geo coordinates to center to.
+     */
+    void centerToCoordinates(const GeoCoordinate &coordinates);
+
+    /**
      * @brief View should be centered to new location
      *
      * @param coordinate Scene coordinates of the new center point
@@ -469,13 +477,6 @@ signals:
     void fetchUsernameFromSettings();
 
     /**
-     * @brief Signal for finding user.
-     *
-     * @param coordinates user geo coordinates
-     */
-    void findUser(const GeoCoordinate &coordinates);
-
-    /**
      * @brief Signals when friend's profile image is ready
      *
      * @param user Friend
@@ -490,13 +491,6 @@ signals:
     void gpsTriggered(bool enabled);
 
     /**
-     * @brief Signal for finding friend.
-     *
-     * @param coordinates friend's geo coordinates
-     */
-    void findFriend(const GeoCoordinate &coordinates);
-
-    /**
      * @brief Signal for friend location ready.
      *
      * @param friendsList
@@ -580,6 +574,13 @@ signals:
     void reverseGeoReady(const QString &address);
 
     /**
+    * @brief Emited when route is parsed and is ready for further processing
+    *
+    * @param route Route item containing parsed route details
+    */
+    void routeParsed(Route &route);
+
+    /**
     * @brief Signal for routing to geo coordinates.
     *
     * @param coordinates destination geo coordinates
diff --git a/src/ui/routewaypointlistitem.cpp b/src/ui/routewaypointlistitem.cpp
new file mode 100644 (file)
index 0000000..b16f5dd
--- /dev/null
@@ -0,0 +1,71 @@
+#include <QDebug>
+#include <QTime>
+
+#include "avatarimage.h"
+#include "listcommon.h"
+#include "routing/routesegment.h"
+
+#include "routewaypointlistitem.h"
+
+RouteWaypointListItem::RouteWaypointListItem()
+    : ExtendedListItem()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    setSubitemTextWidth(SUBITEM_TEXT_MAX_WIDTH);
+}
+
+GeoCoordinate RouteWaypointListItem::coordinates() const
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_coordinates;
+}
+
+void RouteWaypointListItem::setRouteWaypointData(const RouteSegment &routeSegment,
+                                                 const GeoCoordinate &coordinate)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_coordinates = coordinate;
+
+    if (routeSegment.turnType() == "C")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_continue.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TL")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_left.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TSLL")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_slight_left.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TSHL")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_sharp_left.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TR")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_right.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TSLR")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_slight_right.png"),
+                                     AvatarImage::Small));
+    else if (routeSegment.turnType() == "TSHR")
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_sharp_right.png"),
+                                     AvatarImage::Small));
+    else
+        setImage(AvatarImage::create(QPixmap(":/res/images/arrow_turn_start.png"),
+                                     AvatarImage::Small));
+
+    setTitle(shortenText(routeSegment.street(), NAME_TEXT_MAX_WIDTH + MARGIN,
+                        ListItem::TEXT_SIZE_NORMAL));
+
+    clearSubItems();
+
+    QTime zeroTime(0, 0);
+    QTime segmentTravelTime = zeroTime.addSecs(routeSegment.time());
+
+    addSubItem(segmentTravelTime.toString("hh:mm:ss"), QPixmap(":/res/images/clock.png"));
+}
+
+RouteWaypointListItem::~RouteWaypointListItem()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
diff --git a/src/ui/routewaypointlistitem.h b/src/ui/routewaypointlistitem.h
new file mode 100644 (file)
index 0000000..66e78e1
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+   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 ROUTEWAYPOINTLISTITEM_H
+#define ROUTEWAYPOINTLISTITEM_H
+
+#include "coordinates/geocoordinate.h"
+#include "routing/routesegment.h"
+#include "extendedlistitem.h"
+
+/**
+* @brief List item stores information about route waypoints.
+*
+* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+*/
+class RouteWaypointListItem : public ExtendedListItem
+{
+public:
+    /**
+    * @brief Constructor.
+    *
+    * Sets sub items' text width.
+    */
+    RouteWaypointListItem();
+
+    /**
+    * @brief Destructor.
+    */
+    ~RouteWaypointListItem();
+
+/******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+public:
+    /**
+    * @brief Returns item's coordinates.
+    *
+    * @return item's coordinates
+    */
+    GeoCoordinate coordinates() const;
+
+    /**
+    * @brief Set route waypoint data for this item.
+    *
+    * @param routeSegment RouteSegment data
+    * @param coordinates GeoCoordinate
+    */
+    void setRouteWaypointData(const RouteSegment &routeSegment,
+                              const GeoCoordinate &coordinate);
+
+/******************************************************************************
+* DATA MEMBERS
+******************************************************************************/
+private:
+    GeoCoordinate m_coordinates;   ///< Route segment coordinates
+    RouteSegment m_routeSegment;    ///< Route segment data
+};
+
+#endif // ROUTEWAYPOINTLISTITEM_H
+
diff --git a/src/ui/routewaypointlistview.cpp b/src/ui/routewaypointlistview.cpp
new file mode 100644 (file)
index 0000000..9bdfa8e
--- /dev/null
@@ -0,0 +1,23 @@
+#include <QDebug>
+
+#include "routewaypointlistitem.h"
+
+#include "routewaypointlistview.h"
+
+RouteWaypointListView::RouteWaypointListView(QWidget *parent)
+    : ListView(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void RouteWaypointListView::listItemClicked(ListItem *item)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    ListView::listItemClicked(item);
+
+    RouteWaypointListItem *routeWaypointItem = dynamic_cast<RouteWaypointListItem*>(item);
+
+    if (routeWaypointItem)
+        emit routeWaypointItemClicked(routeWaypointItem->coordinates());
+}
diff --git a/src/ui/routewaypointlistview.h b/src/ui/routewaypointlistview.h
new file mode 100644 (file)
index 0000000..42fbc34
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+   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 ROUTEWAYPOINTLISTVIEW_H
+#define ROUTEWAYPOINTLISTVIEW_H
+
+#include "listview.h"
+
+/**
+* @brief Shows RouteWaypointListItems in list view.
+*
+* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+*/
+class RouteWaypointListView : public ListView
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QWidget
+    */
+    RouteWaypointListView(QWidget *parent = 0);
+
+/*******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+public slots:
+    /**
+    * @brief Slot for list item clicked.
+    *
+    * @param item ListItem
+    */
+    void listItemClicked(ListItem *item);
+
+/******************************************************************************
+* SIGNALS
+******************************************************************************/
+signals:
+    /**
+    * @brief Signal is emitted when route waypoint item is clicked.
+    *
+    * @param coordinates item's coordinates
+    */
+    void routeWaypointItemClicked(const GeoCoordinate &coordinates);
+};
+
+
+#endif // ROUTEWAYPOINTLISTVIEW_H
index b3f9926..fa8bbf0 100644 (file)
@@ -3,6 +3,9 @@
 #include "locationlistview.h"
 #include "extendedlistitemdelegate.h"
 #include "routing/location.h"
+#include "routing/route.h"
+#include "routewaypointlistview.h"
+#include "routewaypointlistitem.h"
 #include "panelcommon.h"
 
 #include "routingpanel.h"
@@ -38,10 +41,16 @@ RoutingPanel::RoutingPanel(QWidget *parent)
 
     m_locationListView = new LocationListView(this);
     m_locationListView->setItemDelegate(new ExtendedListItemDelegate(this));
+    m_locationListView->hide();
+
+    m_routeWaypointListView = new RouteWaypointListView(this);
+    m_routeWaypointListView->setItemDelegate(new ExtendedListItemDelegate(this));
+    m_routeWaypointListView->hide();
 
     headerLayout->addWidget(m_locationListLabel, 0, Qt::AlignCenter);
 
     listViewLayout->addWidget(m_locationListView);
+    listViewLayout->addWidget(m_routeWaypointListView);
 
     routingLayout->addWidget(m_routeButton);
     routingLayout->addWidget(m_locationListHeaderWidget);
@@ -54,6 +63,9 @@ RoutingPanel::RoutingPanel(QWidget *parent)
 
     connect(m_routeButton, SIGNAL(clicked()),
             this, SLOT(routeToSelectedLocation()));
+
+    connect(m_routeWaypointListView, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
+            this, SIGNAL(routeWaypointItemClicked(GeoCoordinate)));
 }
 
 void RoutingPanel::populateLocationListView(const QList<Location> &locations)
@@ -63,6 +75,8 @@ void RoutingPanel::populateLocationListView(const QList<Location> &locations)
     m_locationListHeaderWidget->show();
     m_locationListLabel->setText(tr("Search results: %1").arg(locations.count()));
 
+    m_routeWaypointListView->hide();
+    m_locationListView->show();
     m_locationListView->clearList();
 
     for (int i = 0; i < locations.size(); ++i) {
@@ -94,3 +108,24 @@ void RoutingPanel::routeToSelectedLocation()
     if (item)
         emit routeToLocation(item->coordinates());
 }
+
+void RoutingPanel::setRoute(Route &route)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_locationListView->hide();
+    m_routeWaypointListView->show();
+    m_routeWaypointListView->clear();
+
+    QList<RouteSegment> segments = route.segments();
+    QList<GeoCoordinate> geometryPoints = route.geometryPoints();
+
+    for (int i = 0; i < segments.size(); ++i) {
+        RouteWaypointListItem *item = new RouteWaypointListItem();
+        RouteSegment routeSegment = segments.at(i);
+        item->setRouteWaypointData(routeSegment,
+                                   geometryPoints.at(routeSegment.positionIndex()));
+
+        m_routeWaypointListView->addListItem(QString::number(i), item);
+    }
+}
index 0857a23..eb42ab8 100644 (file)
@@ -28,6 +28,8 @@ class ExtendedListItemDelegate;
 class GeoCoordinate;
 class LocationListView;
 class Location;
+class Route;
+class RouteWaypointListView;
 
 /**
  * @brief Class for sliding routing panel
@@ -64,6 +66,14 @@ private slots:
     */
     void routeToSelectedLocation();
 
+    /**
+    * @brief Sets route to the panel.
+    *
+    * Appends route waypoint list with route segments.
+    * @param route Route item containing parsed route details
+    */
+    void setRoute(Route &route);
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -83,6 +93,8 @@ signals:
     */
     void routeToLocation(const GeoCoordinate &coordinates);
 
+    void routeWaypointItemClicked(const GeoCoordinate &coordinate);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
@@ -94,6 +106,7 @@ private:
     QWidget *m_locationListHeaderWidget;    ///< Location list header widget
 
     LocationListView *m_locationListView;   ///< Location list view
+    RouteWaypointListView *m_routeWaypointListView; ///< Route waypoint list view
 };
 
 #endif // ROUTINGPANEL_H