~pkunal-parmar/ubuntu-calendar-app/Minor-Performance

« back to all changes in this revision

Viewing changes to MonthComponentDateDelegate.qml

  • Committer: David Planella
  • Date: 2013-06-12 15:47:15 UTC
  • mfrom: (44 trunk)
  • mto: This revision was merged to the branch mainline in revision 50.
  • Revision ID: david.planella@ubuntu.com-20130612154715-8g4yecfgim9dh38q
Merged from trunk, renamed autopilot tests to follow the same calendar-app naming convention

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import QtQuick 2.0
2
 
import Ubuntu.Components 1.1
3
 
 
4
 
Item{
5
 
    id: dateRootItem
6
 
 
7
 
    property int date;
8
 
    property bool isCurrentMonth;
9
 
    property bool isToday
10
 
 
11
 
    property alias fontSize: dateLabel.font.pixelSize
12
 
 
13
 
    Loader {
14
 
        sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
15
 
        onSourceComponentChanged: {
16
 
            width =  Qt.binding( function() { return parent.width < parent.height ? parent.width : parent.height } );
17
 
            height = Qt.binding ( function() { return width} );
18
 
            anchors.centerIn = Qt.binding( function() { return parent});
19
 
        }
20
 
    }
21
 
 
22
 
    Label {
23
 
        id: dateLabel
24
 
        anchors.centerIn: parent
25
 
        width: parent.width
26
 
        text: date
27
 
        horizontalAlignment: Text.AlignHCenter
28
 
        color: {
29
 
            if( isCurrentMonth ) {
30
 
                if(isToday) {
31
 
                    "white"
32
 
                } else {
33
 
                    "#5D5D5D"
34
 
                }
35
 
            } else {
36
 
                "#AEA79F"
37
 
            }
38
 
        }
39
 
    }
40
 
 
41
 
    Loader{
42
 
        property bool shouldLoad: showEvents
43
 
                                  && intern.eventStatus !== undefined
44
 
                                  && intern.eventStatus[index] !== undefined
45
 
                                  &&intern.eventStatus[index]
46
 
        sourceComponent: shouldLoad ? eventIndicatorComp : undefined
47
 
        onSourceComponentChanged: {
48
 
            anchors.top = Qt.binding( function() { return dateLabel.bottom } );
49
 
            anchors.horizontalCenter =  Qt.binding( function () { return dateLabel.horizontalCenter } );
50
 
        }
51
 
    }
52
 
 
53
 
    MouseArea {
54
 
        anchors.fill: parent
55
 
        onPressAndHold: {
56
 
            var selectedDate = new Date();
57
 
            selectedDate.setFullYear(intern.monthStartYear)
58
 
            selectedDate.setMonth(intern.monthStartMonth + 1)
59
 
            selectedDate.setDate(date)
60
 
            selectedDate.setMinutes(60, 0, 0)
61
 
            pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
62
 
        }
63
 
        onClicked: {
64
 
            var selectedDate = new Date(intern.monthStartYear,
65
 
                                        intern.monthStartMonth,
66
 
                                        intern.monthStartDate + index, 0, 0, 0, 0)
67
 
            //If monthView is clicked then open selected DayView
68
 
            if ( isYearView === false ) {
69
 
                root.dateSelected(selectedDate);
70
 
            }
71
 
            //If yearView is clicked then open selected MonthView
72
 
            else {
73
 
                root.monthSelected(selectedDate);
74
 
            }
75
 
        }
76
 
    }
77
 
}