class WorldClockView: public ui::IView {
public:
+
+ /**
+ * @brief Enumeration for "More" options menu
+ */
+ enum class MoreMenuOptions {
+ ALL_OPTIONS_DISABLED,
+ DELETE_OPTION_ENABLED = 0x1,
+ REORDER_OPTION_ENABLED = 0x2
+ };
+
WorldClockView(ui::IView &main);
Evas_Object *GetEvasObject(){return world_clock_main_;};
void ShowEmptyListLabel();
void HideEmptyListLabel();
void PostItemExistMessage();
- void ShowMorePopup();
+ /**
+ * @brief Shows more popup.
+ * @param options options mask (see MoreMenuOptions enum)
+ */
+ void ShowMorePopup(MoreMenuOptions options);
/**
* @brief Checks if user locations list is empty or not
*
* @return true if empty, false otherwise
*/
- bool IsListEmpty();
+ int GetItemsCount();
private:
void CreateTimezoneDetails();
std::vector<std::function<void(void)>> signals
= std::vector<std::function<void(void)>>((int)WorldClockSignals::MAX, nullptr);
};
+
+ /**
+ * @brief operator & for WorldClockView::MoreMenuOptions enum class.
+ */
+ inline constexpr int operator &(WorldClockView::MoreMenuOptions a,
+ WorldClockView::MoreMenuOptions b){
+ return static_cast<int>(a) & static_cast<int>(b);
+ }
+
+ /**
+ * @brief operator | for WorldClockView::MoreMenuOptions enum class.
+ */
+ inline constexpr WorldClockView::MoreMenuOptions operator |(WorldClockView::MoreMenuOptions a,
+ WorldClockView::MoreMenuOptions b){
+ return static_cast<WorldClockView::MoreMenuOptions>(static_cast<int>(a) |
+ static_cast<int>(b));
+ }
}
#endif /* _CLOCK_VIEW_WORLDCLOCK_H_ */
void WorldClockPresenter::UpdateEmptyListBackground()
{
- if (view_->IsListEmpty())
+ if (view_->GetItemsCount() == 0)
view_->ShowEmptyListLabel();
else
view_->HideEmptyListLabel();
void WorldClockPresenter::OnMoreButtonClicked()
{
- view_->ShowMorePopup();
+ int cnt = view_->GetItemsCount();
+
+ if (cnt == 0) {
+ INF("the list is empty");
+ view_->ShowMorePopup(WorldClockView::MoreMenuOptions::ALL_OPTIONS_DISABLED);
+ } else if (cnt == 1) {
+ INF("Only one Location in the list. DELETE option allowed only.");
+ view_->ShowMorePopup(WorldClockView::MoreMenuOptions::DELETE_OPTION_ENABLED);
+ } else if (cnt > 1) {
+ INF("DELETE and REORDER options enabled");
+ view_->ShowMorePopup(WorldClockView::MoreMenuOptions::DELETE_OPTION_ENABLED |
+ WorldClockView::MoreMenuOptions::REORDER_OPTION_ENABLED);
+ } else {
+ FAT("User locations list size is a negative number!");
+ }
}
void WorldClockPresenter::OnMoreDeleteButtonClicked()
view->EmitSignal(view::WorldClockSignals::BUTTON_MORE_CLICKED);
}
-void WorldClockView::ShowMorePopup()
+void WorldClockView::ShowMorePopup(MoreMenuOptions options)
{
+ if (!(int)(options | MoreMenuOptions::ALL_OPTIONS_DISABLED)) {
+ INF("Locations list is empty. Options are disabled.");
+ return;
+ }
+
more_popup_ = elm_popup_add(elm_object_top_widget_get(world_clock_main_));
elm_popup_align_set(more_popup_, ELM_NOTIFY_ALIGN_FILL, 1.0);
evas_object_size_hint_weight_set(more_popup_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_list_mode_set(list, ELM_LIST_EXPAND);
evas_object_show(list);
- elm_list_item_append(list, "Delete", NULL, NULL, MorePopupDeleteItemCallback, this);
- elm_list_item_append(list, "Reorder", NULL, NULL, MorePopupReorderItemCallback, this);
+ if (options & MoreMenuOptions::DELETE_OPTION_ENABLED)
+ elm_list_item_append(list, "Delete", NULL, NULL, MorePopupDeleteItemCallback, this);
+ if (options & MoreMenuOptions::REORDER_OPTION_ENABLED)
+ elm_list_item_append(list, "Reorder", NULL, NULL, MorePopupReorderItemCallback, this);
elm_object_content_set(more_popup_, list);
evas_object_show(more_popup_);
}
utils::PopupManager::CreatePopup(*this, "Location already exists in the list", 3);
}
-bool WorldClockView::IsListEmpty()
+int WorldClockView::GetItemsCount()
{
- if (elm_genlist_items_count(custom_locations_list_) > 0)
- return false;
- else
- return true;
+ return elm_genlist_items_count(custom_locations_list_);
}