summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Nazarov <i.nazarov@samsung.com>2017-08-30 12:10:55 +0300
committerIgor Nazarov <i.nazarov@samsung.com>2017-08-30 12:45:37 +0300
commitc9287854d1ecb252d0365c386f0d9e2765012811 (patch)
tree8afc5e332b1ffd4daf9269fd868d4133cf4c9f3c
parent2ec1cc848d28df7ca379b066888257887497a01e (diff)
downloadgallery-c9287854d1ecb252d0365c386f0d9e2765012811.tar.gz
gallery-c9287854d1ecb252d0365c386f0d9e2765012811.tar.bz2
gallery-c9287854d1ecb252d0365c386f0d9e2765012811.zip
[Gallery] Simplified MoreOptionsPresenter::Builder implementation
Change-Id: Ib78ed9f8b3a2cd5883542dd17c7e357c1265c61b
-rw-r--r--gallery/presenters/misc/MoreOptionsPresenter.cpp37
-rw-r--r--gallery/presenters/misc/MoreOptionsPresenter.h20
-rw-r--r--gallery/presenters/pages/PreviewPage.cpp6
-rw-r--r--gallery/presenters/pages/PreviewPage.h2
-rw-r--r--gallery/presenters/pages/ThumbnailPage.cpp6
-rw-r--r--gallery/presenters/pages/ThumbnailPage.h2
6 files changed, 31 insertions, 42 deletions
diff --git a/gallery/presenters/misc/MoreOptionsPresenter.cpp b/gallery/presenters/misc/MoreOptionsPresenter.cpp
index f2fa2c9..d587e86 100644
--- a/gallery/presenters/misc/MoreOptionsPresenter.cpp
+++ b/gallery/presenters/misc/MoreOptionsPresenter.cpp
@@ -61,7 +61,8 @@ namespace gallery {
bool MoreOptionsPresenter::Builder::isEmpty() const
{
- return ucl::isEmpty(m_options);
+ using ucl::isEmpty;
+ return isEmpty(m_options);
}
MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::clear()
@@ -73,12 +74,7 @@ namespace gallery {
MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::addOption(
Option option)
{
- if (!m_options) {
- m_options = makeShared<MoreOptions>();
- } else if (m_options.getUseCount() > 1) {
- m_options = makeShared<MoreOptions>(*m_options);
- }
- m_options->emplace_back(std::move(option));
+ m_options.emplace_back(std::move(option));
return *this;
}
@@ -100,9 +96,10 @@ namespace gallery {
"m_parentWidget is NULL!");
}
- auto result = makeShared<MoreOptionsPresenter>(m_options);
+ auto result = makeShared<MoreOptionsPresenter>();
- FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget), {},
+ FAIL_RETURN_VALUE(result->prepare(parent,
+ *m_parentWidget, m_options), {},
"result->prepare() failed!");
return result;
@@ -110,10 +107,8 @@ namespace gallery {
// MoreOptionsPresenter //
- MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
- const MoreOptionsCSRef &options) :
+ MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc) :
GuiPresenter(rc),
- m_options(options),
m_timer(nullptr),
m_newOpenedState(false)
{
@@ -128,7 +123,7 @@ namespace gallery {
}
Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
+ ElmWidget &parentWidget, const std::list<Option> &options)
{
FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
"GuiPresenter::prepare() failed!");
@@ -141,7 +136,7 @@ namespace gallery {
const auto layout = makeShared<Layout>(more, true);
m_widget = layout;
- for (auto &option: *m_options) {
+ for (auto &option: options) {
FAIL_RETURN(addItem(option), "addItem() failed!");
}
@@ -184,7 +179,7 @@ namespace gallery {
impl::setText(item, option.text, impl::PART_MAIN_TEXT);
impl::setText(item, option.subText, impl::PART_SUB_TEXT);
- m_map.set(item, &option);
+ m_map.set(item, option.id);
return RES_OK;
}
@@ -248,9 +243,9 @@ namespace gallery {
return;
}
if (const auto listener = m_listener.lock()) {
- const auto item = m_map.get(eventInfo);
- if (item) {
- listener->onMoreOptionClicked(*this, *item);
+ int optionId = 0;
+ if (m_map.get(eventInfo, optionId)) {
+ listener->onMoreOptionClicked(*this, optionId);
} else {
ELOG("Invalid eventInfo!");
}
@@ -260,9 +255,9 @@ namespace gallery {
void MoreOptionsPresenter::onItemSelected(Widget &widget, void *eventInfo)
{
if (const auto listener = m_listener.lock()) {
- const auto item = m_map.get(eventInfo);
- if (item) {
- listener->onMoreOptionSelected(*this, *item);
+ int optionId = 0;
+ if (m_map.get(eventInfo, optionId)) {
+ listener->onMoreOptionSelected(*this, optionId);
} else {
ELOG("Invalid eventInfo!");
}
diff --git a/gallery/presenters/misc/MoreOptionsPresenter.h b/gallery/presenters/misc/MoreOptionsPresenter.h
index 95b432b..9a53249 100644
--- a/gallery/presenters/misc/MoreOptionsPresenter.h
+++ b/gallery/presenters/misc/MoreOptionsPresenter.h
@@ -38,8 +38,6 @@ namespace gallery {
ucl::LayoutTheme iconTheme;
};
- using MoreOptions = std::list<Option>;
-
class Builder final {
public:
Builder();
@@ -50,16 +48,16 @@ namespace gallery {
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
MoreOptionsPresenterSRef build(GuiPresenter &parent) const;
private:
- ucl::SharedRef<MoreOptions> m_options;
+ std::list<Option> m_options;
ucl::ElmWidgetSRef m_parentWidget;
};
class IListener : public ucl::Polymorphic {
public:
virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
- const Option &option) = 0;
+ int optionId) = 0;
virtual void onMoreOptionSelected(MoreOptionsPresenter &sender,
- const Option &option) {};
+ int optionId) {};
virtual void onMoreOptionsOpened(MoreOptionsPresenter &sender) {};
virtual void onMoreOptionsClosed(MoreOptionsPresenter &sender) {};
};
@@ -75,15 +73,12 @@ namespace gallery {
void setOpenedDelayed(bool isOpened, double timeout);
private:
- using MoreOptionsCSRef = ucl::SharedRef<const MoreOptions>;
-
- private:
friend class ucl::ReffedObj<MoreOptionsPresenter>;
- MoreOptionsPresenter(ucl::IRefCountObj &rc,
- const MoreOptionsCSRef &options);
+ MoreOptionsPresenter(ucl::IRefCountObj &rc);
virtual ~MoreOptionsPresenter();
- ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &parentWidget);
+ ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &parentWidget,
+ const std::list<Option> &options);
ucl::Result addItem(const Option &option);
bool resetTimer(double timeout);
@@ -97,8 +92,7 @@ namespace gallery {
void onItemSelected(ucl::Widget &widget, void *eventInfo);
private:
- const MoreOptionsCSRef m_options;
- ucl::HashMap<void *, const Option *> m_map;
+ ucl::HashMap<void *, int> m_map;
ucl::ElmWidgetSRef m_widget;
IListenerWRef m_listener;
Ecore_Timer *m_timer;
diff --git a/gallery/presenters/pages/PreviewPage.cpp b/gallery/presenters/pages/PreviewPage.cpp
index 75b2d83..a406a4f 100644
--- a/gallery/presenters/pages/PreviewPage.cpp
+++ b/gallery/presenters/pages/PreviewPage.cpp
@@ -550,9 +550,9 @@ namespace gallery {
}
void PreviewPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
- const MoreOptionsPresenter::Option &option)
+ const int optionId)
{
- switch (option.id) {
+ switch (optionId) {
case impl::MORE_OPTION_ID_DELETE:
sender.setOpenedDelayed(false, impl::POPUP_SHOW_TIME_SEC);
confirmItemsDelete();
@@ -563,7 +563,7 @@ namespace gallery {
break;
default:
sender.setOpened(false);
- WLOG("Unknown option id: %d;", option.id);
+ WLOG("Unknown option id: %d;", optionId);
break;
}
}
diff --git a/gallery/presenters/pages/PreviewPage.h b/gallery/presenters/pages/PreviewPage.h
index 21a6391..600d51d 100644
--- a/gallery/presenters/pages/PreviewPage.h
+++ b/gallery/presenters/pages/PreviewPage.h
@@ -129,7 +129,7 @@ namespace gallery {
// MoreOptionsPresenter::IListener //
virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
- const MoreOptionsPresenter::Option &option) final override;
+ int optionId) final override;
// SelectModePresenter::IListener //
diff --git a/gallery/presenters/pages/ThumbnailPage.cpp b/gallery/presenters/pages/ThumbnailPage.cpp
index 2ae0130..f33effb 100644
--- a/gallery/presenters/pages/ThumbnailPage.cpp
+++ b/gallery/presenters/pages/ThumbnailPage.cpp
@@ -319,9 +319,9 @@ namespace gallery {
}
void ThumbnailPage::onMoreOptionClicked(MoreOptionsPresenter &sender,
- const MoreOptionsPresenter::Option &option)
+ const int optionId)
{
- switch (option.id) {
+ switch (optionId) {
case impl::MORE_OPTION_ID_DELETE:
sender.setOpenedDelayed(false, impl::NAVIFRAME_TRANSITION_TIME_SEC);
m_page = PreviewPage::Builder().
@@ -334,7 +334,7 @@ namespace gallery {
break;
default:
sender.setOpened(false);
- WLOG("Unknown option id: %d;", option.id);
+ WLOG("Unknown option id: %d;", optionId);
break;
}
}
diff --git a/gallery/presenters/pages/ThumbnailPage.h b/gallery/presenters/pages/ThumbnailPage.h
index 05f97f0..2eb52ec 100644
--- a/gallery/presenters/pages/ThumbnailPage.h
+++ b/gallery/presenters/pages/ThumbnailPage.h
@@ -84,7 +84,7 @@ namespace gallery {
// MoreOptionsPresenter::IListener //
virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
- const MoreOptionsPresenter::Option &option) final override;
+ int optionId) final override;
private:
class RealizedItem;