Added LocationSearchPanel (which is currently a copy of RoutingPanel)
[situare] / src / ui / locationsearchpanel.h
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Jussi Laitinen - jussi.laitinen@ixonos.com
6         Sami Rämö - sami.ramo@ixonos.com
7
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21 */
22
23 #ifndef LOCATIONSEARCHPANEL_H
24 #define LOCATIONSEARCHPANEL_H
25
26 #include <QtGui>
27
28 #include "panelbase.h"
29
30 class ExtendedListItemDelegate;
31 class GeoCoordinate;
32 class ImageButton;
33 class Location;
34 class LocationListView;
35 class Route;
36 class RouteWaypointListView;
37
38 /**
39  * @brief Location search panel
40  *
41  * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
42  * @author Sami Rämö - sami.ramo (at) ixonos.com
43  */
44 class LocationSearchPanel : public PanelBase
45 {
46     Q_OBJECT
47
48 public:
49     /**
50      * @brief Default constructor
51      *
52      * @param parent
53      */
54     LocationSearchPanel(QWidget *parent = 0);
55
56 /*******************************************************************************
57  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
58  ******************************************************************************/
59 protected:
60     /**
61     * @brief Re-implemented from QWidget::hideEvent()
62     *
63     * Calls clearListsSelections()
64     *
65     * @param event
66     */
67     void hideEvent(QHideEvent *event);
68
69 /*******************************************************************************
70  * MEMBER FUNCTIONS AND SLOTS
71  ******************************************************************************/
72 private:
73     /**
74     * @brief Switch to search results view mode
75     */
76     void showResultsView();
77
78     /**
79     * @brief Switch to routing instructions view mode
80     */
81     void showRoutingView();
82
83 private slots:
84     /**
85     * @brief Clears lists' selections.
86     *
87     * Does call setRouteButtonDisabled().
88     */
89     void clearListsSelections();
90
91     /**
92     * @brief Populates location list view.
93     *
94     * @param locations list of Location objects
95     */
96     void populateLocationListView(const QList<Location> &locations);
97
98     /**
99     * @brief Handler for route button toggling actions
100     */
101     void routeButtonToggled(bool checked);
102
103     /**
104     * @brief Routes to selected location.
105     *
106     * Emits routeToLocation if location is selected from list.
107     */
108     void routeToSelectedLocation();
109
110     /**
111     * @brief Handler for search button toggling actions
112     */
113     void searchLocationButtonToggled(bool checked);
114
115     /**
116     * @brief Sets route to the panel.
117     *
118     * Appends route waypoint list with route segments.
119     * @param route Route item containing parsed route details
120     */
121     void setRoute(Route &route);
122
123     /**
124     * @brief Sets route button disabled.
125     *
126     * Disabled if there isn't any list item selected.
127     */
128     void setRouteButtonDisabled();
129
130 /*******************************************************************************
131  * SIGNALS
132  ******************************************************************************/
133 signals:
134     /**
135     * @brief Emitted when route is cleared
136     */
137     void clearRoute();
138
139     /**
140     * @brief Signal for location item clicked.
141     *
142     * @param swBound south-west bound GeoCoordinate
143     * @param neBound north-east bound GeoCoordinate
144     */
145     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
146
147     /**
148     * @brief Signal for requesting searching location.
149     */
150     void requestSearchLocation();
151
152     /**
153     * @brief Signal for routing to location.
154     *
155     * @param coordinates location's geo coordinates
156     */
157     void routeToLocation(const GeoCoordinate &coordinates);
158
159     /**
160     * @brief Signal for route waypoint item clicked.
161     *
162     * @param coordinate waypoint item's coordinate
163     */
164     void routeWaypointItemClicked(const GeoCoordinate &coordinate);
165
166     /**
167      * @brief Signal for requesting a panel to be opened
168      *
169      * @param widget Pointer to the widget that emitted the signal
170      */
171     void showPanelRequested(QWidget *widget);
172
173 /*******************************************************************************
174  * DATA MEMBERS
175  ******************************************************************************/
176 private:
177     QLabel *m_resultsLabel;                 ///< Location list label
178
179     QStackedLayout *m_views;                ///< Views
180
181     QWidget *m_resultsView;                 ///< Search results view widget
182     QWidget *m_routingView;                 ///< Routing instructions view widget
183
184     ImageButton *m_routeButton;             ///< Route to location button
185     ImageButton *m_searchLocationButton;    ///< Search location button
186     LocationListView *m_locationListView;   ///< Search results list view
187     RouteWaypointListView *m_routeWaypointListView;     ///< Route instructions list view
188 };
189
190 #endif // LOCATIONSEARCHPANEL_H