Merge branch 'master' of https://vcs.maemo.org/git/situare
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Wed, 1 Sep 2010 13:10:20 +0000 (16:10 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Wed, 1 Sep 2010 13:10:20 +0000 (16:10 +0300)
18 files changed:
images.qrc
res/images/location_search.png [new file with mode: 0644]
src/engine/engine.cpp
src/engine/engine.h
src/map/mapengine.cpp
src/src.pro
src/ui/locationsearchpanel.cpp [new file with mode: 0644]
src/ui/locationsearchpanel.h [new file with mode: 0644]
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/paneltab.cpp
src/ui/paneltabbar.cpp
src/ui/paneltabbar.h
src/ui/routingpanel.cpp
src/ui/routingpanel.h
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h
src/ui/textmodifier.h

index 7c7f5f9..400684d 100644 (file)
@@ -59,5 +59,6 @@
         <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/location_search.png</file>
     </qresource>
 </RCC>
diff --git a/res/images/location_search.png b/res/images/location_search.png
new file mode 100644 (file)
index 0000000..ee31448
Binary files /dev/null and b/res/images/location_search.png differ
index 8b0ac3c..2883a50 100644 (file)
@@ -496,6 +496,13 @@ void SituareEngine::routeTo(const GeoCoordinate &endPointCoordinates)
         m_routingService->requestRoute(m_mapEngine->centerGeoCoordinate(), endPointCoordinates);
 }
 
+void SituareEngine::routeToCursor()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    routeTo(m_mapEngine->centerGeoCoordinate());
+}
+
 void SituareEngine::setAutoCentering(bool enabled)
 {
     qDebug() << __PRETTY_FUNCTION__ << enabled;
@@ -668,27 +675,33 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
-    // signals from routing tab
+    // routing signal from friend list tab & search location tab
+    connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
+            this, SLOT(routeTo(const GeoCoordinate&)));
+
+    // signals from location search panel
     connect(m_ui,
             SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
             m_mapEngine,
             SLOT(showMapArea(const GeoCoordinate&, const GeoCoordinate&)));
 
+    // signals from routing tab
     connect(m_ui, SIGNAL(clearRoute()),
             m_mapEngine, SLOT(clearRoute()));
 
-    // signals from distence indicator button
+    connect(m_ui, SIGNAL(routeToCursor()),
+            this, SLOT(routeToCursor()));
+
+    // signals from distance indicator button
     connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
             this, SLOT(changeAutoCenteringSetting(bool)));
 
-    connect(m_ui, SIGNAL(searchForLocation(QString)),
-            this, SLOT(locationSearch(QString)));
-
     connect(m_ui, SIGNAL(draggingModeTriggered()),
             this, SLOT(draggingModeTriggered()));
 
-    connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
-            this, SLOT(routeTo(const GeoCoordinate&)));
+    // signal from search location dialog
+    connect(m_ui, SIGNAL(searchForLocation(QString)),
+            this, SLOT(locationSearch(QString)));
 }
 
 void SituareEngine::signalsFromMapEngine()
@@ -793,7 +806,6 @@ void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_ui->toggleProgressIndicator(false);
-    m_ui->showPanels();
 
     emit userLocationReady(user);
     emit friendsLocationsReady(friendsList);
