~pkunal-parmar/ubuntu-calendar-app/ICalImport

« back to all changes in this revision

Viewing changes to EventBubble.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2014-10-21 12:58:23 UTC
  • mfrom: (511.1.1 ubuntu-calendar-app)
  • Revision ID: tarmac-20141021125823-y5mmdrzm3lwhnjhc
Resolves Bug #1371869
Event bubbles: do not cut off text vertically. Fixes: https://bugs.launchpad.net/bugs/1371869.

Approved by Mihir Soni, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
 
62
62
    onEventChanged: {
63
63
        resize();
64
 
        setDetails();
65
 
    }
66
 
 
67
 
    Component.onCompleted: {
68
 
        setDetails();
69
 
    }
70
 
 
71
 
    function setDetails() {
72
 
        if(event === null || event === undefined) {
73
 
            return;
74
 
        }
75
 
 
76
 
        var startTime = event.startDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
77
 
        var endTime = event.endDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
78
 
 
79
 
        // TRANSLATORS: the first argument (%1) refers to a start time for an event,
80
 
        // while the second one (%2) refers to the end time
81
 
        var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
82
 
 
83
 
        if (type === wideType) {
84
 
            eventDetails.item.timeLableText= ""
85
 
            eventDetails.item.titleLabelText = ""
86
 
            eventDetails.item.descriptionText.text = ""
87
 
            //height is less then set only event title
88
 
            if( height > minimumHeight ) {
89
 
                //on wide type show all details
90
 
                eventDetails.item.timeLableText = timeString
91
 
                if (event.displayLabel)
92
 
                    eventDetails.item.titleLabelText = event.displayLabel;
93
 
                if (event.description)
94
 
                {
95
 
                    eventDetails.item.descriptionText= event.description
96
 
                    //If content is too much don't display.
97
 
                    if (height < descriptionLabel.height + descriptionLabel.y) {
98
 
                        eventDetails.item.descriptionText.text = ""
99
 
                    }
100
 
                }
101
 
                layoutBubbleDetails();
102
 
 
103
 
            } else {
104
 
                if (event.displayLabel)
105
 
                    eventDetails.item.timeLableText = event.displayLabel;
106
 
            }
107
 
        }
108
 
        if (model) {
 
64
        if (model && event ) {
109
65
            var collection = model.collection( event.collectionId );
110
66
            bg.color = collection.color
111
67
        }
151
107
                    top: parent.top
152
108
                    left: parent.left
153
109
                    right: parent.right
154
 
                    margins: units.gu(1)
 
110
                    margins: units.gu(0.5)
155
111
                }
156
112
 
157
113
                Label {
161
117
                    fontSize:"small"
162
118
                    font.bold: true
163
119
                    width: parent.width
164
 
 
165
120
                }
166
121
 
167
122
                Label {
178
133
                    color: "White"
179
134
                    fontSize: "x-small"
180
135
                    width: parent.width
181
 
                    visible: type == wideType
182
136
                }
183
137
            }
184
138
 
199
153
                        flickable.onContentYChanged.connect(layoutBubbleDetails);
200
154
                    }
201
155
                }
 
156
 
 
157
                onEventChanged: {
 
158
                    setDetails();
 
159
                }
 
160
            }
 
161
 
 
162
            function setDetails() {
 
163
                if(event === null || event === undefined) {
 
164
                    return;
 
165
                }
 
166
 
 
167
                var startTime = event.startDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
 
168
                var endTime = event.endDateTime.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
 
169
 
 
170
                if (type === wideType) {
 
171
                    timeLableText= ""
 
172
                    titleLabelText = ""
 
173
                    descriptionText.text = ""
 
174
                    //height is less then set only event title
 
175
                    if( infoBubble.height > minimumHeight ) {
 
176
                        //on wide type show all details
 
177
                        if( infoBubble.height > titleLabel.y + titleLabel.height + units.gu(1)) {
 
178
                            // TRANSLATORS: the first argument (%1) refers to a start time for an event,
 
179
                            // while the second one (%2) refers to the end time
 
180
                            var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
 
181
                            timeLableText = timeString
 
182
                            titleLabelText = event.displayLabel
 
183
                        } else if ( event.displayLabel ) {
 
184
                            // TRANSLATORS: the first argument (%1) refers to a start time for an event,
 
185
                            // while the second one (%2) refers to title of event
 
186
                            timeLableText = i18n.tr("%1 - %2").arg(startTime).arg(event.displayLabel);
 
187
                        }
 
188
 
 
189
                        if (event.description) {
 
190
                            descriptionText = event.description
 
191
                            //descriptionText = event.description
 
192
                            //If content is too much don't display.
 
193
                            if (infoBubble.height < descriptionLabel.y + descriptionLabel.height + units.gu(1)) {
 
194
                                descriptionText = ""
 
195
                            }
 
196
                        }
 
197
 
 
198
                        layoutBubbleDetails();
 
199
                    } else if (event.displayLabel){
 
200
                        eventDetails.item.timeLableText = event.displayLabel;
 
201
                    }
 
202
                }
202
203
            }
203
204
        }
204
205
    }