void UpdateBackgroundLabel();
std::map<int, std::reference_wrapper<model::Alarm>> alarms_;
std::vector<utils::Listener> listeners_;
+ bool CheckModelSizeLimit();
};
} /* presenters */
void ShowNoAlarmsBackgroundLabel();
void HideNoAlarmsBackgroundLabel();
+
+ /**
+ * @brief Shows popup window with specified text
+ */
+ void ShowPopup(const std::string &text);
private:
static Elm_Genlist_Item_Class alarm_itc;
static Evas_Object *ContentGet(void *data, Evas_Object *obj, const char *part);
msgid "IDS_CLOCK_MAX_RECORDS_REACHED_POPUP_ABB"
msgstr "Maximum number of stopwatch records (%d) reached."
+msgid "IDS_CLOCK_TPOP_CANT_ADD_MORE_THEN_PD_ALARMS"
+msgstr "Can't add more then %d alarms."
using namespace utils;
using std::placeholders::_1;
+const int AVAILABLE_ALARMS_MAX = 20;
+
AlarmPresenter::AlarmPresenter(AlarmView *v, AlarmProvider *m) : view(v), model(m)
{
view->SetButtonClickedCallback(std::bind(&AlarmPresenter::OnAddButtonClicked, this));
void AlarmPresenter::OnAddButtonClicked()
{
AlarmCreateRequestEvent ev;
+ char buf[64];
+
+ if (!CheckModelSizeLimit()) {
+ snprintf(buf, sizeof(buf), _("IDS_CLOCK_TPOP_CANT_ADD_MORE_THEN_PD_ALARMS"),
+ AVAILABLE_ALARMS_MAX);
+ view->ShowPopup(buf);
+ return;
+ }
EventBus::FireEvent(ev);
}
}
}
}
+
+bool AlarmPresenter::CheckModelSizeLimit()
+{
+ if (AlarmProvider::GetInstance()->GetAlarms().size() >= AVAILABLE_ALARMS_MAX ) {
+ return false;
+ }
+ return true;
+}
+
using namespace model;
using namespace utils;
-
EditAlarmPresenter::EditAlarmPresenter(model::Alarm *alarm, view::EditAlarmView& view) :
alarm_(alarm), view_(view)
{
#include <efl_extension.h>
#include "Utils/Log.h"
+#include "Utils/PopupManager.h"
using namespace view;
using namespace model;
label_ = nullptr;
}
}
+
+void AlarmView::ShowPopup(const std::string &text)
+{
+ PopupManager::CreatePopup(*this, text);
+}