index 71bfc7a..422e2f1 100644 (file)
@@ -257,6 +257,11 @@ private slots:
     void routeTo(const GeoCoordinate &endPointCoordinates);
 
     /**
+    * @brief Route to current cursor position
+    */
+    void routeToCursor();
+
+    /**
     * @brief Slot for setting auto centering state.
     *
     * Calls gps to send last known position
index 0675e1f..77a87f6 100644 (file)
@@ -139,13 +139,13 @@ void MapEngine::centerAndZoomTo(QRect rect, bool useMargins)
     int marginVertical = 0;
 
     if (useMargins) {
-        marginHorizontal = 50;
+        marginHorizontal = 5;
         marginVertical = 5;
     }
 
     // calculate the usable size of the view
-    int viewUsableHeight = m_viewSize.height() - 2 * marginHorizontal;
-    int viewUsableWidth = m_viewSize.width() - 2 * marginVertical;
+    int viewUsableHeight = m_viewSize.height() - 2 * marginVertical;
+    int viewUsableWidth = m_viewSize.width() - 2 * marginHorizontal;
 
     // calculate how many levels must be zoomed out from the closest zoom level to get the rect
     // fit inside the usable view area
index 1063753..1cf0da4 100644 (file)
@@ -81,6 +81,7 @@ SOURCES += main.cpp \
     ui/routewaypointlistitem.cpp \
     ui/routewaypointlistview.cpp \
     user/user.cpp \
+    ui/locationsearchpanel.cpp \
     ui/textmodifier.cpp
 HEADERS += application.h \
     common.h \
@@ -164,6 +165,7 @@ HEADERS += application.h \
     ui/routewaypointlistitem.h \
     ui/routewaypointlistview.h \
     user/user.h \
+    ui/locationsearchpanel.h \
     ui/textmodifier.h
 QT += network \
     webkit
diff --git a/src/ui/locationsearchpanel.cpp b/src/ui/locationsearchpanel.cpp
new file mode 100644 (file)
index 0000000..d42353c
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Jussi Laitinen - jussi.laitinen@ixonos.com
+        Sami Rämö - sami.ramo@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.
+*/
+
+#include "extendedlistitemdelegate.h"
+#include "locationlistitem.h"
+#include "locationlistview.h"
+#include "imagebutton.h"
+#include "panelcommon.h"
+#include "routing/location.h"
+
+#include "locationsearchpanel.h"
+
+LocationSearchPanel::LocationSearchPanel(QWidget *parent)
+    : PanelBase(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    // --- HEADER WIDGET ---
+    QWidget *resultsHeaderWidget = new QWidget();
+    resultsHeaderWidget->setAutoFillBackground(true);
+    QPalette labelPalette = resultsHeaderWidget->palette();
+    labelPalette.setColor(QPalette::Background, Qt::black);
+    resultsHeaderWidget->setPalette(labelPalette);
+
+    QHBoxLayout *headerLayout = new QHBoxLayout();
+    resultsHeaderWidget->setLayout(headerLayout);
+    headerLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                     PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+
+    m_resultsLabel = new QLabel(this);
+    headerLayout->addWidget(m_resultsLabel, 0, Qt::AlignCenter);
+    setHeaderText(0);
+
+    // --- SEARCH RESULTS LIST VIEW ---
+    m_locationListView = new LocationListView(this);
+    m_locationListView->setItemDelegate(new ExtendedListItemDelegate(this));
+
+    connect(m_locationListView,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            this,
+            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+
+    connect(m_locationListView, SIGNAL(listItemSelectionChanged()),
+            this, SLOT(setRouteButtonDisabled()));
+
+    QVBoxLayout *resultsListViewLayout = new QVBoxLayout;
+    resultsListViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                       PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+    resultsListViewLayout->addWidget(m_locationListView);
+
+    // --- MAIN LAYOUT ---
+    QVBoxLayout *panelLayout = new QVBoxLayout;
+    panelLayout->setSpacing(0);
+    setLayout(panelLayout);
+
+    const int MARGIN_LEFT = 0;
+    panelLayout->setContentsMargins(MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                    PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+
+    panelLayout->addWidget(resultsHeaderWidget);
+    panelLayout->addLayout(resultsListViewLayout);
+
+    // --- CONTEXT BUTTONS ---
+    m_routeButton = new ImageButton(":res/images/compass.png", "", "", this);
+    m_routeButton->setDisabled(true);
+    connect(m_routeButton, SIGNAL(clicked()),
+            this, SLOT(routeToSelectedLocation()));
+
+    ImageButton *searchLocationButton = new ImageButton(":/res/images/search.png",
+                                                        ":/res/images/search_s.png", "", this);
+    connect(searchLocationButton, SIGNAL(clicked()),
+            this, SIGNAL(requestSearchLocation()));
+
+    m_contextButtonLayout->addWidget(m_routeButton);
+    m_contextButtonLayout->addWidget(searchLocationButton);
+}
+
+void LocationSearchPanel::clearListsSelections()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_locationListView->clearItemSelection();
+
+    setRouteButtonDisabled();
+}
+
+void LocationSearchPanel::hideEvent(QHideEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QWidget::hideEvent(event);
+
+    clearListsSelections();
+}
+
+void LocationSearchPanel::populateLocationListView(const QList<Location> &locations)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    setHeaderText(locations.count());
+
+    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);
+    }
+
+    const int FIRST_LOCATION_ITEM_INDEX = 0;
+    const int ONE_LOCATION_ITEM = 1;
+
+    if (locations.size() == ONE_LOCATION_ITEM) {
+        ListItem *item = m_locationListView->listItemAt(FIRST_LOCATION_ITEM_INDEX);
+
+        if (item)
+            m_locationListView->setSelectedItem(item);
+    }
+
+    m_locationListView->scrollToTop();
+}
+
+void LocationSearchPanel::routeToSelectedLocation()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    LocationListItem *item = dynamic_cast<LocationListItem *>
+                             (m_locationListView->selectedItem());
+
+    if (item)
+        emit routeToLocation(item->coordinates());
+}
+
+void LocationSearchPanel::setHeaderText(int count)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_resultsLabel->setText(tr("Search results: %1").arg(count));
+}
+
+void LocationSearchPanel::setRouteButtonDisabled()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_routeButton->setDisabled(m_locationListView->selectedItems().isEmpty());
+}
diff --git a/src/ui/locationsearchpanel.h b/src/ui/locationsearchpanel.h
new file mode 100644 (file)
index 0000000..fd87bf2
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Jussi Laitinen - jussi.laitinen@ixonos.com
+        Sami Rämö - sami.ramo@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 LOCATIONSEARCHPANEL_H
+#define LOCATIONSEARCHPANEL_H
+
+#include <QtGui>
+
+#include "panelbase.h"
+
+class ExtendedListItemDelegate;
+class GeoCoordinate;
+class ImageButton;
+class Location;
+class LocationListView;
+
+/**
+ * @brief Location search panel
+ *
+ * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
+ */
+class LocationSearchPanel : public PanelBase
+{
+    Q_OBJECT
+
+public:
+    /**
+     * @brief Default constructor
+     *
+     * @param parent
+     */
+    LocationSearchPanel(QWidget *parent = 0);
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+    /**
+    * @brief Re-implemented from QWidget::hideEvent()
+    *
+    * Calls clearListsSelections()
+    *
+    * @param event
+    */
+    void hideEvent(QHideEvent *event);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+private:
+    /**
+    * @brief Set text for header
+    *
+    * @param count Search result count
+    */
+    void setHeaderText(int count);
+
+private slots:
+    /**
+    * @brief Clears lists' selections.
+    *
+    * Does call setRouteButtonDisabled().
+    */
+    void clearListsSelections();
+
+    /**
+    * @brief Populates location list view.
+    *
+    * @param locations list of Location objects
+    */
+    void populateLocationListView(const QList<Location> &locations);
+
+    /**
+    * @brief Routes to selected location.
+    *
+    * Emits routeToLocation if location is selected from list.
+    */
+    void routeToSelectedLocation();
+
+    /**
+    * @brief Sets route button disabled.
+    *
+    * Disabled if there isn't any list item selected.
+    */
+    void setRouteButtonDisabled();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Signal for location item clicked.
+    *
+    * @param swBound south-west bound GeoCoordinate
+    * @param neBound north-east bound GeoCoordinate
+    */
+    void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
+
+    /**
+    * @brief Signal for requesting searching location.
+    */
+    void requestSearchLocation();
+
+    /**
+    * @brief Signal for routing to location.
+    *
+    * @param coordinates location's geo coordinates
+    */
+    void routeToLocation(const GeoCoordinate &coordinates);
+
+    /**
+    * @brief Signal for route waypoint item clicked.
+    *
+    * @param coordinate waypoint item's coordinate
+    */
+    void routeWaypointItemClicked(const GeoCoordinate &coordinate);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    QLabel *m_resultsLabel;                 ///< Location list label
+
+    ImageButton *m_routeButton;             ///< Route to location button
+    LocationListView *m_locationListView;   ///< Search results list view
+};
+
+#endif // LOCATIONSEARCHPANEL_H
index 0d4c574..e99cf6b 100644 (file)
@@ -40,6 +40,7 @@
 #include "friendlistpanel.h"
 #include "fullscreenbutton.h"
 #include "indicatorbuttonpanel.h"
