2
* Copyright (C) 2013-2014 Canonical Ltd
4
* This file is part of Ubuntu Calendar App
6
* Ubuntu Calendar App is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 3 as
8
* published by the Free Software Foundation.
10
* Ubuntu Calendar App is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import Ubuntu.Components 1.1
20
import Ubuntu.Components.Popups 1.0
22
import "dateExt.js" as DateExt
23
import "ViewType.js" as ViewType
28
property var allDayEvents;
29
property var startDay: DateExt.today();
32
property int type: ViewType.ViewTypeWeek
36
function getAllDayEvents(startDate, endDate) {
38
var items = model.getItems(startDate,endDate);
39
for(var i = 0 ; i < items.length ; ++i) {
40
var event = items[(i)];
41
if( event && event.allDay ) {
42
for(var d = event.startDateTime; d <= event.endDateTime; d = d.addDays(1)) {
43
var key = Qt.formatDateTime(d, "dd-MMM-yyyy");
54
function createAllDayEvents() {
55
if(!startDay || startDay === undefined) {
58
var sd = startDay.midnight();
59
var ed = sd.addDays( (type == ViewType.ViewTypeDay) ? 1 : 7);
60
allDayEvents = getAllDayEvents(sd,ed);
64
model: type == ViewType.ViewTypeWeek ? 7 : 1
69
gradient: UbuntuColors.orangeGradient
71
x: type === ViewType.ViewTypeWeek ? root.width/7*index : 0
74
width: parent.width/ (type == ViewType.ViewTypeWeek ? 7 : 1)
75
visible: !allDayButton.events || allDayButton.events.length === 0 ? false : true
78
if(!allDayButton.events || allDayButton.events.length === 0) {
82
if(type == ViewType.ViewTypeWeek) {
83
PopupUtils.open(popoverComponent, root,{"events": allDayButton.events})
85
if( allDayButton.events.length > 1 ) {
86
PopupUtils.open(popoverComponent, root,{"events": allDayButton.events})
88
pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":allDayButton.events[0],"model": root.model});
95
onAllDayEventsChanged:{
96
var sd = startDay.midnight();
97
sd = sd.addDays(index);
98
var key = Qt.formatDateTime(sd, "dd-MMM-yyyy");
99
events = allDayEvents[key];
101
if(!events || events.length === 0) {
106
if(type == ViewType.ViewTypeWeek) {
107
// TRANSLATORS: the first parameter refers to the number of all-day events
108
// on a given day. "Ev." is short form for "Events".
109
// Please keep the translation of "Ev." to 3 characters only, as the week view
110
// where it's shown has limited space
111
text = i18n.tr("%1 ev.").arg(events.length)
113
if( events.length > 1) {
114
// TRANSLATORS: the argument refers to the number of all day events
115
text = i18n.tr("%1 all day event", "%1 all day events", events.length).arg(events.length)
117
text = events[0].displayLabel;
136
property var delegateHight: units.gu(4);
137
property int maxEventToDisplay: 3;
142
height: ( delegateHight * (events.length > maxEventToDisplay ? maxEventToDisplay : events.length) ) + units.gu(1)
143
model: popover.events
145
top: parent.top; topMargin: units.gu(1); bottomMargin: units.gu(1)
149
text: modelData.displayLabel;
150
anchors.horizontalCenter: parent.horizontalCenter
152
height: allDayEventsList.delegateHight
158
pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":modelData,"model": root.model});