~timo-jyrinki/ubuntu-calendar-app/use_pickerpanelworkaround_lp1351024

« back to all changes in this revision

Viewing changes to MonthComponent.qml

  • Committer: Kunal Parmar
  • Date: 2014-05-19 08:54:41 UTC
  • mfrom: (274 ubuntu-calendar-app)
  • mto: This revision was merged to the branch mainline in revision 354.
  • Revision ID: pkunal.parmar@gmail.com-20140519085441-rw80fn7schao4tqi
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    property bool showEvents: false
11
11
 
12
12
    property var currentMonth;
 
13
    property var isYearView;
13
14
 
14
15
    property string dayLabelFontSize: "medium"
15
16
    property string dateLabelFontSize: "large"
19
20
    property alias dayLabelDelegate : dayLabelRepeater.delegate
20
21
    property alias dateLabelDelegate : dateLabelRepeater.delegate
21
22
 
 
23
    signal monthSelected(var date);
22
24
    signal dateSelected(var date)
23
25
 
24
26
    height: ubuntuShape.height
56
58
        property int todayMonth: today.getMonth()
57
59
        property int todayYear: today.getFullYear()
58
60
 
59
 
 
60
61
        //date from month will start, this date might be from previous month
61
62
        property var monthStart: currentMonth.weekStart( Qt.locale().firstDayOfWeek )
62
63
        property int monthStartDate: monthStart.getDate()
189
190
                sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
190
191
            }
191
192
 
192
 
            Label{
 
193
            Label {
193
194
                id: dateLabel
194
195
                anchors.centerIn: parent
195
196
                width: parent.width
209
210
                }
210
211
            }
211
212
 
212
 
            Rectangle{
213
 
                width: units.gu(1)
214
 
                height: width
215
 
                radius: height/2
216
 
                color:"#5E2750"
217
 
                visible: showEvents
 
213
            Loader{
 
214
                property bool shouldLoad: showEvents
218
215
                         && intern.eventStatus !== undefined
219
216
                         && intern.eventStatus[index] !== undefined
220
217
                         &&intern.eventStatus[index]
 
218
                sourceComponent: shouldLoad ? eventIndicatorComp : undefined
221
219
                anchors.top: dateLabel.bottom
222
220
                anchors.horizontalCenter: dateLabel.horizontalCenter
223
221
            }
224
222
 
225
 
            MouseArea{
 
223
            MouseArea {
226
224
                anchors.fill: parent
 
225
                onPressAndHold: {
 
226
                    var selectedDate = new Date();
 
227
                    selectedDate.setFullYear(intern.monthStartYear)
 
228
                    selectedDate.setMonth(intern.monthStartMonth + 1)
 
229
                    selectedDate.setDate(date)
 
230
                    selectedDate.setMinutes(60, 0, 0)
 
231
                    pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
 
232
                }
227
233
                onClicked: {
228
 
                    root.dateSelected(new Date(intern.monthStartYear,
229
 
                                               intern.monthStartMonth,
230
 
                                               intern.monthStartDate+index,0,0,0,0));
 
234
                    var selectedDate = new Date(intern.monthStartYear,
 
235
                                                intern.monthStartMonth,
 
236
                                                intern.monthStartDate + index, 0, 0, 0, 0)
 
237
                    //If monthView is clicked then open selected DayView
 
238
                    if ( isYearView === false ) {
 
239
                        root.dateSelected(selectedDate);
 
240
                    }
 
241
                    //If yearView is clicked then open selected MonthView
 
242
                    else {
 
243
                        root.monthSelected(selectedDate);
 
244
                    }
231
245
                }
232
246
            }
233
247
        }
234
248
    }
235
249
 
236
250
    Component{
 
251
        id: eventIndicatorComp
 
252
        Rectangle {
 
253
            width: units.gu(1)
 
254
            height: width
 
255
            radius: height/2
 
256
            color:"#5E2750"
 
257
        }
 
258
    }
 
259
 
 
260
    Component{
237
261
        id: dafaultDayLabelComponent
238
262
 
239
263
        Label{