std::map<int, std::reference_wrapper<model::Alarm>> alarms_;
std::vector<utils::Listener> listeners_;
bool CheckModelSizeLimit();
+ void OnMenuButtonClicked();
};
} /* presenters */
typedef std::function<void(int)> SelectCallback;
typedef std::function<void(int)> ToggleCallback;
typedef std::function<void(void)> ButtonClickedCallback;
+ typedef std::function<void(void)> MenuButtonClickedCallback;
AlarmView(ui::IView &main);
void Clear();
void SetItemSelectCallback(SelectCallback func);;
void SetButtonClickedCallback(ButtonClickedCallback func);
void SetDeleteItemClickedCallback(ButtonClickedCallback func) { onDeleteClicked_ = func;}
+ void SetMenuButtonClickedCallback(MenuButtonClickedCallback func) { onMenuClicked_ = func;}
Evas_Object *GetEvasObject();
void ShowNoAlarmsBackgroundLabel();
* @brief Shows popup window with specified text
*/
void ShowPopup(const std::string &text);
+
+ /**
+ * @brief Shows delete popup
+ */
+ void ShowDeletePopup();
+
private:
static Elm_Genlist_Item_Class alarm_itc;
static Evas_Object *ContentGet(void *data, Evas_Object *obj, const char *part);
ToggleCallback onToggled_;
ButtonClickedCallback onClicked_;
ButtonClickedCallback onDeleteClicked_;
- void ShowDeletePopup();
+ MenuButtonClickedCallback onMenuClicked_;
};
}
view->SetDeleteItemClickedCallback(std::bind(&AlarmPresenter::OnDeleteItemClicked, this));
view->SetItemToggleCallback(std::bind(&AlarmPresenter::OnItemActiveStatusChanged, this, _1));
view->SetItemSelectCallback(std::bind(&AlarmPresenter::OnItemSelected, this, _1));
+ view->SetMenuButtonClickedCallback(std::bind(&AlarmPresenter::OnMenuButtonClicked, this));
listeners_.push_back(EventBus::AddListener<AlarmAddedEvent>(
std::bind(&AlarmPresenter::OnAlarmAddedEvent, this, _1)));
EventBus::FireEvent(ev);
}
+void AlarmPresenter::OnMenuButtonClicked()
+{
+ if (alarms_.size() > 0)
+ view->ShowDeletePopup();
+}
+
void AlarmPresenter::OnAlarmRemovedEvent(Event &e)
{
AlarmRemovedEvent &ev = dynamic_cast<AlarmRemovedEvent&>(e);
void AlarmView::MoreButtonClicked(void *data, Evas_Object *obj, void *info)
{
AlarmView *view = static_cast<AlarmView*>(data);
- view->ShowDeletePopup();
+ if (view->onMenuClicked_) view->onMenuClicked_();
}
void AlarmView::Clear()
AlarmView *view = static_cast<AlarmView*>(data);
if (view->onDeleteClicked_) view->onDeleteClicked_();
evas_object_del(view->popup_);
+ view->popup_ = nullptr;
}
void AlarmView::ShowDeletePopup()
{
+ if (popup_) return;
+
popup_ = elm_popup_add(elm_object_top_widget_get(content_));
elm_popup_align_set(popup_, ELM_NOTIFY_ALIGN_FILL, 1.0);
evas_object_size_hint_weight_set(popup_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);