TizenRefApp-6415 Search Result isn't Updated after Editing Contact 57/86457/1
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 1 Sep 2016 08:25:17 +0000 (11:25 +0300)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 1 Sep 2016 08:25:17 +0000 (11:25 +0300)
Change-Id: Id1e7cebb862cae33c4f27c14b6d7fc3e7fdade3f
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-common/inc/Contacts/Model/SearchEngine.h
lib-common/src/Contacts/Model/SearchEngine.cpp
lib-contacts/inc/Contacts/List/SearchField.h
lib-contacts/src/Contacts/List/ListView.cpp
lib-contacts/src/Contacts/List/Model/PersonSearchProvider.cpp
lib-contacts/src/Contacts/List/SearchField.cpp

index b98cc71..ae9521b 100644 (file)
@@ -60,11 +60,10 @@ namespace Contacts
 
                        /**@{*/
                        /**
-                        * @brief Notify engine that SearchData was Inserted/Updated/Deleted
+                        * @brief Insert/Delete results for given SearchData
                         * @param[in]   searchData  SearchData object
                         */
                        void insertSearchData(SearchData *searchData);
-                       void updateSearchData(SearchData *searchData);
                        void deleteSearchData(SearchData *searchData);
                        /**@}*/
 
index 8d18bfd..94b9e5c 100644 (file)
@@ -85,29 +85,6 @@ void SearchEngine::insertSearchData(SearchData *searchData)
        searchData->setSearchResult(lastResult);
 }
 
-void SearchEngine::updateSearchData(SearchData *searchData)
-{
-       SearchResult *lastResult = nullptr;
-
-       historyFor([searchData, &lastResult](const std::string &query, ResultList &list) {
-               auto it = findSearchData(list, searchData);
-               if (it != list.end()) {
-                       SearchResultPtr searchResult = searchData->compare(query);
-                       lastResult = searchResult.get();
-
-                       if (searchResult) {
-                               it->second = std::move(searchResult);
-                       } else {
-                               list.erase(it);
-                       }
-               }
-
-               return true;
-       });
-
-       searchData->setSearchResult(lastResult);
-}
-
 void SearchEngine::deleteSearchData(SearchData *searchData)
 {
        for (auto &&list : m_History) {
index fc1e29e..0d552ca 100644 (file)
@@ -38,6 +38,11 @@ namespace Contacts
                        typedef std::function<void(const char *)> ChangeCallback;
 
                        /**
+                        * @return Search query text.
+                        */
+                       const char *getText() const;
+
+                       /**
                         * @brief Set entry changed callback
                         */
                        void setChangeCallback(ChangeCallback callback);
index a040f49..5407534 100644 (file)
@@ -114,6 +114,9 @@ PersonProvider *ListView::getProvider() const
 void ListView::onUpdateFinished()
 {
        elm_index_level_go(m_Index, 0);
+       if (m_IsSearching) {
+               elm_genlist_filter_set(m_Genlist->getEvasObject(), (void *) m_SearchField->getText());
+       }
 }
 
 bool ListView::isListEmpty()
index dfd3ad3..06321a1 100644 (file)
@@ -90,7 +90,8 @@ void PersonSearchProvider::onInserted(Person &person)
 
 void PersonSearchProvider::onUpdated(PersonSearchData &searchData, int changes)
 {
-       m_SearchEngine.updateSearchData(&searchData);
+       m_SearchEngine.deleteSearchData(&searchData);
+       m_SearchEngine.insertSearchData(&searchData);
        searchData.onUpdated(changes);
 }
 
index 90ab6df..aa8a538 100644 (file)
 
 using namespace Contacts::List;
 
+const char *SearchField::getText() const
+{
+       return m_Text.c_str();
+}
+
 void SearchField::setChangeCallback(ChangeCallback callback)
 {
        m_OnChanged = std::move(callback);