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

« back to all changes in this revision

Viewing changes to MonthComponentDateDelegate.qml

  • Committer: Tarmac
  • Author(s): Mihir Soni
  • Date: 2014-10-22 18:27:38 UTC
  • mfrom: (519.1.3 limitLablesModel)
  • Revision ID: tarmac-20141022182738-g8jxgtygmunt7y6g
Moved limitLabels from object to ListModel.

Approved by Kunal Parmar, Ubuntu Phone Apps Jenkins Bot, Arto Jalkanen.

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
 
 
12
 
    Loader {
13
 
        width: parent.width < parent.height ? parent.width : parent.height
14
 
        height: width
15
 
        anchors.centerIn: columns
16
 
        sourceComponent: isToday && isCurrentMonth ? highLightComp : undefined
17
 
    }
18
 
 
19
 
    Column {
20
 
        id: columns
21
 
        anchors.centerIn: parent
22
 
        width: parent.width
23
 
        spacing: units.gu(0.5)
24
 
        Label {
25
 
            id: dateLabel
26
 
            text: date
27
 
            //horizontalAlignment: Text.AlignHCenter
28
 
            anchors.horizontalCenter: parent.horizontalCenter
29
 
            fontSize: root.dateLabelFontSize
30
 
            color: {
31
 
                if( isCurrentMonth ) {
32
 
                    if(isToday) {
33
 
                        "white"
34
 
                    } else {
35
 
                        "#5D5D5D"
36
 
                    }
37
 
                } else {
38
 
                    "#AEA79F"
39
 
                }
40
 
            }
41
 
        }
42
 
 
43
 
        Loader{
44
 
            width: units.gu(1)
45
 
            height: width
46
 
            sourceComponent: showEvent ? eventIndicatorComp : undefined
47
 
            anchors.horizontalCenter: dateLabel.horizontalCenter
48
 
        }
49
 
    }
50
 
 
51
 
    Component{
52
 
        id: eventIndicatorComp
53
 
        Rectangle {
54
 
            anchors.fill: parent
55
 
            radius: height/2
56
 
            color:"#5E2750"
57
 
        }
58
 
    }
59
 
 
60
 
    MouseArea {
61
 
        anchors.fill: parent
62
 
        onPressAndHold: {
63
 
            var selectedDate = new Date();
64
 
            selectedDate.setFullYear(intern.monthStartYear)
65
 
            selectedDate.setMonth(intern.monthStartMonth + 1)
66
 
            selectedDate.setDate(date)
67
 
            selectedDate.setMinutes(60, 0, 0)
68
 
            pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel});
69
 
        }
70
 
        onClicked: {
71
 
            var selectedDate = new Date(intern.monthStartYear,
72
 
                                        intern.monthStartMonth,
73
 
                                        intern.monthStartDate + index, 0, 0, 0, 0)
74
 
            //If monthView is clicked then open selected DayView
75
 
            if ( isYearView === false ) {
76
 
                root.dateSelected(selectedDate);
77
 
            }
78
 
            //If yearView is clicked then open selected MonthView
79
 
            else {
80
 
                root.monthSelected(selectedDate);
81
 
            }
82
 
        }
83
 
    }
84
 
}