Emit error signal when login fails
[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     /**
80     * @brief Reads search history from settings.
81     */
82     void readSettings();
83
84     /**
85     * @brief Set text for header
86     *
87     * @param count Search result count
88     */
89     void setHeaderText(int count);
90
91 private slots:
92     /**
93     * @brief Prepends search history list view with search.
94     *
95     * If search history limit is reached, oldest search is removed from list view.
96     *
97     * @param searchString search string to add
98     * @param dateTime date and time of search (if empty, current date and time is added)
99     */
100     void prependSearchHistory(QString searchString, QDateTime dateTime = QDateTime());
101
102     /**
103     * @brief Clears lists' selections.
104     *
105     * Does call setRouteButtonDisabled().
106     */
107     void clearListsSelections();
108
109     /**
110      * @brief show / hide empty panel label
111      *
112      * @param show true if empty panel should be shown
113      */
114     void showEmptyPanel(bool show);
115
116     /**
117     * @brief Shows location list view.
118     *
119     * @param locationItemsCount location items count
120     */
121     void showLocationListView(int locationItemsCount);
122
123     /**
124     * @brief Shows search history list view.
125     */
126     void showSearchHistoryListView();
127
128     /**
129     * @brief Populates location list view.
130     *
131     * @param locations list of Location objects
132     */
133     void populateLocationListView(const QList<Location> &locations);
134
135     /**
136     * @brief Routes to selected location.
137     *
138     * Emits routeToLocation if location is selected from list.
139     */
140     void routeToSelectedLocation();
141
142 /*******************************************************************************
143  * SIGNALS
144  ******************************************************************************/
145 signals:
146     /**
147     * @brief Signal for location item clicked.
148     *
149     * @param swBound south-west bound GeoCoordinate
150     * @param neBound north-east bound GeoCoordinate
151     */
152     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
153
154     /**
155     * @brief Signal for requesting searching location.
156     */
157     void requestSearchLocation();
158
159     /**
160     * @brief Signal for routing to location.
161     *
162     * @param coordinates location's geo coordinates
163     */
164     void routeToLocation(const GeoCoordinate &coordinates);
165
166     /**
167     * @brief Signal for route waypoint item clicked.
168     *
169     * @param coordinate waypoint item's coordinate
170     */
171     void routeWaypointItemClicked(const GeoCoordinate &coordinate);
172
173     /**
174     * @brief Signal is emitted when search history item is clicked.
175     *
176     * @param searchString search string used
177     */
178     void searchHistoryItemClicked(const QString &searchString);
179
180 /*******************************************************************************
181  * DATA MEMBERS
182  ******************************************************************************/
183 private:
184     QLabel *m_noSearchLabel;                        ///< Text label for empty panel
185     QLabel *m_resultsLabel;                         ///< Location list label
186
187     ImageButton *m_clearLocationListButton;         ///< Clear location list button
188     ImageButton *m_routeButton;                     ///< Route to location button
189     SearchHistoryListView *m_searchHistoryListView; ///< Search history list view
190     LocationListView *m_locationListView;           ///< Search results list view
191 };
192
193 #endif // LOCATIONSEARCHPANEL_H