+#include "locationsearchpanel.h"
 #include "logindialog.h"
 #include "mapscale.h"
 #include "panelcommon.h"
@@ -251,6 +252,25 @@ void MainWindow::buildInformationBox(const QString &message, bool modal)
     queueDialog(msgBox);
 }
 
+void MainWindow::buildLocationSearchPanel()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_locationSearchPanel = new LocationSearchPanel(this);
+
+    connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
+            m_locationSearchPanel, SLOT(populateLocationListView(const QList<Location>&)));
+
+    connect(m_locationSearchPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+            this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+
+    connect(m_locationSearchPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
+            this, SIGNAL(routeTo(const GeoCoordinate&)));
+
+    connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
+            this, SLOT(startLocationSearch()));
+}
+
 void MainWindow::buildMap()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -321,11 +341,18 @@ void MainWindow::buildPanels()
 
     buildUserInfoPanel();
     buildFriendListPanel();
+    buildLocationSearchPanel();
     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"));
+    
+    //Save Situare related tab indexes so tabs can be enabled/disabled when logged in/out
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png")));
+    m_situareTabsIndexes.append(
+            m_tabbedPanel->addTab(m_friendsListPanel, QIcon(":/res/images/friend_list.png")));
+
+    m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/location_search.png"));
     m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
 
     connect(m_mapView, SIGNAL(viewResized(QSize)),
@@ -365,14 +392,8 @@ void MainWindow::buildRoutingPanel()
 
     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(m_routingPanel, SIGNAL(routeToCursor()),
+            this, SIGNAL(routeToCursor()));
 
     connect(this, SIGNAL(routeParsed(Route&)),
             m_routingPanel, SLOT(setRoute(Route&)));
@@ -380,9 +401,6 @@ void MainWindow::buildRoutingPanel()
     connect(m_routingPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
             this, SIGNAL(centerToCoordinates(GeoCoordinate)));
 
-    connect(m_routingPanel, SIGNAL(requestSearchLocation()),
-            this, SLOT(startLocationSearch()));
-
     connect(m_routingPanel, SIGNAL(clearRoute()),
             this, SIGNAL(clearRoute()));
 }
