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

« back to all changes in this revision

Viewing changes to MonthComponentDateDelegate.qml

  • Committer: Kunal Parmar
  • Date: 2015-07-16 14:02:53 UTC
  • mfrom: (622.1.72 ubuntu-calendar-app)
  • Revision ID: pkunal.parmar@gmail.com-20150716140253-vvhhy1dzq0sft4wy
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    property bool showEvent;
11
11
    property alias fontSize: dateLabel.font.pixelSize
12
12
 
 
13
    property bool isSelected: false
 
14
 
13
15
    Loader {
14
 
        sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
 
16
        sourceComponent: (isToday && isCurrentMonth) || isSelected ? highLightComp : undefined
15
17
        onSourceComponentChanged: {
16
 
            width = Qt.binding( function() { return ( dateRootItem.height / 1.5 ); });
 
18
            width = Qt.binding( function() {
 
19
                var width = dateRootItem.height > dateRootItem.width ? dateRootItem.width :dateRootItem.height
 
20
                return ( width / 1.1 );
 
21
            });
17
22
            height = Qt.binding ( function() { return width} );
18
23
            anchors.centerIn = Qt.binding( function() { return dateLabel});
19
24
        }
26
31
        fontSize: root.dateLabelFontSize
27
32
        color: {
28
33
            if( isCurrentMonth ) {
29
 
                if(isToday) {
 
34
                if( isToday || isSelected ) {
30
35
                    "white"
31
36
                } else {
32
37
                    "#5D5D5D"
33
38
                }
34
39
            } else {
35
 
                "#AEA79F"
 
40
                if(isSelected) {
 
41
                    "white"
 
42
                } else {
 
43
                    "#AEA79F"
 
44
                }
36
45
            }
37
46
        }
38
47
    }
58
67
    Component{
59
68
        id: highLightComp
60
69
        UbuntuShape{
61
 
            color: "#DD4814"
 
70
            color: {
 
71
                if( isToday && !isSelected ) {
 
72
                    "#DD4814"
 
73
                } else {
 
74
                    "gray"
 
75
                }
 
76
            }
 
77
 
 
78
            Rectangle{
 
79
                anchors.fill: parent
 
80
                anchors.margins: units.gu(0.5)
 
81
                color: isToday ? "#DD4814" : "darkgray"
 
82
            }
62
83
        }
63
84
    }
64
85
 
65
86
    MouseArea {
66
87
        anchors.fill: parent
67
88
        onPressAndHold: {
68
 
            var selectedDate = new Date();
69
 
            selectedDate.setFullYear(intern.monthStartYear)
70
 
            selectedDate.setMonth(intern.monthStartMonth + 1)
71
 
            selectedDate.setDate(date)
72
 
            selectedDate.setMinutes(60, 0, 0)
73
 
            pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
 
89
            if( isSelected ) {
 
90
                var selectedDate = new Date();
 
91
                selectedDate.setFullYear(intern.monthStartYear)
 
92
                selectedDate.setMonth(intern.monthStartMonth + 1)
 
93
                selectedDate.setDate(date)
 
94
                selectedDate.setMinutes(60, 0, 0)
 
95
                pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
 
96
            }
74
97
        }
75
98
        onClicked: {
76
99
            var selectedDate = new Date(intern.monthStartYear,
77
100
                                        intern.monthStartMonth,
78
101
                                        intern.monthStartDate + index, 0, 0, 0, 0)
79
 
            //If monthView is clicked then open selected DayView
80
 
            if ( isYearView === false ) {
81
 
                root.dateSelected(selectedDate);
82
 
            }
83
 
            //If yearView is clicked then open selected MonthView
84
 
            else {
 
102
            if( isYearView ) {
 
103
                //If yearView is clicked then open selected MonthView
85
104
                root.monthSelected(selectedDate);
 
105
            } else {
 
106
                if( isSelected ) {
 
107
                    //If monthView is clicked then open selected DayView
 
108
                    root.dateSelected(selectedDate);
 
109
                } else {
 
110
                    intern.selectedIndex = index
 
111
                }
86
112
            }
87
113
        }
88
114
    }