/**
* @brief Initializes application.
*/
- int Init();
+ void Init();
/**
* @brief Denitializes application.
model::StopWatch *stop_watch_model_;
model::Timer *timer_model_;
- presenter::AlarmListPresenter *alarm_presenter_;
- presenter::WorldClockPresenter *world_clock_presenter_;
- presenter::StopWatchPresenter *stop_watch_presenter_;
- presenter::TimerPresenter *timer_presenter_;
- presenter::EditAlarmPresenter *edit_presenter_;
- presenter::DeleteAlarmPresenter *delete_presenter_;
- presenter::WorldClockDeletePresenter *world_clock_delete_presenter_;
- presenter::WorldClockReorderPresenter *world_clock_reorder_presenter_;
+ presenter::AlarmListPresenter *alarm_presenter_ = nullptr;
+ presenter::WorldClockPresenter *world_clock_presenter_ = nullptr;
+ presenter::StopWatchPresenter *stop_watch_presenter_ = nullptr;
+ presenter::TimerPresenter *timer_presenter_ = nullptr;
+ presenter::EditAlarmPresenter *edit_presenter_ = nullptr;
+ presenter::DeleteAlarmPresenter *delete_presenter_ = nullptr;
+ presenter::WorldClockDeletePresenter *world_clock_delete_presenter_ = nullptr;
+ presenter::WorldClockReorderPresenter *world_clock_reorder_presenter_ = nullptr;
- view::MainView main_view_;
+ view::MainView *main_view_ = nullptr;
- view::EditAlarmView edit_page_;
- view::DeleteAlarmView delete_page_;
- view::WorldClockDeleteItemsView world_clock_delete_page_;
- view::WorldClockReorderView world_clock_reorder_page_;
+ view::EditAlarmView *edit_page_ = nullptr;
+ view::DeleteAlarmView *delete_page_ = nullptr;
+ view::WorldClockDeleteItemsView *world_clock_delete_page_ = nullptr;
+ view::WorldClockReorderView *world_clock_reorder_page_ = nullptr;
/**
* @brief Creates new "Edit" alarm page.
/**
* @brief intiialized flag
*/
- bool initialized_;
+ bool initialized_ = false;
Ecore_Idler *idler_ = nullptr;
static Eina_Bool IdlerCb(void *data);
* @param it the iterator to element in model to be edited.
* @param view instance which presenter will be managing
*/
- EditAlarmPresenter(model::AlarmList &model, model::AlarmList::Iterator it, view::EditAlarmView &view);
+ EditAlarmPresenter(model::AlarmList &model, model::AlarmList::Iterator it, view::EditAlarmView *view);
/**
* @brief Construct new presenter for new alarm creation.
* @param model AlarmList instance which presenter will be managing
* @param view instance which presenter will be managing
*/
- EditAlarmPresenter(model::AlarmList &model, view::EditAlarmView &view);
+ EditAlarmPresenter(model::AlarmList &model, view::EditAlarmView *view);
~EditAlarmPresenter();
private:
model::AlarmList &model_;
model::AlarmList::Iterator iterator_;
- view::EditAlarmView &view_;
+ view::EditAlarmView *view_ = nullptr;
view::EditAlarmView::AlarmViewInfo info_;
void OnEditDone();
void OnEditCancel();
using std::placeholders::_1;
MainController::MainController(model::AlarmProvider *provider) :
- provider_(provider),
- world_clock_model_(nullptr), stop_watch_model_(nullptr), timer_model_(nullptr),
-
- alarm_presenter_(nullptr), world_clock_presenter_(nullptr), stop_watch_presenter_(nullptr),
- timer_presenter_(nullptr), edit_presenter_(nullptr), delete_presenter_(nullptr),
- world_clock_delete_presenter_(nullptr), world_clock_reorder_presenter_(nullptr),
-
- edit_page_(main_view_), delete_page_(main_view_),
- world_clock_delete_page_(main_view_), world_clock_reorder_page_(main_view_),
-
- initialized_(false)
+ provider_(provider)
{
}
Eina_Bool MainController::IdlerCb(void *data)
{
MainController *controller = static_cast<MainController *>(data);
- MainView *mainView = &(controller->main_view_);
+ MainView *mainView = controller->main_view_;
controller->world_clock_model_ = new model::WorldClock();
controller->world_clock_presenter_ = new WorldClockPresenter(
return ECORE_CALLBACK_CANCEL;
}
-int MainController::Init()
+void MainController::Init()
{
- if (initialized_) return 0;
+ if (initialized_) return;
- alarm_presenter_ = new AlarmListPresenter((AlarmListView *)main_view_.GetView(ALARM), provider_->GetAlarms());
+ main_view_ = new MainView();
+ edit_page_ = new EditAlarmView(*main_view_);
+ delete_page_ = new DeleteAlarmView(*main_view_);
+ world_clock_delete_page_ = new WorldClockDeleteItemsView(*main_view_);
+ world_clock_reorder_page_ = new WorldClockReorderView(*main_view_);
+
+ alarm_presenter_ = new AlarmListPresenter((AlarmListView *)main_view_->GetView(ALARM), provider_->GetAlarms());
idler_ = ecore_idler_add(IdlerCb, this);
std::bind(&MainController::CreateNewWorldClockReorderPage, this, _1)));
initialized_ = true;
-
- return 0;
}
void MainController::Deinit()
delete timer_presenter_;
delete timer_model_;
+ delete edit_page_;
+ delete delete_page_;
+ delete world_clock_delete_page_;
+ delete world_clock_reorder_page_;
+ delete main_view_;
+
connections_.clear();
initialized_ = false;
}
{
delete delete_presenter_;
- delete_presenter_ = new DeleteAlarmPresenter(&delete_page_, provider_->GetAlarms());
+ delete_presenter_ = new DeleteAlarmPresenter(delete_page_, provider_->GetAlarms());
}
void MainController::CreateNewWorldClockDeletePage(utils::Event &e)
{
delete world_clock_delete_presenter_;
- world_clock_delete_presenter_ = new WorldClockDeletePresenter(&world_clock_delete_page_, world_clock_model_);
+ world_clock_delete_presenter_ = new WorldClockDeletePresenter(world_clock_delete_page_, world_clock_model_);
}
void MainController::CreateNewWorldClockReorderPage(Event &e)
{
delete world_clock_reorder_presenter_;
- world_clock_reorder_presenter_ = new WorldClockReorderPresenter(&world_clock_reorder_page_, world_clock_model_);
+ world_clock_reorder_presenter_ = new WorldClockReorderPresenter(world_clock_reorder_page_, world_clock_model_);
}
const double time_truncate_factor = 60 * 1000; // 60 seconds
-EditAlarmPresenter::EditAlarmPresenter(AlarmList &model, AlarmList::Iterator it, view::EditAlarmView& view) :
+EditAlarmPresenter::EditAlarmPresenter(AlarmList &model, AlarmList::Iterator it, view::EditAlarmView *view) :
model_(model), iterator_(it), view_(view)
{
connections_.push_back(
- view_.OnEditDone.Connect(std::bind(&EditAlarmPresenter::OnEditDone, this)));
+ view_->OnEditDone.Connect(std::bind(&EditAlarmPresenter::OnEditDone, this)));
connections_.push_back(
- view_.OnEditCancel.Connect(std::bind(&EditAlarmPresenter::OnEditCancel, this)));
+ view_->OnEditCancel.Connect(std::bind(&EditAlarmPresenter::OnEditCancel, this)));
connections_.push_back(
- view_.OnBackButtonClicked.Connect(std::bind(&EditAlarmPresenter::OnBackButton, this)));
+ view_->OnBackButtonClicked.Connect(std::bind(&EditAlarmPresenter::OnBackButton, this)));
connections_.push_back(
- view_.OnDiscardPopupOptionSelected.Connect(std::bind(&EditAlarmPresenter::OnDiscardPopupOptionClicked, this, _1)))
+ view_->OnDiscardPopupOptionSelected.Connect(std::bind(&EditAlarmPresenter::OnDiscardPopupOptionClicked, this, _1)))
;
if (iterator_ == model_.End()) {
mode_ = EditAlarmView::Mode::Edit;
}
- view_.SetData(info_);
- view_.SetMode(mode_);
- view_.PushPage();
+ view_->SetData(info_);
+ view_->SetMode(mode_);
+ view_->PushPage();
}
-EditAlarmPresenter::EditAlarmPresenter(AlarmList &model, view::EditAlarmView& view) :
+EditAlarmPresenter::EditAlarmPresenter(AlarmList &model, view::EditAlarmView *view) :
EditAlarmPresenter(model, model.End(), view)
{
}
EditAlarmPresenter::~EditAlarmPresenter()
{
- view_.PopPage();
+ view_->PopPage();
}
view::EditAlarmView::AlarmViewInfo EditAlarmPresenter::GetDefaultInfo() const
for (auto it = model_.Begin(); it != end; ++it)
{
if ((it->GetTime().Truncate(time_truncate_factor) == truncated_time) &&
- (it->GetName() == view_.GetData().name))
+ (it->GetName() == view_->GetData().name))
return it;
}
return model_.End();
{
auto alarm = *it;
- SetAlarmProperties(alarm, view_.GetData());
+ SetAlarmProperties(alarm, view_->GetData());
if (alarm.GetWeekFlags().Empty() && alarm.GetTime() < Time::Now())
alarm.Deactivate();
if (model_.Size() == model_.MaxSize()) {
std::string text = Translate::Sprintf("IDS_ALM_BODY_MAXIMUM_NUMBER_OF_ALARMS_HPD_REACHED",
model_.MaxSize());
- view_.ShowPopup(text);
+ view_->ShowPopup(text);
return;
}
- SetAlarmProperties(new_alarm, view_.GetData());
+ SetAlarmProperties(new_alarm, view_->GetData());
if (!new_alarm.GetWeekFlags().Empty() || new_alarm.GetTime() > Time::Now())
new_alarm.Activate();
std::string text = Translate::Sprintf(
"IDS_CLOCK_TPOP_ALARM_ALREADY_SET_FOR_PS_EXISTING_ALARM_UPDATED",
time.Format("hh:mm a").c_str());
- view_.ShowPopup(text);
+ view_->ShowPopup(text);
}
/**
void EditAlarmPresenter::OnEditDone()
{
// get alarm matching time & name entered in view
- auto update_target = GetMatchingAlarm(view_.GetData().name, view_.GetData().time);
+ auto update_target = GetMatchingAlarm(view_->GetData().name, view_->GetData().time);
if (mode_ == EditAlarmView::Mode::Edit) {
// if matching alarm exists and different then edited one
}
}
- view_.PopPage();
+ view_->PopPage();
}
void EditAlarmPresenter::SetAlarmProperties(Alarm &alarm, const EditAlarmView::AlarmViewInfo &data)
void EditAlarmPresenter::OnEditCancel()
{
- view_.PopPage();
+ view_->PopPage();
}
void EditAlarmPresenter::OnDiscardPopupOptionClicked(EditAlarmView::DiscardPopupOption option)
switch (option)
{
case EditAlarmView::DiscardPopupOption::CANCEL:
- view_.HideDiscardPopup();
+ view_->HideDiscardPopup();
break;
case EditAlarmView::DiscardPopupOption::CONFIRM:
- view_.HideDiscardPopup();
- view_.PopPage();
+ view_->HideDiscardPopup();
+ view_->PopPage();
break;
}
}
void EditAlarmPresenter::OnBackButton()
{
- if (view_.IsDiscardPopupVisible())
+ if (view_->IsDiscardPopupVisible())
return;
- if (!CompareAlarmInfoStructures(info_, view_.GetData()))
+ if (!CompareAlarmInfoStructures(info_, view_->GetData()))
{
- view_.ShowDiscardPopup();
+ view_->ShowDiscardPopup();
} else {
- view_.PopPage();
+ view_->PopPage();
}
}