diff options
author | Igor Nazarov <i.nazarov@samsung.com> | 2017-07-20 18:26:07 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-07-20 18:28:55 +0300 |
commit | 393f840b48a29f9712c9cf195042ab9ce4e4a9d3 (patch) | |
tree | 00bbe47b682ceb4a64714c7b101fcc8e34b09476 | |
parent | 6340a6c69fb31fbc6dbed97dec21961a8ae53622 (diff) | |
download | gallery-393f840b48a29f9712c9cf195042ab9ce4e4a9d3.tar.gz gallery-393f840b48a29f9712c9cf195042ab9ce4e4a9d3.tar.bz2 gallery-393f840b48a29f9712c9cf195042ab9ce4e4a9d3.zip |
TizenRefApp-8902 [Gallery] Add parent param in getItemPartContent method
of ListItemPresenter
Change-Id: I712fa8e9fb35fe35e2029c2b7bb758f7b2f77fe9
-rw-r--r-- | ucl/inc/ucl/mvp/ListItemPresenter.h | 9 | ||||
-rw-r--r-- | ucl/src/mvp/ListItemPresenter.cpp | 36 | ||||
-rw-r--r-- | ucl/src/mvp/ListPresenter.cpp | 5 |
3 files changed, 29 insertions, 21 deletions
diff --git a/ucl/inc/ucl/mvp/ListItemPresenter.h b/ucl/inc/ucl/mvp/ListItemPresenter.h index 2c90f42..46d2fb4 100644 --- a/ucl/inc/ucl/mvp/ListItemPresenter.h +++ b/ucl/inc/ucl/mvp/ListItemPresenter.h @@ -18,6 +18,7 @@ #define __UCL_MVP_LIST_ITEM_PRESENTER_H__ #include "ucl/gui/GenlistItem.h" +#include "ucl/gui/ElmWidget.h" #include "ucl/misc/HashMap.h" @@ -86,7 +87,7 @@ namespace ucl { bool isActive() const; GenlistItem getItem(); - ItemClassCacheSRef getItemClassCache(); + ItemClassCache *getItemClassCache(); Result updateItemStyle(ElmStyle newItemStyle); @@ -96,7 +97,7 @@ namespace ucl { 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(); @@ -107,6 +108,7 @@ namespace ucl { private: void attachItem(GenlistItem item, + ElmWidgetSRef &&parent, const ItemClassCacheSRef &itcCache, const SharedRef<bool> &isActiveRef); @@ -119,8 +121,9 @@ namespace ucl { private: ListItemPresenterSRef m_selfRef; GenlistItem m_item; - ItemClassCacheWRef m_itcCache; + ItemClassCacheSRef m_itcCache; SharedRef<bool> m_isActiveRef; + ElmWidgetSRef m_parent; int m_flags; }; } diff --git a/ucl/src/mvp/ListItemPresenter.cpp b/ucl/src/mvp/ListItemPresenter.cpp index e2ad69a..d27568b 100644 --- a/ucl/src/mvp/ListItemPresenter.cpp +++ b/ucl/src/mvp/ListItemPresenter.cpp @@ -57,8 +57,9 @@ namespace ucl { 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(); } @@ -128,14 +129,10 @@ namespace ucl { } } - 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(); } @@ -144,6 +141,8 @@ namespace ucl { m_item.setData(this); m_item.setDelCallback(CALLBACK_A(ListItemPresenter::onItemDel)); + m_parent = std::move(parent); + m_itcCache = itcCache; m_isActiveRef = isActiveRef; @@ -166,6 +165,11 @@ namespace ucl { m_item.setData(nullptr); m_item.setDelCallback(nullptr); m_item = nullptr; + + m_parent.reset(); + m_itcCache.reset(); + m_isActiveRef.reset(); + if (!silent) { onItemDetached(); } @@ -199,10 +203,9 @@ namespace ucl { 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) @@ -210,15 +213,13 @@ namespace ucl { 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()); @@ -247,7 +248,8 @@ namespace ucl { { } - WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part) + WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part, + ElmWidget &parent) { return nullptr; } diff --git a/ucl/src/mvp/ListPresenter.cpp b/ucl/src/mvp/ListPresenter.cpp index 220b10e..48bf316 100644 --- a/ucl/src/mvp/ListPresenter.cpp +++ b/ucl/src/mvp/ListPresenter.cpp @@ -97,6 +97,9 @@ namespace ucl { ListPresenter::~ListPresenter() { + if (m_genlist) { + m_genlist->clear(); + } } Result ListPresenter::prepare( @@ -236,7 +239,7 @@ namespace ucl { 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; } |