Added LocationSearchPanel (which is currently a copy of RoutingPanel)
[situare] / src / ui / locationsearchpanel.h
diff --git a/src/ui/locationsearchpanel.h b/src/ui/locationsearchpanel.h
new file mode 100644 (file)
index 0000000..f0b2ebc
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+    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