@@ -952,25 +970,6 @@ void MainWindow::showInformationBox()
     }
 }
 
-void MainWindow::showPanels()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-///< @todo check how this is called and can this method be removed
-
-//    if(m_loggedIn) {
-//        if(!m_friendsListPanel->isVisible()) {
-//            m_friendsListPanel->show();
-//            m_friendsListPanelSidebar->show();
-//        }
-
-//        if(!m_userPanel->isVisible()) {
-//            m_userPanel->show();
-//            m_userPanelSidebar->show();
-//        }
-//    }
-}
-
 void MainWindow::startLocationSearch()
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -1029,17 +1028,7 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-///< @todo can this be removed?
-
-//    if(!m_loggedIn) {
-//        m_friendsListPanel->closePanel();
-//        m_friendsListPanel->hide();
-//        m_friendsListPanelSidebar->hide();
-
-//        m_userPanel->closePanel();
-//        m_userPanel->hide();
-//        m_userPanelSidebar->hide();
-//    }
+    m_tabbedPanel->setTabsEnabled(m_situareTabsIndexes, m_loggedIn);
 }
 
 const QString MainWindow::username()
index 044a1c4..06acfae 100644 (file)
@@ -40,24 +40,24 @@ class QToolButton;
 class QWebView;
 
 class FacebookAuthentication;
-class FullScreenButton;
 class FriendListPanel;
-class IndicatorButtonPanel;
+class FullScreenButton;
 class GeoCoordinate;
+class IndicatorButtonPanel;
+class Location;
+class LocationSearchPanel;
 class MapScale;
 class MapScene;
 class MapView;
 class Route;
 class RoutingPanel;
-class TabbedPanel;
-class SettingsDialog;
 class SceneCoordinate;
+class SettingsDialog;
 class SituareService;
 class TabbedPanel;
 class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
