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

« back to all changes in this revision

Viewing changes to WeekComponent.qml

  • Committer: Launchpad Translations on behalf of ubuntu-calendar-dev
  • Date: 2014-06-09 06:30:09 UTC
  • Revision ID: launchpad_translations_on_behalf_of_ubuntu-calendar-dev-20140609063009-vf9c9x0iyl0ossr6
Launchpad automatic translations update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
Flickable{
8
 
    id: timeLineView
9
 
 
10
 
    property var weekStart: new Date()
11
 
    property int weekWidth:0;
12
 
 
13
 
    contentHeight: timeLineColumn.height + units.gu(3)
14
 
    contentWidth: width
15
 
 
16
 
    clip: true
17
 
 
18
 
    onWeekStartChanged: {
19
 
        scroll();
20
 
    }
21
 
 
22
 
    function setSelectedDay() {
23
 
        if( intern.now.weekStart( intern.weekstartDay).isSameDay(visibleWeek) ) {
24
 
            intern.selectedDay =  intern.now
25
 
        } else {
26
 
            intern.selectedDay = visibleWeek
27
 
        }
28
 
    }
29
 
 
30
 
    function scroll() {
31
 
        //scroll to 9 o'clock or to now
32
 
        var now = new Date();
33
 
        var hour = 9
34
 
        if( weekStart !== undefined
35
 
                && now.weekStart(Qt.locale().firstDayOfWeek).isSameDay(weekStart)) {
36
 
            hour = now.getHours();
37
 
        }
38
 
 
39
 
        timeLineView.contentY = hour * units.gu(10);
40
 
        if(timeLineView.contentY >= timeLineView.contentHeight - timeLineView.height) {
41
 
            timeLineView.contentY = timeLineView.contentHeight - timeLineView.height
42
 
        }
43
 
    }
44
 
 
45
 
    //scroll in case content height changed
46
 
    onContentHeightChanged: {
47
 
        scroll()
48
 
    }
49
 
 
50
 
    Rectangle{
51
 
        id: background;
52
 
        anchors.fill: parent
53
 
        color: "white"
54
 
    }
55
 
 
56
 
    TimeLineBackground{
57
 
        id: timeLineColumn
58
 
        anchors.top: parent.top
59
 
        anchors.topMargin: units.gu(3)
60
 
        width: parent.width
61
 
    }
62
 
 
63
 
    //vertical lines for weeks
64
 
    Row{
65
 
        id: dayIndicator
66
 
 
67
 
        x: timeLabel.width
68
 
        width: parent.width
69
 
        height: timeLineView.contentHeight
70
 
 
71
 
        Repeater{
72
 
            model:7
73
 
            delegate: Rectangle{
74
 
                height: dayIndicator.height
75
 
                width: weekWidth
76
 
                border.color: "gray"
77
 
                opacity: 0.1
78
 
            }
79
 
        }
80
 
    }
81
 
 
82
 
    Row{
83
 
        id: week
84
 
        width: timeLineColumn.width - x
85
 
        height: timeLineColumn.height
86
 
        anchors.top: parent.top
87
 
        anchors.topMargin: units.gu(3)
88
 
        x: timeLabel.width
89
 
        spacing: 0
90
 
 
91
 
        property var weekStartDay: timeLineView.weekStart.weekStart( Qt.locale().firstDayOfWeek );
92
 
 
93
 
        Repeater{
94
 
            model: 7
95
 
 
96
 
            delegate: TimeLineBase {
97
 
                anchors.top: parent.top
98
 
                height: parent.height
99
 
                width: weekWidth
100
 
                delegate: infoBubbleComponent
101
 
                day: week.weekStartDay.addDays(index)
102
 
            }
103
 
        }
104
 
    }
105
 
 
106
 
    Component{
107
 
        id: infoBubbleComponent
108
 
        Rectangle{
109
 
            id: infoBubble
110
 
 
111
 
            property string title;
112
 
            property string location;
113
 
            property int hour;
114
 
 
115
 
            signal clicked(int hour);
116
 
 
117
 
            color:'#fffdaa';
118
 
            width: weekWidth
119
 
            x: units.gu(0)
120
 
 
121
 
            border.color: "#f4d690"
122
 
 
123
 
            Label{
124
 
                text:infoBubble.title;
125
 
                fontSize:"small";
126
 
                color:"black"
127
 
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
128
 
                width: parent.width
129
 
            }
130
 
 
131
 
            MouseArea{
132
 
                anchors.fill: parent
133
 
                onClicked: {
134
 
                    infoBubble.clicked(hour);
135
 
                }
136
 
            }
137
 
        }
138
 
    }
139
 
}