TizenRefApp-7101 Update realized items only in setCheckedState() 61/87761/3
authorDmytro Dragan <dm.dragan@samsung.com>
Fri, 9 Sep 2016 09:30:31 +0000 (12:30 +0300)
committerAndrey Klimenko <and.klimenko@samsung.com>
Fri, 9 Sep 2016 11:29:27 +0000 (04:29 -0700)
Change-Id: I1b3b94176d77dc2e836336361781f8b21b0e0273
Signed-off-by: Dmytro Dragan <dm.dragan@samsung.com>
src/Common/View/inc/ListView.h
src/Common/View/src/ListItem.cpp
src/Common/View/src/ListView.cpp
src/Conversation/ConvList/Controller/src/ConvList.cpp
src/MsgThread/Controller/inc/ThreadList.h
src/MsgThread/Controller/src/ThreadList.cpp
src/Settings/Controller/src/MsgOnSimCard.cpp

index 1df100f..c5ba9d5 100644 (file)
@@ -103,6 +103,12 @@ namespace Msg
             ListItemCollection getItems() const;
 
             /**
+             * @brief Gets realized list-view items.
+             * @return list-view items.
+             */
+            ListItemCollection getRealizedItems() const;
+
+            /**
              * @brief Gets first list-view item.
              * @return first list-view item.
              */
@@ -208,10 +214,11 @@ namespace Msg
             bool getCheckMode() const;
 
             /**
-             * @brief Checks(unchecks) all list-view items in selection mode.
+             * @brief Checks(unchecks) all list-view items in selection mode and updates realized items.
              * @param[in] check if true all items will be checked, if false - unchecks all items.
+             * @param[in] updateFullItem if false only check part will be updated, if true whole item will be updated.
              */
-            void checkAllItems(bool check);
+            void checkAllItems(bool check, bool updateFullItem = false);
 
             template<typename T>
             std::vector<T*> getItems() const;
index 6768341..2e78d12 100644 (file)
@@ -183,8 +183,8 @@ void ListItem::changeCheckedState(bool updateUi)
 void ListItem::setCheckedState(bool state, bool updateUi)
 {
     m_Checked = state;
-    if(updateUi)
-        elm_genlist_item_update(getElmObjItem());
+    if (updateUi)
+        updateFields(getCheckPart(*this), ELM_GENLIST_ITEM_FIELD_ALL);
 }
 
 bool ListItem::getCheckedState() const
index 4006d16..d5e6dc2 100644 (file)
@@ -152,6 +152,26 @@ ListItemCollection ListView::getItems() const
     return list;
 }
 
+ListItemCollection ListView::getRealizedItems() const
+{
+    ListItemCollection collection;
+    Eina_List *list = elm_genlist_realized_items_get(getEo());
+    if(list)
+    {
+        void *obj = nullptr;
+        Eina_List *l = nullptr;
+
+        EINA_LIST_FOREACH(list, l, obj)
+        {
+            collection.push_back(getItem((Elm_Object_Item *)obj));
+        }
+
+        eina_list_free(list);
+    }
+
+    return collection;
+}
+
 ListItem *ListView::getFirstItem() const
 {
     return getItem(elm_genlist_first_item_get(getEo()));
@@ -236,21 +256,12 @@ void ListView::notifyListener(void *data, Evas_Object *obj, void *event_info, Li
 void ListView::setCheckMode(bool check)
 {
     m_CheckMode = check;
-    if(!check)
+    if (!check)
     {
         // Restore "default" state:
-        Eina_List *list = elm_genlist_realized_items_get(getEo());
-        if(list)
+        for(ListItem *item: getRealizedItems())
         {
-            void *obj = nullptr;
-            Eina_List *l = nullptr;
-
-            EINA_LIST_FOREACH(list, l, obj)
-            {
-                elm_object_item_signal_emit((Elm_Widget_Item*)obj, "elm,state,default", "elm");
-            }
-
-            eina_list_free(list);
+            item->emitSignal("elm,state,default", "elm");
         }
     }
 }
@@ -260,14 +271,20 @@ bool ListView::getCheckMode() const
     return m_CheckMode;
 }
 
-void ListView::checkAllItems(bool check)
+void ListView::checkAllItems(bool check,  bool updateFullItem)
 {
-    ListItemCollection items = getItems();
-    for(ListItem *item: items)
+    for(ListItem *item: getItems())
     {
-        // TODO: Optimization, update UI only for visible items
-        item->setCheckedState(check, true);
+        item->setCheckedState(check, false);
     }
+
+    if (updateFullItem)
+        updateRealizedItems();
+    else
+        for(ListItem *item: getRealizedItems())
+        {
+            item->updateFields(item->getCheckPart(*item), ELM_GENLIST_ITEM_FIELD_ALL);
+        }
 }
 
 void ListView::updateRealizedItems()
index bacc754..09b2f7e 100644 (file)
@@ -323,12 +323,7 @@ bool ConvList::isAllListItemSelected() const
 
 void ConvList::selectListItems(bool state)
 {
-    auto items = m_pList->getItems<ConvListItem>();
-    for(ConvListItem *item : items)
-    {
-        item->setCheckedState(state, false);
-    }
-    m_pList->updateRealizedItems();
+    m_pList->checkAllItems(state);
     if(m_pListener)
         m_pListener->onConvListItemChecked();
 }
index 20baf4d..a0631a4 100644 (file)
@@ -68,7 +68,6 @@ namespace Msg
 
         private:
             void showSelectAllItem(bool show, bool resetCheck = true);
-            void checkAllItems(bool check);
             void checkHandler(SelectAllListItem &item);
             void checkHandler(ThreadListItem &item);
             void fillList();
index b9f71fa..9e63e10 100644 (file)
@@ -70,7 +70,7 @@ void ThreadList::setDeleteMode(bool value)
 {
     m_DeleteMode = value;
     setCheckMode(value);
-    checkAllItems(false);
+    checkAllItems(false, true);
     showSelectAllItem(value);
 }
 
@@ -123,18 +123,6 @@ void ThreadList::showSelectAllItem(bool show, bool resetCheck)
     }
 }
 
-void ThreadList::checkAllItems(bool check)
-{
-    auto items = getItems();
-    for(ListItem *it : items)
-    {
-        if(it->isCheckable() && !isSelectAll(it))
-            it->setCheckedState(check, false);
-    }
-
-    updateRealizedItems();
-}
-
 bool ThreadList::isAllThreadListItemChecked() const
 {
     // Simple impl. but not fast:
index d8b712a..5226c7c 100644 (file)
@@ -281,7 +281,7 @@ void MsgOnSimCard::setTitleWithButtons(bool value)
     getNaviBar().showButton(NaviPrevButtonId, !value);
 
     m_pList->setCheckMode(value);
-    m_pList->checkAllItems(false);
+    m_pList->checkAllItems(false, true);
     showSelectAllItem(value);
 }