2
* Copyright (C) 2014 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
20
import Ubuntu.Components 0.1
21
import Ubuntu.Components.ListItems 0.1 as ListItem
22
import "../common/ClockUtils.js" as Utils
27
// Property to determine the size of the alarms listview height
28
property int maxItemsVisible
30
// Property to store the model of the saved alarm list
31
property alias model: listSavedAlarm.model
33
// Property to help with the dynamic positioning of the alarm list
34
property alias headerHeight: savedAlarmHeader.height
35
property alias dividerHeight: divider.height
37
visible: listSavedAlarm.count !== 0
39
ListItem.ThinDivider { id: divider }
44
text: i18n.tr("Alarms")
45
anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: units.gu(2) }
46
color: Theme.palette.normal.baseText
53
objectName: "listSavedAlarm"
56
anchors { left: parent.left; right: parent.right }
57
height: listAlarm.maxItemsVisible * units.gu(6)
60
delegate: ListItem.Base {
61
objectName: "alarm" + index
64
objectName: "listAlarmTime" + index
66
text: Utils.convertTime(date.getHours(), date.getMinutes(), 0, appSetting.contents.timeFormat)
67
anchors { verticalCenter: parent.verticalCenter; right: alarmStatus.left; rightMargin: units.gu(2) }
68
color: Theme.palette.normal.baseText
73
objectName: "listAlarmLabel" + index
76
elide: Text.ElideRight
80
rightMargin: units.gu(2)
81
leftMargin: units.gu(1);
82
verticalCenter: alarmTime.top;
83
verticalCenterOffset: units.gu(0.4)
85
color: Theme.palette.normal.baseText
90
objectName: "listAlarmSubtitle" + index
92
text: format_day_string(daysOfWeek, type)
93
anchors { left: alarmLabel.left; top: alarmLabel.bottom }
94
color: Theme.palette.normal.backgroundText
99
objectName: "listAlarmStatus" + index
100
checked: model.enabled
101
anchors { right: parent.right; verticalCenter: alarmTime.verticalCenter }
103
var alarm = alarmModel.get(index);
104
alarm.enabled = checked
109
selected: listSavedAlarm.currentIndex == index
114
var alarm = alarmModel.get(index)
118
onClicked: pagestack.push(Qt.resolvedUrl("AddAlarmPage.qml"), {"isNewAlarm": false, "alarmIndex": index})