-class Location;
 
 /**
  * @brief Main Window Class
@@ -156,11 +156,6 @@ public:
 
 public slots:
     /**
-     * @brief Build direction indicator button panel and connect signals
-     */
-    void buildIndicatorButtonPanel();
-
-    /**
      * @brief Builds information box with message.
      *
      * @param message Information message
@@ -198,11 +193,6 @@ public slots:
     void setUsername(const QString &username);
 
     /**
-     * @brief Method to show panels
-     */
-    void showPanels();
-
-    /**
      * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
      *        doesn't exist yet
      */
@@ -238,6 +228,17 @@ private:
     void buildFullScreenButton();
 
     /**
+     * @brief Build direction indicator button panel and connect signals
+     */
+    void buildIndicatorButtonPanel();
+
+
+    /**
+     * @brief Build location search panel and connect signals
+     */
+    void buildLocationSearchPanel();
+
+    /**
      * @brief Build map and connect slots
      */
     void buildMap();
@@ -590,6 +591,11 @@ signals:
     void routeTo(const GeoCoordinate &coordinates);
 
     /**
+    * @brief Request routing to current cursor position
+    */
+    void routeToCursor();
+
+    /**
      * @brief Signal to save username to settings
      *
      * @param username Username
@@ -674,6 +680,7 @@ private:
     QLabel *m_crosshair;                    ///< Label for center point crosshair
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
 
+    QList<int> m_situareTabsIndexes;        ///< List of Situare tab indexes
     QList<QDialog *> m_error_queue;         ///< QList type error dialog queue
     QList<QDialog *> m_queue;               ///< QList type dialog queue
 
@@ -688,7 +695,8 @@ private:
 
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
-    IndicatorButtonPanel *m_indicatorButtonPanel;     ///< Instance of direction indicator button
+    IndicatorButtonPanel *m_indicatorButtonPanel;   ///< Instance of direction indicator button
+    LocationSearchPanel *m_locationSearchPanel;     ///< Location search panel
     MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
     NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
index 19b1240..c3ce81f 100644 (file)
@@ -109,8 +109,8 @@ void PanelTab::paintEvent(QPaintEvent *event)
 
     if (isDown())
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
-    else if (isChecked())
-        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
-    else
+    else if (!isEnabled())
         icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
+    else
+        icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
 }
index 7b7cdd5..7efca18 100644 (file)
@@ -128,3 +128,10 @@ void PanelTabBar::setUpTabLayout()
 
     emit sizeChangeRequested();
 }
+
+QButtonGroup * PanelTabBar::tabs() const
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_tabButtonGroup;
+}
index 35ed793..5a69357 100644 (file)
@@ -78,6 +78,13 @@ public:
      */
     void removeTab(int index);
 
+    /**
+    * @brief Returns all tabs.
+    *
+    * @return All tabs
+    */
+    QButtonGroup * tabs() const;
+
 private:
     /**
      * @brief Initializes and formats tab buttons layout
index 6a244d2..45998f4 100644 (file)
@@ -1,7 +1,27 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Jussi Laitinen - jussi.laitinen@ixonos.com
+        Sami Rämö - sami.ramo@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.
+*/
+
 #include "coordinates/geocoordinate.h"
 #include "extendedlistitemdelegate.h"
-#include "locationlistitem.h"
-#include "locationlistview.h"
 #include "imagebutton.h"
 #include "panelcommon.h"
 #include "routewaypointlistitem.h"
