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 Ubuntu.Components 1.1
21
import QtOrganizer 5.0
2
import Ubuntu.Components 0.1
29
9
property int type: narrowType
30
10
property int wideType: 1;
31
11
property int narrowType: 2;
33
property int depthInRow: 0;
34
property int sizeOfRow:0
36
property Flickable flickable;
38
readonly property int minimumHeight: type == wideType
39
? eventDetails.item.timeLabelHeight + /*top-bottom margin*/ units.gu(2)
42
13
signal clicked(var event);
46
17
anchors.fill: parent
50
var offset = parent.width/sizeOfRow;
51
x = (depthInRow) * offset;
52
width = parent.width - x;
67
function assingnBgColor() {
68
if (model && event ) {
69
var collection = model.collection( event.collectionId );
71
if( event.endDateTime >= now) {
72
bg.color = collection.color
74
//if event is on past then add some white color to original color
75
bg.color = Qt.tint( collection.color, "#aaffffff" );
81
function layoutBubbleDetails() {
82
if( !flickable || flickable === undefined ) {
25
Component.onCompleted: {
29
function setDetails() {
30
if(event === null || event === undefined) {
86
if( infoBubble.y < flickable.contentY && infoBubble.height > flickable.height) {
87
var y = (flickable.contentY - infoBubble.y) * 1.2;
88
if( ( y + eventDetails.item.height + units.gu(2)) > infoBubble.height) {
89
y = infoBubble.height - eventDetails.item.height - units.gu(2);
91
eventDetails.item.y = y;
97
sourceComponent: type == wideType ? detailsComponent : undefined
106
property alias timeLabelHeight : timeLabel.height
109
height: detailsColumn.height
118
margins: units.gu(0.5)
123
objectName: "timeLabel"
132
objectName: "titleLabel"
136
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
148
layoutBubbleDetails();
153
onFlickableChanged: {
154
if (flickable && infoBubble.height > flickable.height) {
155
flickable.onContentYChanged.connect(layoutBubbleDetails);
160
if(flickable && infoBubble.height > flickable.height) {
161
flickable.onContentYChanged.connect(layoutBubbleDetails);
170
function setDetails() {
171
if(event === null || event === undefined) {
175
var startTime = event.startDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
176
var endTime = event.endDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
178
if (type === wideType) {
181
descriptionLabel.text = ""
182
//height is less then set only event title
183
if( infoBubble.height > minimumHeight ) {
184
//on wide type show all details
185
if( infoBubble.height > titleLabel.y + titleLabel.height + units.gu(1)) {
186
// TRANSLATORS: the first argument (%1) refers to a start time for an event,
187
// while the second one (%2) refers to the end time
188
var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
189
timeLabel.text = timeString
190
titleLabel.text = event.displayLabel
191
} else if ( event.displayLabel ) {
192
// TRANSLATORS: the first argument (%1) refers to a start time for an event,
193
// while the second one (%2) refers to title of event
194
timeLabel.text = i18n.tr("%1 - %2").arg(startTime).arg(event.displayLabel);
197
if (event.description) {
198
descriptionLabel.text = event.description
199
//descriptionText = event.description
200
//If content is too much don't display.
201
if (infoBubble.height < descriptionLabel.y + descriptionLabel.height + units.gu(1)) {
202
descriptionLabel.text = ""
206
layoutBubbleDetails();
207
} else if (event.displayLabel){
208
eventDetails.item.timeLableText = event.displayLabel;
34
// TRANSLATORS: this is a time formatting string,
35
// see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
36
var timeFormat = i18n.tr("hh:mm");
37
var startTime = event.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat)
38
var endTime = event.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat)
39
// TRANSLATORS: the first argument (%1) refers to a start time for an event,
40
// while the second one (%2) refers to the end time
41
var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
45
descriptionLabel.text = ""
47
if( type == wideType) {
48
timeLabel.text = timeString
50
if( event.displayLabel)
51
titleLabel.text = event.displayLabel;
53
if( event.description)
54
descriptionLabel.text = event.description
56
timeLabel.text = startTime
70
anchors.verticalCenter: parent.verticalCenter
87
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
89
visible: type == wideType
97
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
99
visible: type == wideType
216
104
anchors.fill: parent
218
106
infoBubble.clicked(event);