summaryrefslogtreecommitdiff
path: root/alarm-app/inc/List/AlarmsView.h
blob: 8128337db351f4494cc5b87b1ecd3cbbcbb63538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * Copyright 2017 Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LIST_ALARMS_VIEW_H
#define LIST_ALARMS_VIEW_H

#include "Common/Model/AlarmProvider.h"
#include "Ux/SelectView.h"
#include <system_settings.h>

namespace Ui
{
	class Genlist;
}

namespace Ux
{
	class MultiSelector;
}

namespace List
{
	class AlarmItem;
	class TitleItem;
	class AddAlarmItem;
	class AlarmsView: public Ux::SelectView
	{
	public:
		/**
		 * @brief Called when Alarm is added
		 * @param   alarmId   Added Alarm ID
		 */
		typedef std::function<void(int alarmId)> AddCallback;

		AlarmsView();
		virtual ~AlarmsView() override;

		/**
		 * @brief Set add Alarm callback.
		 * @param[in]   callback    Add callback
		 */
		void setAddCallback(AddCallback callback);

	private:
		virtual Evas_Object *onCreate(Evas_Object *parent) override;
		virtual void onCreated() override;
		virtual void onPageAttached(Ui::NavigatorPage *page) override;
		virtual void onNavigation(bool isCurrent) override;
		virtual void onSelectModeChanged(Ux::SelectMode selectMode) override;
		virtual void onSelectCountChanged(size_t selectCount) override;
		virtual Evas_Object *createDoneButton() override;
		void onUpdateFinished();

		Evas_Object *createContentLayout(Evas_Object *parent);
		Evas_Object *createNoContents(Evas_Object *parent);
		Evas_Object *createAddButton(Evas_Object *parent);
		void updateEmptyState();

		AlarmItem *createItem(::Model::DataItem &dataItem);
		void insertItem(AlarmItem *alarmItem);

		void onAlarmInserted(::Model::DataItem &dataItem);
		void onAlarmUpdated(AlarmItem *item, int changes);
		void onAlarmDeleted(AlarmItem *item);
		void onAddPressed();
		void onFormatChanged(system_settings_key_e key);
		void onItemLongpressed(Evas_Object *genlist, Elm_Object_Item *item);
		bool onSelectFinished();

		Evas_Object *m_NoContents;
		Evas_Object *m_ContentLayout;
		Ui::Genlist *m_Genlist;
		TitleItem *m_TitleItem;
		AddAlarmItem *m_AddAlarmItem;
		Ux::MultiSelector *m_MultiSelector;
		Common::Model::AlarmProvider m_Provider;

		AddCallback m_OnAlarmAdded;
	};
}

#endif /* LIST_ALARMS_VIEW_H */