Created SearchHistoryListView and -Item classes.
[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 SearchHistoryListView;
36
37 /**
38  * @brief Location search panel
39  *
40  * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
41  * @author Sami Rämö - sami.ramo (at) ixonos.com
42  */
43 class LocationSearchPanel : public PanelBase
44 {
45     Q_OBJECT
46
47 public:
48     /**
49      * @brief Default constructor
50      *
51      * @param parent
52      */
53     LocationSearchPanel(QWidget *parent = 0);
54
55     /**
56      * @brief Destructor
57      *
58      * Writes search history to settings.
59      */
60     ~LocationSearchPanel();
61
62 /*******************************************************************************
63  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
64  ******************************************************************************/
65 protected:
66     /**
67     * @brief Re-implemented from QWidget::hideEvent()
68     *
69     * Calls clearListsSelections()
70     *
71     * @param event
72     */
73     void hideEvent(QHideEvent *event);
74
75 /*******************************************************************************
76  * MEMBER FUNCTIONS AND SLOTS
77  ******************************************************************************/
78 private:
79     void readSettings();
80
81     /**
82     * @brief Set text for header
83     *
84     * @param count Search result count
85     */
86     void setHeaderText(int count);
87
88 private slots:
89
90     void appendSearchHistory(QString searchString, QDateTime currentTime = QDateTime());
91
92     /**
93     * @brief Clears lists' selections.
94     *
95     * Does call setRouteButtonDisabled().
96     */
97     void clearListsSelections();
98
99     /**
100     * @brief Shows search history list.
101     */
102     void showSearchHistoryList();
103
104     /**
105     * @brief Populates location list view.
106     *
107     * @param locations list of Location objects
108     */
109     void populateLocationListView(const QList<Location> &locations);
110
111     /**
112     * @brief Routes to selected location.
113     *
114     * Emits routeToLocation if location is selected from list.
115     */
116     void routeToSelectedLocation();
117
118     /**
119     * @brief Sets route button disabled.
120     *
121     * Disabled if there isn't any list item selected.
122     */
123     void setRouteButtonDisabled();
124
125 /*******************************************************************************
126  * SIGNALS
127  ******************************************************************************/
128 signals:
129     /**
130     * @brief Signal for location item clicked.
131     *
132     * @param swBound south-west bound GeoCoordinate
133     * @param neBound north-east bound GeoCoordinate
134     */
135     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
136
137     /**
138     * @brief Signal for requesting searching location.
139     */
140     void requestSearchLocation();
141
142     /**
143     * @brief Signal for routing to location.
144     *
145     * @param coordinates location's geo coordinates
146     */
147     void routeToLocation(const GeoCoordinate &coordinates);
148
149     /**
150     * @brief Signal for route waypoint item clicked.
151     *
152     * @param coordinate waypoint item's coordinate
153     */
154     void routeWaypointItemClicked(const GeoCoordinate &coordinate);
155
156 /*******************************************************************************
157  * DATA MEMBERS
158  ******************************************************************************/
159 private:
160     QLabel *m_resultsLabel;                         ///< Location list label
161
162     ImageButton *m_clearLocationListButton;         ///< Clear location list button
163     ImageButton *m_routeButton;                     ///< Route to location button
164     SearchHistoryListView *m_searchHistoryListView; ///< Search history list view
165     LocationListView *m_locationListView;           ///< Search results list view
166 };
167
168 #endif // LOCATIONSEARCHPANEL_H