@@ -16,179 +36,59 @@ RoutingPanel::RoutingPanel(QWidget *parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    // --- ROUTING INSTRUCTIONS WIDGET ---
+    // --- LAYOUT & ROUTING INSTRUCTIONS VIEW ---
     m_routeWaypointListView = new RouteWaypointListView(this);
     m_routeWaypointListView->setItemDelegate(new ExtendedListItemDelegate(this));
 
     connect(m_routeWaypointListView, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
             this, SIGNAL(routeWaypointItemClicked(GeoCoordinate)));
 
-    QVBoxLayout *routingViewLayout = new QVBoxLayout;
-    routingViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
-                                          PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
-
-    // main routing layout
-    m_routingView = new QWidget();
-    m_routingView->setLayout(routingViewLayout);
-    routingViewLayout->addWidget(m_routeWaypointListView);
-
-    // --- SEARCH RESULTS WIDGET ---
-    // header
-    QWidget *resultsHeaderWidget = new QWidget();
-    resultsHeaderWidget->setAutoFillBackground(true);
-    QPalette labelPalette = resultsHeaderWidget->palette();
-    labelPalette.setColor(QPalette::Background, Qt::black);
-    resultsHeaderWidget->setPalette(labelPalette);
-
-    QHBoxLayout *headerLayout = new QHBoxLayout();
-    resultsHeaderWidget->setLayout(headerLayout);
-    headerLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
-                                     PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
-
-    m_resultsLabel = new QLabel(this);
-    headerLayout->addWidget(m_resultsLabel, 0, Qt::AlignCenter);
-
-    // list view
-    m_locationListView = new LocationListView(this);
-    m_locationListView->setItemDelegate(new ExtendedListItemDelegate(this));
-
-    connect(m_locationListView,
-            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
-            this,
-            SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
-
-    connect(m_locationListView, SIGNAL(listItemSelectionChanged()),
-            this, SLOT(setRouteButtonDisabled()));
-
-    QVBoxLayout *resultsListViewLayout = new QVBoxLayout;
-    resultsListViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
-                                       PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
-    resultsListViewLayout->addWidget(m_locationListView);
-
-    // main results layout
-    m_resultsView = new QWidget();
-    QVBoxLayout *resultsViewLayout = new QVBoxLayout;
-    const int CONTENTS_MARGIN_LEFT = 0;
-    resultsViewLayout->setContentsMargins(CONTENTS_MARGIN_LEFT, PANEL_MARGIN_TOP,
-                                          PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
-    m_resultsView->setLayout(resultsViewLayout);
-
-    resultsViewLayout->addWidget(resultsHeaderWidget);
-    resultsViewLayout->addLayout(resultsListViewLayout);
-
-    // --- MAIN LAYOUT ---
-    QVBoxLayout *routingPanelLayout = new QVBoxLayout;
-    routingPanelLayout->setMargin(0);
-    routingPanelLayout->setSpacing(0);
-    setLayout(routingPanelLayout);
-
-    m_views = new QStackedLayout();
-    routingPanelLayout->addLayout(m_views);
-    m_views->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
-                                PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
-
-    m_views->addWidget(m_routingView);
-    m_views->addWidget(m_resultsView);
+    QVBoxLayout *panelLayout = new QVBoxLayout;
+    panelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
+                                    PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+
+    panelLayout->addWidget(m_routeWaypointListView);
+    setLayout(panelLayout);
 
     // --- CONTEXT BUTTONS ---
-    m_searchLocationButton = new ImageButton(":/res/images/search.png",
-                                             ":/res/images/search_s.png", "", this);
-    m_searchLocationButton->setCheckable(true);
-    connect(m_searchLocationButton, SIGNAL(toggled(bool)),
-            this, SLOT(searchLocationButtonToggled(bool)));
-
-    m_routeButton = new ImageButton(":res/images/route_to_location.png",
-                                    ":res/images/route_to_location_s.png", "", this);
-    m_routeButton->setCheckable(true);
-    m_routeButton->setDisabled(true);
-    connect(m_routeButton, SIGNAL(toggled(bool)),
-            this, SLOT(routeButtonToggled(bool)));
-
-    m_contextButtonLayout->addWidget(m_searchLocationButton);
-    m_contextButtonLayout->addWidget(m_routeButton);
+    ImageButton *routeToCursorButton = new ImageButton(":res/images/sight.png",
+                                                       "", "", this);
+    connect(routeToCursorButton, SIGNAL(clicked()),
+            this, SIGNAL(routeToCursor()));
+
+    m_clearRouteButton = new ImageButton(":/res/images/gps_position.png",
+                                         "", "", this);
+    connect(m_clearRouteButton, SIGNAL(clicked()),
+            this, SLOT(clearRouteButtonClicked()));
+    m_clearRouteButton->setDisabled(true);
+
+    m_contextButtonLayout->addWidget(routeToCursorButton);
+    m_contextButtonLayout->addWidget(m_clearRouteButton);
 }
 
 void RoutingPanel::clearListsSelections()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_locationListView->clearItemSelection();
     m_routeWaypointListView->clearItemSelection();
-
-    setRouteButtonDisabled();
-}
-
-void RoutingPanel::hideEvent(QHideEvent *event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    QWidget::hideEvent(event);
-
-    clearListsSelections();
-}
-
-void RoutingPanel::populateLocationListView(const QList<Location> &locations)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_resultsLabel->setText(tr("Search results: %1").arg(locations.count()));
-
-    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);
-    }
-
-    const int FIRST_LOCATION_ITEM_INDEX = 0;
-    const int ONE_LOCATION_ITEM = 1;
-
-    if (locations.size() == ONE_LOCATION_ITEM) {
-        ListItem *item = m_locationListView->listItemAt(FIRST_LOCATION_ITEM_INDEX);
-
-        if (item)
-            m_locationListView->setSelectedItem(item);
-    }
-
-    m_locationListView->scrollToTop();
 }
 
