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

72.2.11 by Kunal Parmar
adding missing files
1
import QtQuick 2.0
2
import Ubuntu.Components 0.1
3
4
import "dateExt.js" as DateExt
5
import "dataService.js" as DataService
6
7
Item{
8
    id: root
72.2.31 by Kunal Parmar
Re-apply revision 98.
9
    objectName: "DayView"
10
72.2.11 by Kunal Parmar
adding missing files
11
    anchors.fill: parent
12
13
    property var currentDay: new Date()
14
15
    PathViewBase{
96.2.2 by Kunal Parmar
final weekview and dayview
16
        id: dayViewPath
17
        objectName: "DayViewPathBase"
18
19
        property var startDay: currentDay.addDays(-1)
20
21
        anchors.top: parent.top
22
        anchors.topMargin: units.gu(1.5)
96.2.4 by Kunal Parmar
merge from trunk
23
72.2.11 by Kunal Parmar
adding missing files
24
        width: parent.width
96.2.2 by Kunal Parmar
final weekview and dayview
25
        height: parent.height - units.gu(3)
72.2.11 by Kunal Parmar
adding missing files
26
27
        onNextItemHighlighted: {
96.2.2 by Kunal Parmar
final weekview and dayview
28
            //next day
29
            currentDay = currentDay.addDays(1);
72.2.11 by Kunal Parmar
adding missing files
30
        }
31
32
        onPreviousItemHighlighted: {
96.2.2 by Kunal Parmar
final weekview and dayview
33
            //previous day
34
            currentDay = currentDay.addDays(-1);
72.2.11 by Kunal Parmar
adding missing files
35
        }
36
96.2.1 by Kunal Parmar
initial version
37
        delegate: TimeLineBaseComponent {
72.2.11 by Kunal Parmar
adding missing files
38
            id: timeLineView
72.2.31 by Kunal Parmar
Re-apply revision 98.
39
            objectName: "DayComponent-"+index
40
96.2.1 by Kunal Parmar
initial version
41
            type: typeDay
42
72.2.11 by Kunal Parmar
adding missing files
43
            width: parent.width
44
            height: parent.height
96.2.4 by Kunal Parmar
merge from trunk
45
96.2.1 by Kunal Parmar
initial version
46
            startDay: getStartDay().addDays(-1);
72.2.11 by Kunal Parmar
adding missing files
47
48
            function getStartDay() {
49
                //previous page
96.2.2 by Kunal Parmar
final weekview and dayview
50
                if (index === dayViewPath.currentIndex) {
51
                    return dayViewPath.startDay;
72.2.11 by Kunal Parmar
adding missing files
52
                }
53
54
                //next page
96.2.2 by Kunal Parmar
final weekview and dayview
55
                var previousIndex = dayViewPath.currentIndex > 0 ? dayViewPath.currentIndex - 1 : 2
72.2.11 by Kunal Parmar
adding missing files
56
                if ( index === previousIndex ) {
96.2.2 by Kunal Parmar
final weekview and dayview
57
                    return dayViewPath.startDay.addDays(2);
72.2.11 by Kunal Parmar
adding missing files
58
                }
59
60
                //current page
96.2.2 by Kunal Parmar
final weekview and dayview
61
                return dayViewPath.startDay.addDays(1);
72.2.11 by Kunal Parmar
adding missing files
62
            }
63
        }
64
    }
65
}