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.
*/
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;
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
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()));
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");
}
}
}
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()
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();
}
private:
void showSelectAllItem(bool show, bool resetCheck = true);
- void checkAllItems(bool check);
void checkHandler(SelectAllListItem &item);
void checkHandler(ThreadListItem &item);
void fillList();
{
m_DeleteMode = value;
setCheckMode(value);
- checkAllItems(false);
+ checkAllItems(false, true);
showSelectAllItem(value);
}
}
}
-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:
getNaviBar().showButton(NaviPrevButtonId, !value);
m_pList->setCheckMode(value);
- m_pList->checkAllItems(false);
+ m_pList->checkAllItems(false, true);
showSelectAllItem(value);
}