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

« back to all changes in this revision

Viewing changes to MonthComponentDateDelegate.qml

  • Committer: Mihir Soni
  • Date: 2014-10-22 14:03:01 UTC
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: mihirsoni.123@gmail.com-20141022140301-qwow5d82hp0evo1o
Moved Limit Labels to model

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
 
    property bool showEvent;
11
 
    property alias fontSize: dateLabel.font.pixelSize
12
 
 
13
 
    Loader {
14
 
        sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
15
 
        onSourceComponentChanged: {
16
 
            width = Qt.binding( function() { return ( dateRootItem.height / 1.5 ); });
17
 
            height = Qt.binding ( function() { return width} );
18
 
            anchors.centerIn = Qt.binding( function() { return dateLabel});
19
 
        }
20
 
    }
21
 
 
22
 
    Label {
23
 
        id: dateLabel
24
 
        anchors.centerIn: parent
25
 
        text: date
26
 
        fontSize: root.dateLabelFontSize
27
 
        color: {
28
 
            if( isCurrentMonth ) {
29
 
                if(isToday) {
30
 
                    "white"
31
 
                } else {
32
 
                    "#5D5D5D"
33
 
                }
34
 
            } else {
35
 
                "#AEA79F"
36
 
            }
37
 
        }
38
 
    }
39
 
 
40
 
    Loader{
41
 
        width: units.gu(1)
42
 
        height: width
43
 
        anchors.horizontalCenter: parent.horizontalCenter
44
 
        anchors.top: dateLabel.bottom
45
 
        anchors.topMargin: dateRootItem.height/4
46
 
        sourceComponent: showEvent ? eventIndicatorComp : undefined
47
 
    }
48
 
 
49
 
    Component{
50
 
        id: eventIndicatorComp
51
 
        Rectangle {
52
 
            anchors.fill: parent
53
 
            radius: height/2
54
 
            color:"#5E2750"
55
 
        }
56
 
    }
57
 
 
58
 
    Component{
59
 
        id: highLightComp
60
 
        UbuntuShape{
61
 
            color: "#DD4814"
62
 
        }
63
 
    }
64
 
 
65
 
    MouseArea {
66
 
        anchors.fill: parent
67
 
        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});
74
 
        }
75
 
        onClicked: {
76
 
            var selectedDate = new Date(intern.monthStartYear,
77
 
                                        intern.monthStartMonth,
78
 
                                        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 {
85
 
                root.monthSelected(selectedDate);
86
 
            }
87
 
        }
88
 
    }
89
 
}