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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
import Ubuntu.Components.ListItems 0.1

Page {
    id: root

    property var event;

    anchors.fill: parent
    anchors.margins: units.gu(2)

    Component.onCompleted: {
        if( pageStack.header )
            pageStack.header.visible = false;
        showEvent(event);
    }

    Component.onDestruction: {
        if( pageStack.header )
            pageStack.header.visible = true;
    }

    function showEvent(e) {
        // FIXME: temp location in case there is no vanue is defined
        var location="-15.800513,-47.91378";
        //var location ="Terry' Cafe, 158 Great Suffold St, London, SE1 1PE";

        // TRANSLATORS: this is a time formatting string,
        // see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
        var timeFormat = i18n.tr("hh:mm");
        var startTime = e.startDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
        var endTime = e.endDateTime.toLocaleTimeString(Qt.locale(), timeFormat);
        // TRANSLATORS: the first argument (%1) refers to a start time for an event,
        // while the second one (%2) refers to the end time
        timeLabel.text =  i18n.tr("%1 - %2").arg(startTime).arg(endTime);
        var dateFormat = i18n.tr("ddd, d MMMM");
        dateLabel.text = e.startDateTime.toLocaleDateString(Qt.locale(),dateFormat);

        if( e.displayLabel) {
            titleLabel.text = e.displayLabel;
        }

        if( e.location ) {
            locationLabel.text = e.location;
        }

        if( e.description ) {
            descLabel.text = e.description;
        }

        var attendees = e.attendees;

        contactModel.clear();
        if( attendees !== undefined ) {
            for( var j = 0 ; j < attendees.length ; ++j ) {
                contactModel.append( {"name": attendees[j].name } );
            }
        }

        // FIXME: need to cache map image to avoid duplicate download every time
        var imageSrc = "http://maps.googleapis.com/maps/api/staticmap?center="+location+
                "&markers=color:blue|"+location+"&zoom=15&size="+mapContainer.width+
                "x"+mapContainer.height+"&sensor=false";
        mapImage.source=imageSrc;
    }

    tools: ToolbarItems {
        ToolbarButton {
            action: Action {
                text: i18n.tr("Add invite");
                onTriggered: {
                    print(text + " not implemented");
                }
            }
        }

        ToolbarButton {
            action:Action {
                text: i18n.tr("Edit");
                onTriggered: {
                    print(text + " not implemented");
                }
            }
        }
    }

    Column{
        anchors.fill: parent
        spacing: units.gu(1)

        Item{
            width: parent.width
            height: timeLabel.height
            Label{
                id: timeLabel
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                fontSize: "large"
            }
            Label{
                id: dateLabel
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                fontSize: "small"
            }
        }

        Label{
            id: titleLabel
            fontSize: "x-large"
            width: parent.width
            wrapMode: Text.WordWrap
        }
        ThinDivider{}

        Label{
            id: descLabel
            // FIXME: temporaty text, in ui there is no field to enter message
            text:"Hi both, please turn up on time, it gets really busy by 1pm! Anna x"
            wrapMode: Text.WordWrap
            fontSize: "medium"
            width: parent.width
        }

        //map control with location
        Rectangle{
            id: mapContainer
            width:parent.width
            height: units.gu(25)
            Image {
                id: mapImage
                anchors.fill: parent
                opacity: 0.5
            }
            Label{
                id:locationLabel
                wrapMode: Text.WordWrap
                fontSize: "medium"
                width: parent.width
                //color:"#c94212"
                color:"black"

                anchors {
                    left: parent.left
                    leftMargin: units.gu(1)
                    bottom: parent.bottom
                    bottomMargin: units.gu(1)
                }
            }
        }

        Label{
            text: i18n.tr("People");
            fontSize: "small"
        }
        ThinDivider{}

        //contact list view
        ListView {
            id:contactList
            width: parent.width
            height:  {
                var height = parent.height;
                //not considering the list view it self
                for( var i = 0; i < parent.children.length - 1 ; ++i) {
                    height -= parent.children[i].height;
                }
                height -= parent.children.length * parent.spacing;
            }
            clip: true
            model: ListModel {
                id: contactModel
            }

            Label{
                fontSize: "medium"
                visible: contactModel.count <= 0
                anchors.verticalCenter: parent.verticalCenter
            }

            delegate: Standard{
                text: name
                icon: Qt.resolvedUrl("dummy.png")
                progression: true
            }
        }
    }
}