ui/routingpanel.cpp \
ui/routewaypointlistitem.cpp \
ui/routewaypointlistview.cpp \
- user/user.cpp
+ user/user.cpp \
+ ui/locationsearchpanel.cpp
HEADERS += application.h \
common.h \
coordinates/geocoordinate.h \
ui/routingpanel.h \
ui/routewaypointlistitem.h \
ui/routewaypointlistview.h \
- user/user.h
+ user/user.h \
+ ui/locationsearchpanel.h
QT += network \
webkit
DEFINES += QT_NO_DEBUG_OUTPUT
--- /dev/null
+/*
+ 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"
+#include "routewaypointlistview.h"
+#include "routing/location.h"
+#include "routing/route.h"
+
+#include "locationsearchpanel.h"
+
+LocationSearchPanel::LocationSearchPanel(QWidget *parent)
+ : PanelBase(parent)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ // --- ROUTING INSTRUCTIONS WIDGET ---
+ 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 *LocationSearchPanelLayout = new QVBoxLayout;
+ LocationSearchPanelLayout->setMargin(0);
+ LocationSearchPanelLayout->setSpacing(0);
+ setLayout(LocationSearchPanelLayout);
+
+ m_views = new QStackedLayout();
+ LocationSearchPanelLayout->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);
+
+ // --- 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);
+}
+
+void LocationSearchPanel::clearListsSelections()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_locationListView->clearItemSelection();
+ m_routeWaypointListView->clearItemSelection();
+
+ setRouteButtonDisabled();
+}
+
+void LocationSearchPanel::hideEvent(QHideEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QWidget::hideEvent(event);
+
+ clearListsSelections();
+}
+
+void LocationSearchPanel::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 LocationSearchPanel::routeButtonToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (checked) {
+ routeToSelectedLocation();
+ m_searchLocationButton->setChecked(false);
+ } else {
+ emit clearRoute();
+ m_routeWaypointListView->clearList();
+ setRouteButtonDisabled();
+ }
+}
+
+void LocationSearchPanel::routeToSelectedLocation()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ LocationListItem *item = dynamic_cast<LocationListItem *>
+ (m_locationListView->selectedItem());
+
+ if (item)
+ emit routeToLocation(item->coordinates());
+}
+
+void LocationSearchPanel::searchLocationButtonToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (checked) {
+ showResultsView();
+ emit requestSearchLocation();
+ } else {
+ showRoutingView();
+ }
+}
+
+void LocationSearchPanel::setRoute(Route &route)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_routeWaypointListView->clearList();
+
+ 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);
+ }
+
+ 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);
+
+ emit openPanelRequested(this);
+}
+
+void LocationSearchPanel::setRouteButtonDisabled()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_routeButton->setDisabled(m_locationListView->selectedItems().isEmpty()
+ && !m_routeButton->isChecked());
+}
+
+void LocationSearchPanel::showResultsView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_views->setCurrentWidget(m_resultsView);
+ m_routeWaypointListView->clearItemSelection();
+}
+
+void LocationSearchPanel::showRoutingView()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_views->setCurrentWidget(m_routingView);
+ m_locationListView->clearItemSelection();
+}
--- /dev/null
+/*
+ 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;
+class Route;
+class RouteWaypointListView;
+
+/**
+ * @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 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
+ */
+ void searchLocationButtonToggled(bool checked);
+
+ /**
+ * @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
+ ******************************************************************************/
+signals:
+ /**
+ * @brief Emitted when route is cleared
+ */
+ void clearRoute();
+
+ /**
+ * @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);
+
+ /**
+ * @brief Signal for requesting a panel to be opened
+ *
+ * @param widget Pointer to the widget that emitted the signal
+ */
+ void showPanelRequested(QWidget *widget);
+
+/*******************************************************************************
+ * 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
+
+ ImageButton *m_routeButton; ///< Route to location button
+ ImageButton *m_searchLocationButton; ///< Search location button
+ LocationListView *m_locationListView; ///< Search results list view
+ RouteWaypointListView *m_routeWaypointListView; ///< Route instructions list view
+};
+
+#endif // LOCATIONSEARCHPANEL_H
#include "friendlistpanel.h"
#include "fullscreenbutton.h"
#include "indicatorbuttonpanel.h"
+#include "locationsearchpanel.h"
#include "logindialog.h"
#include "mapscale.h"
#include "panelcommon.h"
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(this, SIGNAL(routeParsed(Route&)),
+ m_locationSearchPanel, SLOT(setRoute(Route&)));
+
+ connect(m_locationSearchPanel, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
+ this, SIGNAL(centerToCoordinates(GeoCoordinate)));
+
+ connect(m_locationSearchPanel, SIGNAL(requestSearchLocation()),
+ this, SLOT(startLocationSearch()));
+
+ connect(m_locationSearchPanel, SIGNAL(clearRoute()),
+ this, SIGNAL(clearRoute()));
+}
+
void MainWindow::buildMap()
{
qDebug() << __PRETTY_FUNCTION__;
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"));
+ m_tabbedPanel->addTab(m_locationSearchPanel, QIcon(":/res/images/search.png"));
m_tabbedPanel->addTab(m_routingPanel, QIcon(":/res/images/routing.png"));
connect(m_mapView, SIGNAL(viewResized(QSize)),
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
public slots:
/**
- * @brief Build direction indicator button panel and connect signals
- */
- void buildIndicatorButtonPanel();
-
- /**
* @brief Builds information box with message.
*
* @param message Information message
void buildFullScreenButton();
/**
+ * @brief Build direction indicator button panel and connect signals
+ */
+ void buildIndicatorButtonPanel();
+
+ void buildLocationSearchPanel();
+
+ /**
* @brief Build map and connect slots
*/
void buildMap();
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
+ LocationSearchPanel *m_locationSearchPanel;
MapScale *m_mapScale; ///< Instance of the map scale
MapView *m_mapView; ///< Instance of the map view
NetworkCookieJar *m_cookieJar; ///< Placeholder for QNetworkCookies
+/*
+ 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"
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
* @brief Class for sliding routing panel
*
* @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
*/
class RoutingPanel : public PanelBase
{