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/>.
20
import QtOrganizer 5.0
21
import Ubuntu.Components 1.1
22
import "dateExt.js" as DateExt
26
objectName: "AgendaView"
28
property var currentDay: new Date()
30
signal dateSelected(var date);
32
Keys.forwardTo: [eventList]
34
function goToBeginning() {
35
eventList.positionViewAtBeginning();
38
function hasEnabledCalendars() {
39
var enabled_calendars = eventListModel.getCollections().filter( function( item ) {
40
return item.extendedMetaData( "collection-selected" );
43
return !!enabled_calendars.length;
47
id: calendarTodayAction
48
objectName:"todaybutton"
49
iconName: "calendar-today"
50
text: i18n.tr("Today")
52
currentDay = new Date()
59
commonHeaderActions.newEventAction,
60
commonHeaderActions.showCalendarAction,
61
commonHeaderActions.reloadAction
66
startPeriod: currentDay.midnight();
67
endPeriod: currentDay.addDays(30).endOfDay()
68
filter: eventModel.filter
72
blankPolicy: SortOrder.BlanksFirst
73
detail: Detail.EventTime
74
field: EventTime.FieldStartDateTime
75
direction: Qt.AscendingOrder
82
running: eventListModel.isLoading
83
anchors.centerIn: parent
88
id: noEventsOrCalendarsLabel
90
var default_title = i18n.tr( "No upcoming events" );
92
if ( !root.hasEnabledCalendars() ) {
93
default_title = i18n.tr("You have no calendars enabled")
98
visible: !root.hasEnabledCalendars() || !eventListModel.itemCount
99
anchors.centerIn: parent
103
text: i18n.tr( "Enable calendars" )
104
visible: !root.hasEnabledCalendars()
105
anchors.top: noEventsOrCalendarsLabel.bottom
106
anchors.horizontalCenter: noEventsOrCalendarsLabel.horizontalCenter
107
anchors.topMargin: units.gu( 1.5 )
108
color: UbuntuColors.orange
111
pageStack.push(Qt.resolvedUrl("CalendarChoicePopup.qml"),{"model":eventModel});
112
pageStack.currentPage.collectionUpdated.connect(eventModel.delayedApplyFilter);
118
model: eventListModel
120
visible: eventListModel.itemCount > 0
122
delegate: listDelegate
126
flickableItem: eventList
127
align: Qt.AlignTrailing
135
property var event: eventListModel.items[index];
138
height: container.height
144
function setDetails() {
145
if(event === null || event === undefined) {
149
headerContainer.visible = false;
151
headerContainer.visible = true;
153
var prevEvent = eventListModel.items[index-1];
154
if( prevEvent.startDateTime.midnight() < event.startDateTime.midnight()) {
155
headerContainer.visible = true;
159
var date = event.startDateTime.toLocaleDateString()
160
var startTime = event.startDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
161
var endTime = event.endDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
163
// TRANSLATORS: the first argument (%1) refers to a start time for an event,
164
// while the second one (%2) refers to the end time
165
var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
168
timeLabel.text = timeString
169
header.color = event.startDateTime.toLocaleDateString() === new Date().toLocaleDateString() ? UbuntuColors.orange : UbuntuColors.darkGrey
170
detailsContainer.color = eventListModel.collection(event.collectionId).color
172
if( event.displayLabel) {
173
titleLabel.text = event.displayLabel;
181
height: detailsContainer.height + headerContainer.height +
182
(headerContainer.visible ? units.gu(2) : units.gu(0.5))
184
spacing: headerContainer.visible ? units.gu(1) : 0
186
anchors.top: parent.top
187
anchors.topMargin: headerContainer.visible ? units.gu(1.5) : units.gu(1)
192
height: visible ? header.height + units.gu(1) : 0
200
elide: Text.ElideRight
204
leftMargin: units.gu(1)
205
verticalCenter: parent.verticalCenter
212
dateSelected(event.startDateTime);
226
height: detailsColumn.height + units.gu(1)
227
borderSource: "radius_ide.sci"
232
when: mouseArea.pressed
235
target: detailsContainer
236
borderSource: "radius_pressed.sci"
248
margins: units.gu(0.5)
266
elide: Text.ElideRight
267
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
281
pageStack.push(Qt.resolvedUrl("EventDetails.qml"), {"event":event,"model":eventListModel});