#define __UCL_MVP_LIST_ITEM_PRESENTER_H__
#include "ucl/gui/GenlistItem.h"
+#include "ucl/gui/ElmWidget.h"
#include "ucl/misc/HashMap.h"
bool isActive() const;
GenlistItem getItem();
- ItemClassCacheSRef getItemClassCache();
+ ItemClassCache *getItemClassCache();
Result updateItemStyle(ElmStyle newItemStyle);
virtual void onItemDetached();
virtual CString getItemPartText(EdjePart part);
- virtual WidgetSRef getItemPartContent(EdjePart part);
+ virtual WidgetSRef getItemPartContent(EdjePart part, ElmWidget &parent);
virtual bool getItemPartState(EdjePart part);
virtual void onItemSelected();
private:
void attachItem(GenlistItem item,
+ ElmWidgetSRef &&parent,
const ItemClassCacheSRef &itcCache,
const SharedRef<bool> &isActiveRef);
private:
ListItemPresenterSRef m_selfRef;
GenlistItem m_item;
- ItemClassCacheWRef m_itcCache;
+ ItemClassCacheSRef m_itcCache;
SharedRef<bool> m_isActiveRef;
+ ElmWidgetSRef m_parent;
int m_flags;
};
}
if (!data) {
LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
}
- if (const auto widget = static_cast<ListItemPresenter *>(data)->
- getItemPartContent(EdjePart(part))) {
+ auto &&item = *static_cast<ListItemPresenter *>(data);
+ if (const auto widget = item.getItemPartContent(
+ EdjePart(part), *item.m_parent)) {
widget->setIsOwner(false);
return widget->getEo();
}
}
}
- void ListItemPresenter::attachItem(GenlistItem item,
+ void ListItemPresenter::attachItem(GenlistItem item, ElmWidgetSRef &&parent,
const ItemClassCacheSRef &itcCache,
const SharedRef<bool> &isActiveRef)
{
- if (!item) {
- LOG_RETURN_VOID(RES_FAIL, "item is NULL!");
- }
-
if (m_item) {
deleteDetachedItem();
}
m_item.setData(this);
m_item.setDelCallback(CALLBACK_A(ListItemPresenter::onItemDel));
+ m_parent = std::move(parent);
+
m_itcCache = itcCache;
m_isActiveRef = isActiveRef;
m_item.setData(nullptr);
m_item.setDelCallback(nullptr);
m_item = nullptr;
+
+ m_parent.reset();
+ m_itcCache.reset();
+ m_isActiveRef.reset();
+
if (!silent) {
onItemDetached();
}
return m_item;
}
- ListItemPresenter::ItemClassCacheSRef
- ListItemPresenter::getItemClassCache()
+ ListItemPresenter::ItemClassCache *ListItemPresenter::getItemClassCache()
{
- return m_itcCache.lock();
+ return m_itcCache.get();
}
Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle)
if (!m_item) {
LOG_RETURN(RES_ILLEGAL_STATE, "m_item is NULL!");
}
-
- const auto itcCache = getItemClassCache();
- if (!itcCache) {
- LOG_RETURN(RES_FATAL, "itcCache is NULL!");
+ if (!m_itcCache) {
+ LOG_RETURN(RES_FATAL, "m_itcCache is NULL!");
}
- const auto itc = itcCache->getItemClass(newItemStyle);
+ const auto itc = m_itcCache->getItemClass(newItemStyle);
if (!itc) {
- LOG_RETURN(RES_FAIL, "itcCache.getItemClass() failed!");
+ LOG_RETURN(RES_FAIL, "m_itcCache->getItemClass() failed!");
}
m_item.update(itc->get());
{
}
- WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part)
+ WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part,
+ ElmWidget &parent)
{
return nullptr;
}
ListPresenter::~ListPresenter()
{
+ if (m_genlist) {
+ m_genlist->clear();
+ }
}
Result ListPresenter::prepare(
LOG_RETURN(RES_FAIL, "insertFunc() failed!");
}
- itemPresenter.attachItem(item, m_itcCache, m_isActiveRef);
+ itemPresenter.attachItem(item, m_genlist, m_itcCache, m_isActiveRef);
return RES_OK;
}