~chris.gagnon/+junk/qtpim-coverage

« back to all changes in this revision

Viewing changes to tests/system/qmlorganizer/contents/DayView.qml

  • Committer: chris.gagnon
  • Date: 2013-12-10 23:09:37 UTC
  • Revision ID: chris.gagnon@canonical.com-20131210230937-2akf1ft1edcttk87
first post

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the examples of the Qt Mobility Components.
 
7
**
 
8
** $QT_BEGIN_LICENSE:BSD$
 
9
** You may use this file under the terms of the BSD license as follows:
 
10
**
 
11
** "Redistribution and use in source and binary forms, with or without
 
12
** modification, are permitted provided that the following conditions are
 
13
** met:
 
14
**   * Redistributions of source code must retain the above copyright
 
15
**     notice, this list of conditions and the following disclaimer.
 
16
**   * Redistributions in binary form must reproduce the above copyright
 
17
**     notice, this list of conditions and the following disclaimer in
 
18
**     the documentation and/or other materials provided with the
 
19
**     distribution.
 
20
**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
 
21
**     of its contributors may be used to endorse or promote products derived
 
22
**     from this software without specific prior written permission.
 
23
**
 
24
**
 
25
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
26
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
27
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
28
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
29
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
30
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
31
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
32
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
33
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
34
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
35
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 
36
**
 
37
** $QT_END_LICENSE$
 
38
**
 
39
****************************************************************************/
 
40
 
 
41
import QtQuick 2.0
 
42
import QtOrganizer 5.0
 
43
 
 
44
Flickable
 
45
{
 
46
     Rectangle {
 
47
         id : dayView
 
48
 
 
49
         anchors.fill : parent
 
50
         opacity : parent.opacity
 
51
         color: "#9eaf30"
 
52
         gradient: Gradient {
 
53
             GradientStop {
 
54
                 position: 0.00;
 
55
                 color: "#9eaf30";
 
56
             }
 
57
             GradientStop {
 
58
                 position: 0.89;
 
59
                 color: "#ffffff";
 
60
             }
 
61
         }
 
62
 
 
63
         ListView {
 
64
             id : hourList
 
65
             model : hourModel
 
66
             anchors.fill: parent
 
67
             clip: true
 
68
             focus: true
 
69
             opacity : parent.opacity
 
70
 
 
71
             delegate : hourDelegate
 
72
             highlight: hourHighlight
 
73
             preferredHighlightBegin: hourList.height * 0.5
 
74
             preferredHighlightEnd: preferredHighlightBegin
 
75
             highlightFollowsCurrentItem : true
 
76
             highlightMoveSpeed : 2000
 
77
             keyNavigationWraps : true
 
78
 
 
79
             onCurrentIndexChanged : {
 
80
                 if (timelineView.opacity > 0) {
 
81
                     calendar.currentDate = new Date(timelineView.year, timelineView.month, currentIndex + 1);
 
82
                     monthList.currentIndex = timelineView.month;
 
83
                     currentIndex = timelineView.day - 1;
 
84
                 }
 
85
             }
 
86
 
 
87
         }
 
88
         Component {
 
89
             id: hourHighlight
 
90
             Rectangle {
 
91
                 width: hourList.width;
 
92
                 height: hourList.height /7 ;
 
93
                 color: "lightsteelblue" ;radius: 5
 
94
             }
 
95
         }
 
96
 
 
97
         Component {
 
98
             id: hourDelegate
 
99
 
 
100
 
 
101
             Item {
 
102
                 width : hourList.width
 
103
                 height : childrenRect.height
 
104
                 property int rowIndex : index
 
105
                 id:hourDelegateInstanceItem
 
106
 
 
107
                 Column {
 
108
                     // Draw a line under the previous Hour list tiem
 
109
                     Rectangle {
 
110
                         height : 1
 
111
                         width : hourList.width
 
112
                         color : "black"
 
113
                     }
 
114
 
 
115
                     Text {
 
116
                        // text: hour
 
117
                         text: index + ":00"
 
118
                     }
 
119
 
 
120
 
 
121
                     // List all, if any, of the events within this hour.
 
122
                     Repeater {
 
123
 
 
124
                         focus: true
 
125
 
 
126
                         // Simple fetch ALL events on this day...and we will filter them bu hour.
 
127
                         model: calendar.organizer.items? calendar.organizer.itemsByTimePeriod(new Date(calendar.year, calendar.month, calendar.day)
 
128
                                                                                     , new Date(calendar.year, calendar.month, calendar.day+1))
 
129
                                                        : 0
 
130
 
 
131
                         Row {
 
132
                             spacing:  4
 
133
                             Text {
 
134
                                 id: itemText
 
135
                                 clip: true
 
136
                                 focus: true
 
137
 
 
138
                                 // Only display a link when the event starts within this hour......
 
139
                                 text: (hourDelegateInstanceItem.rowIndex == Qt.formatTime(modelData.itemStartTime, "hh")) ? "<a href=\"#\">" + modelData.displayLabel + "</a>":""
 
140
                                 onLinkActivated: {
 
141
                                     detailsView.isNewItem = false;
 
142
                                     detailsView.item = modelData;
 
143
                                     if (detailsView.item.itemType == Type.EventOccurrence || detailsView.item.itemType == Type.TodoOccurrence)
 
144
                                         calendar.state = "OccurrenceDialogView";
 
145
                                     else
 
146
                                         calendar.state = "DetailsView";
 
147
                                 }
 
148
                             }
 
149
                             Rectangle {
 
150
                                 width: 15; height: 15
 
151
                                 anchors { verticalCenter: parent.verticalCenter }
 
152
                                 border { color: "black"; width: 1; }
 
153
                                 visible: (hourDelegateInstanceItem.rowIndex == Qt.formatTime(modelData.itemStartTime, "hh")) ? true : false
 
154
                                 color: calendar.organizer.collection(modelData.collectionId)? calendar.organizer.collection(modelData.collectionId).color : "red"
 
155
                             }
 
156
                         }
 
157
                     }
 
158
                 }
 
159
             }
 
160
 
 
161
         }
 
162
 
 
163
         ListModel {
 
164
             id : hourModel
 
165
             ListElement {hour : "0:00"}
 
166
             ListElement {hour : "1:00"}
 
167
             ListElement {hour : "2:00"}
 
168
             ListElement {hour : "3:00"}
 
169
             ListElement {hour : "4:00"}
 
170
             ListElement {hour : "5:00"}
 
171
             ListElement {hour : "6:00"}
 
172
             ListElement {hour : "7:00"}
 
173
             ListElement {hour : "8:00"}
 
174
             ListElement {hour : "9:00"}
 
175
             ListElement {hour : "10:00"}
 
176
             ListElement {hour : "11:00"}
 
177
             ListElement {hour : "12:00"}
 
178
             ListElement {hour : "13:00"}
 
179
             ListElement {hour : "14:00"}
 
180
             ListElement {hour : "15:00"}
 
181
             ListElement {hour : "16:00"}
 
182
             ListElement {hour : "17:00"}
 
183
             ListElement {hour : "18:00"}
 
184
             ListElement {hour : "19:00"}
 
185
             ListElement {hour : "20:00"}
 
186
             ListElement {hour : "21:00"}
 
187
             ListElement {hour : "22:00"}
 
188
             ListElement {hour : "23:00"}
 
189
         }
 
190
     }
 
191
}