Objects deletion added.
Change-Id: Icd00dcdd41e8da6a2deeea2de4a9c933277dabba
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
#include "Utils/EventBus.h"
+#include "View/AlarmView.h"
+#include "View/StopWatchView.h"
+#include "View/TimerView.h"
+#include "View/WorldClockView.h"
+
+#include "Model/AlarmProvider.h"
+#include "Model/StopWatch.h"
+#include "Model/Timer.h"
+#include "Model/WorldClock.h"
+
+#include "Presenter/AlarmPresenter.h"
+#include "Presenter/StopWatchPresenter.h"
+#include "Presenter/TimerPresenter.h"
+#include "Presenter/WorldClockPresenter.h"
+
+
/**
* @file MainController.h
*/
* @brief Creates new "Delete" alarm page.
*/
void CreateNewDeleteAlarmsPage(utils::Event *e);
+
+ model::WorldClock *world_clock_model_;
+ model::StopWatch *stop_watch_model_;
+ model::Timer *timer_model_;
+
+ presenter::AlarmPresenter *alarm_presenter_;
+ presenter::WorldClockPresenter *world_clock_presenter_;
+ presenter::StopWatchPresenter *stop_watch_presenter_;
+ presenter::TimerPresenter *timer_presenter_;
+
};
}
* @brief Constructs the WorldClock object. It will also load UserLocation list from preferences.
*/
WorldClock();
-
- /*
- * @brief Locations list made of locations(cities) chosen by user.
- */
+ ~WorldClock(){};
std::vector<model::Location> UserLocations;
/*
namespace view {
+ enum ViewType {
+ ALARM,
+ WORLD_CLOCK,
+ STOP_WATCH,
+ TIMER
+ };
+
/**
* @brief Application main view class
* @remarks This is singleton class.
* @remarks Customized for singleton purpose - make no effect.
*/
void operator=(MainView const&) = delete;
+
+ /**
+ * @brief Retrieves view by its type
+ * @param[in] type type of the view
+ * @return view
+ */
+ IView *GetView(ViewType type);
private:
/**
int MainController::Init()
{
- MainView::GetInstance();
+ world_clock_model_ = new model::WorldClock();
+ stop_watch_model_ = new model::StopWatch();
+ timer_model_ = new model::Timer();
+
MainView::GetInstance().CreateContent();
+ alarm_presenter_ = new AlarmPresenter((AlarmView *)MainView::GetInstance().GetView(ALARM), AlarmProvider::GetInstance());
+ world_clock_presenter_ = new WorldClockPresenter((WorldClockView *)MainView::GetInstance().GetView(WORLD_CLOCK), world_clock_model_);
+ stop_watch_presenter_ = new StopWatchPresenter((StopWatchView *)MainView::GetInstance().GetView(STOP_WATCH), stop_watch_model_);
+ timer_presenter_ = new TimerPresenter((TimerView *)MainView::GetInstance().GetView(TIMER), timer_model_);
+
+
EventBus::RegisterHandler(AlarmCreateRequestEvent::EventType(),
std::bind(&MainController::CreateNewAlarmPage, this, _1));
EventBus::RegisterHandler(AlarmDeleteRequestEvent::EventType(),
void MainController::Deinit()
{
+ delete alarm_presenter_;
+
+ delete world_clock_presenter_;
+ delete world_clock_model_;
+
+ delete stop_watch_presenter_;
+ delete stop_watch_model_;
+
+ delete timer_presenter_;
+ delete timer_model_;
+
EventBus::DeregisterHandler(AlarmCreateRequestEvent::EventType(),
std::bind(&MainController::CreateNewAlarmPage, this, _1));
EventBus::DeregisterHandler(AlarmDeleteRequestEvent::EventType(),
MainView::~MainView()
{
+ delete alarm_;
+ delete world_clock_;
+ delete stop_watch_;
+ delete timer_ ;
}
void MainView::ConformantAdd()
DBG("NaviframeAdd END");
}
-
void MainView::CreatePages()
{
- AlarmView *alarm = new AlarmView();
- new AlarmPresenter(alarm, AlarmProvider::GetInstance());
- alarm_ = alarm;
-
- WorldClockView *worldClock = new WorldClockView();
- model::WorldClock *worldClockModel = new model::WorldClock();
- new WorldClockPresenter(worldClock, worldClockModel);
- world_clock_ = worldClock;
-
- StopWatchView *stopWatch = new StopWatchView();
- model::StopWatch *stopWatchModel = new model::StopWatch();
- new StopWatchPresenter(stopWatch, stopWatchModel);
- stop_watch_ = stopWatch;
-
+ alarm_ = new AlarmView();
+ world_clock_ = new WorldClockView();
+ stop_watch_ = new StopWatchView();
timer_ = new TimerView();
-
- TimerView *timer = new TimerView();
- model::Timer *timerModel = new model::Timer();
- new TimerPresenter(timer, timerModel);
- timer_ = timer;
}
+
void MainView::CreateToolbarButtons()
{
elm_toolbar_item_append(toolbar_, Utils::GetAppResourcePath(Utils::APP_DIR_RESOURCE,
return naviframe_;
}
+ui::IView *MainView::GetView(ViewType type)
+{
+ switch (type){
+ case ALARM:
+ return alarm_;
+ case WORLD_CLOCK:
+ return world_clock_;
+ case STOP_WATCH:
+ return stop_watch_;
+ case TIMER:
+ return timer_;
+ default:
+ ERR("Wrong view type!");
+ return NULL;
+ }
+}