-void RoutingPanel::routeButtonToggled(bool checked)
+void RoutingPanel::clearRouteButtonClicked()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if (checked) {
-        routeToSelectedLocation();
-        m_searchLocationButton->setChecked(false);
-    } else {
-        emit clearRoute();
-        m_routeWaypointListView->clearList();
-        setRouteButtonDisabled();
-    }
+    m_clearRouteButton->setDisabled(true);
+    m_routeWaypointListView->clearList();
+    emit clearRoute();
 }
 
-void RoutingPanel::routeToSelectedLocation()
+void RoutingPanel::hideEvent(QHideEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    LocationListItem *item = dynamic_cast<LocationListItem *>
-                             (m_locationListView->selectedItem());
-
-    if (item)
-        emit routeToLocation(item->coordinates());
-}
-
-void RoutingPanel::searchLocationButtonToggled(bool checked)
-{
-    qDebug() << __PRETTY_FUNCTION__;
+    QWidget::hideEvent(event);
 
-    if (checked) {
-        showResultsView();
-        emit requestSearchLocation();
-    } else {
-        showRoutingView();
-    }
+    clearListsSelections();
 }
 
 void RoutingPanel::setRoute(Route &route)
@@ -211,41 +111,7 @@ void RoutingPanel::setRoute(Route &route)
 
     m_routeWaypointListView->scrollToTop();
 
-    // route might come from FriendListPanel's route to friend button, so we have to
-    // check the routing button without emitting new routing request
-    blockSignals(true);
-    m_routeButton->setEnabled(true);
-    m_routeButton->setChecked(true);
-    blockSignals(false);
-    m_searchLocationButton->setChecked(false);
-
-    // search location button might be already false, so we have to make sure the
-    // toggle action handler is called every time
-    searchLocationButtonToggled(false);
+    m_clearRouteButton->setDisabled(false);
 
     emit openPanelRequested(this);
 }
-
-void RoutingPanel::setRouteButtonDisabled()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_routeButton->setDisabled(m_locationListView->selectedItems().isEmpty()
-                               && !m_routeButton->isChecked());
-}
-
-void RoutingPanel::showResultsView()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_views->setCurrentWidget(m_resultsView);
-    m_routeWaypointListView->clearItemSelection();
-}
-
-void RoutingPanel::showRoutingView()
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    m_views->setCurrentWidget(m_routingView);
-    m_locationListView->clearItemSelection();
-}
index 45e8d18..2418f4c 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Jussi Laitinen - jussi.laitinen@ixonos.com
+        Sami Rämö - sami.ramo@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
 class ExtendedListItemDelegate;
 class GeoCoordinate;
 class ImageButton;
