Using UrlHistoryList do display history list (on urientry edition).
[profile/tv/apps/web/browser.git] / services / QuickAccess / UrlHistoryList / UrlHistoryList.h
index fa9934a..f42a425 100644 (file)
 #include <Evas.h>
 
 #include "services/HistoryService/HistoryItem.h"
+#include <boost/signals2/signal.hpp>
 
 using namespace std;
 
-namespace tizen_browser
-{
+namespace tizen_browser {
+namespace base_ui {
+
+class QuickAccess;
+class GenlistManager;
+typedef shared_ptr<GenlistManager> GenlistManagerPtr;
 
-namespace services
+enum class EditedUrlState
 {
-class WidgetListManager;
-typedef shared_ptr<WidgetListManager> WidgetListManagerPtr;
-}
+    // url was edited by a user (by typing)
+    EDITED_BY_USER,
+    // url was edited in other way than typing (but for the first time after previous user edition)
+    EDITED_OTHER_FIRST,
+    // url was edited in other way than typing (and previously was not edited by the user)
+    EDITED_OTHER_MANY_TIMES
+};
 
-namespace base_ui
+/**
+ * Needed to indicate who did the last url entry edition (user/other/other many times). Used
+ * to indicate when widget can be hidden in a pretty way or an instant way.
+ */
+class EditedUrlStatesHelper
 {
+public:
+    EditedUrlStatesHelper()
+    {
+    }
+    void changeState(bool editedByUser)
+    {
+        if (editedByUser) {
+            currentState = EditedUrlState::EDITED_BY_USER;
+        } else {
+            if (currentState == EditedUrlState::EDITED_BY_USER) {
+                currentState = EditedUrlState::EDITED_OTHER_FIRST;
+            } else {
+                currentState = EditedUrlState::EDITED_OTHER_MANY_TIMES;
+            }
+        }
+    }
+    EditedUrlState getCurrentState()
+    {
+        return currentState;
+    }
+private:
+    EditedUrlState currentState = EditedUrlState::EDITED_BY_USER;
+};
 
 /**
  * Manages list of url matches (URL from history). Manages top layout, creates
@@ -43,25 +79,47 @@ namespace base_ui
 class UrlHistoryList
 {
 public:
-       UrlHistoryList();
-       virtual ~UrlHistoryList();
-       void show();
-       void createLayout(Evas_Object* parentLayout);
-       Evas_Object *getLayout();
-
-       /**
-        * \brief entered url is edited (edited before acceptation)
-        */
-       void onURLEntryEdit(const string& editedUrl,
-                       shared_ptr<services::HistoryItemVector> matchedEntries);
-       void onMouseClick();
+    UrlHistoryList(QuickAccess* quickAccess);
+    virtual ~UrlHistoryList();
+    void createLayout(Evas_Object* parentLayout);
+    Evas_Object* getLayout();
+
+    // // on uri entry widget "changed,user" signal
+    void onURLEntryEditedByUser(const string& editedUrl,
+            shared_ptr<services::HistoryItemVector> matchedEntries);
+    // on uri entry widget "changed" signal
+    void onURLEntryEdited();
+
+    void onMouseClick();
+
+    boost::signals2::signal<void(shared_ptr<services::HistoryItem>, bool)> openURLInNewTab;
+
+    int getVisibleItemsMax() const
+    {
+        return VISIBLE_ITEMS_MAX;
+    }
+
+    int getMinKeywordLength() const
+    {
+        return MIN_KEYWORD_LENGTH;
+    }
 
 private:
+    void onListItemSelect(std::string content);
+    void onListWidgetFocused();
+    void onListWidgetUnfocused();
+
+    EditedUrlStatesHelper editedUrlStatesHelper;
 
-       Evas_Object* m_layout;
-       string m_edjFilePath;
+    // the maximum items number on a list
+    const int VISIBLE_ITEMS_MAX = 12;
+    // the minimum length of the keyword used to search matches
+    const int MIN_KEYWORD_LENGTH = 3;
+    Evas_Object* m_layout;
+    string m_edjFilePath;
 
-       services::WidgetListManagerPtr m_widgetListManager;
+    GenlistManagerPtr m_genlistListManager = nullptr;
+    QuickAccess* m_quickAccess;
 
 };