Merge branch 'master' into context_driven_buttons, review
[situare] / src / ui / locationsearchpanel.h
index 98b978d..e939db7 100644 (file)
@@ -32,6 +32,7 @@ class GeoCoordinate;
 class ImageButton;
 class Location;
 class LocationListView;
+class SearchHistoryListView;
 
 /**
  * @brief Location search panel
@@ -51,6 +52,13 @@ public:
      */
     LocationSearchPanel(QWidget *parent = 0);
 
+    /**
+     * @brief Destructor
+     *
+     * Writes search history to settings.
+     */
+    ~LocationSearchPanel();
+
 /*******************************************************************************
  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
  ******************************************************************************/
@@ -69,6 +77,11 @@ protected:
  ******************************************************************************/
 private:
     /**
+    * @brief Reads search history from settings.
+    */
+    void readSettings();
+
+    /**
     * @brief Set text for header
     *
     * @param count Search result count
@@ -77,6 +90,16 @@ private:
 
 private slots:
     /**
+    * @brief Prepends search history list view with search.
+    *
+    * If search history limit is reached, oldest search is removed from list view.
+    *
+    * @param searchString search string to add
+    * @param dateTime date and time of search (if empty, current date and time is added)
+    */
+    void prependSearchHistory(QString searchString, QDateTime dateTime = QDateTime());
+
+    /**
     * @brief Clears lists' selections.
     *
     * Does call setRouteButtonDisabled().
@@ -84,6 +107,18 @@ private slots:
     void clearListsSelections();
 
     /**
+    * @brief Shows location list view.
+    *
+    * @param locationItemsCount location items count
+    */
+    void showLocationListView(int locationItemsCount);
+
+    /**
+    * @brief Shows search history list view.
+    */
+    void showSearchHistoryListView();
+
+    /**
     * @brief Populates location list view.
     *
     * @param locations list of Location objects
@@ -128,14 +163,23 @@ signals:
     */
     void routeWaypointItemClicked(const GeoCoordinate &coordinate);
 
+    /**
+    * @brief Signal is emitted when search history item is clicked.
+    *
+    * @param searchString search string used
+    */
+    void searchHistoryItemClicked(const QString &searchString);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    QLabel *m_resultsLabel;                 ///< Location list label
+    QLabel *m_resultsLabel;                         ///< Location list label
 
-    ImageButton *m_routeButton;             ///< Route to location button
-    LocationListView *m_locationListView;   ///< Search results list view
+    ImageButton *m_clearLocationListButton;         ///< Clear location list button
+    ImageButton *m_routeButton;                     ///< Route to location button
+    SearchHistoryListView *m_searchHistoryListView; ///< Search history list view
+    LocationListView *m_locationListView;           ///< Search results list view
 };
 
 #endif // LOCATIONSEARCHPANEL_H