-class Location;
-class LocationListView;
 class Route;
 class RouteWaypointListView;
 
 /**
- * @brief Class for sliding routing panel
+ * @brief Routing panel
  *
  * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
  */
 class RoutingPanel : public PanelBase
 {
@@ -67,64 +67,26 @@ protected:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-private:
-    /**
-    * @brief Switch to search results view mode
-    */
-    void showResultsView();
-
-    /**
-    * @brief Switch to routing instructions view mode
-    */
-    void showRoutingView();
-
 private slots:
     /**
     * @brief Clears lists' selections.
-    *
-    * Does call setRouteButtonDisabled().
     */
     void clearListsSelections();
 
     /**
-    * @brief Populates location list view.
-    *
-    * @param locations list of Location objects
-    */
-    void populateLocationListView(const QList<Location> &locations);
-
-    /**
-    * @brief Handler for route button toggling actions
-    */
-    void routeButtonToggled(bool checked);
-
-    /**
-    * @brief Routes to selected location.
-    *
-    * Emits routeToLocation if location is selected from list.
-    */
-    void routeToSelectedLocation();
-
-    /**
-    * @brief Handler for search button toggling actions
+    * @brief Handler for clear route button clicks
     */
-    void searchLocationButtonToggled(bool checked);
+    void clearRouteButtonClicked();
 
     /**
     * @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);
 
-    /**
-    * @brief Sets route button disabled.
-    *
-    * Disabled if there isn't any list item selected.
-    */
-    void setRouteButtonDisabled();
-
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -135,24 +97,9 @@ signals:
     void clearRoute();
 
     /**
-    * @brief Signal for location item clicked.
-    *
-    * @param swBound south-west bound GeoCoordinate
-    * @param neBound north-east bound GeoCoordinate
+    * @brief Request routing to current cursor position
     */
-    void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
-
-    /**
-    * @brief Signal for requesting searching location.
-    */
-    void requestSearchLocation();
-
-    /**
-    * @brief Signal for routing to location.
-    *
-    * @param coordinates location's geo coordinates
-    */
-    void routeToLocation(const GeoCoordinate &coordinates);
+    void routeToCursor();
 
     /**
     * @brief Signal for route waypoint item clicked.
@@ -172,16 +119,9 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QLabel *m_resultsLabel;                 ///< Location list label
-
-    QStackedLayout *m_views;                ///< Views
-
-    QWidget *m_resultsView;                 ///< Search results view widget
-    QWidget *m_routingView;                 ///< Routing instructions view widget
+    QLabel *m_resultsLabel;                             ///< Location list label
 
-    ImageButton *m_routeButton;             ///< Route to location button
-    ImageButton *m_searchLocationButton;    ///< Search location button
-    LocationListView *m_locationListView;   ///< Search results list view
+    ImageButton *m_clearRouteButton;                    ///< Search location button
     RouteWaypointListView *m_routeWaypointListView;     ///< Route instructions list view
 };
 
index 50f0344..af58c61 100644 (file)
@@ -20,6 +20,8 @@
     USA.
 */
 
+#include <QAbstractButton>
+#include <QButtonGroup>
 #include <QDebug>
 #include <QPropertyAnimation>
 #include <QRegion>
@@ -256,6 +258,24 @@ void TabbedPanel::setCurrentIndex(int index)
     }
 }
 
+void TabbedPanel::setTabsEnabled(const QList<int> &tabIndexes, bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QButtonGroup *tabs = m_panelTabBar->tabs();
+
+    foreach (int tabIndex, tabIndexes) {
+        QAbstractButton *tabButton = tabs->button(tabIndex);
+
+        if (tabButton) {
+            if (tabButton->isChecked())
+                closePanel();
+
+            tabButton->setEnabled(enabled);
+        }
+    }
+}
+
 void TabbedPanel::stateChanged()
 {
     qDebug() << __PRETTY_FUNCTION__;
index d3e1f16..12fefa9 100644 (file)
@@ -95,6 +95,15 @@ public:
      */
     void removeTab(int index);
 
+    /**
+    * @brief Sets tabs enabled.
+    *
+    * If disabled tab is currently selected, panel will be closed also
+    * @param tabIndexes tab indexes to set
+    * @param enabled true if should be enabled, false otherwise
+    */
+    void setTabsEnabled(const QList<int> &tabIndexes, bool enabled);
+
 public slots:
     /**
      * @brief Slot that closes the panel
index e206e0a..42e3f3a 100644 (file)
@@ -34,8 +34,6 @@ class TextModifier : public QObject
 {
     Q_OBJECT
 public:
-    TextModifier(QObject *parent = 0);
-
     /**
     * @brief Shortens text to fit.
     *