~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to MonthComponentDateDelegate.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2014-10-22 21:23:07 UTC
  • mfrom: (515.1.7 MonthCompDelegate)
  • Revision ID: tarmac-20141022212307-gyoyiqqcw6pscwom
Moved month component delegate to different file.

Approved by Ubuntu Phone Apps Jenkins Bot, Mihir Soni.

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