bool MoreOptionsPresenter::Builder::isEmpty() const
{
- return ucl::isEmpty(m_options);
+ using ucl::isEmpty;
+ return isEmpty(m_options);
}
MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::clear()
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;
}
"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;
// MoreOptionsPresenter //
- MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
- const MoreOptionsCSRef &options) :
+ MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc) :
GuiPresenter(rc),
- m_options(options),
m_timer(nullptr),
m_newOpenedState(false)
{
}
Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
- ElmWidget &parentWidget)
+ ElmWidget &parentWidget, const std::list<Option> &options)
{
FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
"GuiPresenter::prepare() failed!");
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!");
}
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;
}
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!");
}
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!");
}
ucl::LayoutTheme iconTheme;
};
- using MoreOptions = std::list<Option>;
-
class Builder final {
public:
Builder();
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) {};
};
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);
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;