File: organizer.qml

package info (click to toggle)
qtpim-opensource-src 5.0~git20201102.f9a8f0fc%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 18,236 kB
  • sloc: cpp: 82,965; xml: 91; makefile: 81; javascript: 67
file content (324 lines) | stat: -rw-r--r-- 13,049 bytes parent folder | download | duplicates (3)
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

import QtQuick 2.0
import QtOrganizer 5.0
import "contents"

Rectangle {
         id: calendar
         width: 400
         height: 640
         property date currentDate:new Date()
         property int year:currentDate.getFullYear()
         property int month:currentDate.getMonth()
         property int day:currentDate.getDate()
         property int hour:currentDate.getHours()
         property int weekDay:currentDate.getDay()
         property string status:currentDate.toDateString()
         property string preState: "MonthView"
         property alias contentArea : contentArea

        color: "#343434";
        Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 }

        state: "MonthView";

        CollectionFilter {
            id: modelCollectionFilter
            ids: {
                var idList = [];
                var list = organizer.collections;
                for (var i = 0; i< list.length; i++) {
                    idList.push(list[i].collectionId);
                }
                return idList;
            }
        }

        DetailFieldFilter {
            id: todoFilter
            detail: Detail.ItemType
            field: Type.FieldType
            value: Type.Todo
        }

        IntersectionFilter {
            id: intersectionFilter
            filters: [modelCollectionFilter]
        }

        SystemPalette { id: activePalette }
        property OrganizerModel organizer:OrganizerModel{
            id: organizer
            manager:"qtorganizer:memory:id=qml"
            startPeriod:'2009-01-01'
            endPeriod:'2012-12-31'
            autoUpdate:true
            filter: intersectionFilter
            Component.onCompleted : {
                if (managerName == "memory")
                    organizer.importItems(Qt.resolvedUrl("contents/test.ics"));
            }
            onItemsFetched: {
                // this is for occurrenceDialog
                console.log("QML --- ITEMS FETCHED" + fetchedItems[0].displayLabel + fetchedItems[0].itemStartTime);
                if (fetchedItems.length == 1) {
                    detailsView.isNewItem = false;
                    detailsView.item = fetchedItems[0];
                    calendar.state = "DetailsView";
                }
            }
        }

        InfoBar {
            id: infoBar;
            anchors {
                left: parent.left; right: parent.right; top: parent.top
            }
            height: 20
        }

        MenuBar {
            id: menuBar;
            anchors {
                left: parent.left; right: parent.right; top: infoBar.bottom
            }
            height: 35; opacity: 0.9
            info: organizer.error + "\nTotal:" + organizer.itemCount
        }

        StatusBar {
            id: statusBar; status:calendar.status; width: parent.width; height: 35; opacity: 0.9; anchors.bottom: calendar.bottom
            onLeftClicked: {
                if (calendar.state == "MonthView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month - 1, calendar.day);
                } else if (calendar.state == "WeekView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day - 7);
                } else if (calendar.state == "DayView" || calendar.state == "TimelineView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day - 1);
                }

            }

            //rightClick
            onRightClicked: {
                if (calendar.state == "MonthView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month + 1, calendar.day);
                } else if (calendar.state == "WeekView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day + 7);
                } else if (calendar.state == "DayView" || calendar.state == "TimelineView") {
                    calendar.currentDate = new Date(calendar.year, calendar.month , calendar.day + 1);
                }
            }

            //add new item clicked
            onAddClicked : {
                calendar.preState = calendar.state;
                if (calendar.state == "SettingsView" && settingsView.state == "CollectionManagerView") {
                    settingsView.collectionManagerView.addCollection();
                } else {
                    calendar.state = "AddNewItemSelectView";
                }
            }
        }

        states: [
            State {name: "MonthView"; PropertyChanges { target: monthView; opacity: 1; }},
            State {name: "TimelineView"; PropertyChanges { target: timelineView; opacity: 1; }},
            State {name: "WeekView"; PropertyChanges { target: weekView; opacity: 1; }},
            State {name: "DayView"; PropertyChanges { target: dayView; opacity: 1; }},
            State {name: "AgenderView"; PropertyChanges { target: agenderView; opacity: 1; }},
            State {
                name: "DetailsView";
                PropertyChanges { target: detailsView; opacity: 1;}
                PropertyChanges { target: statusBar; opacity: 0; }
            },
            State {name: "AddNewItemSelectView"; PropertyChanges { target: addNewItemview; opacity: 0.8; }},
            State {name: "OccurrenceDialogView"; PropertyChanges { target: occurrenceDialog; opacity: 0.8; }},
            State {name: "TodoView"; PropertyChanges { target: todoView; opacity: 1; }},
            State {name: "AttendeeDetailsView"; PropertyChanges { target: attendeeDetailsView; opacity: 1; }},
            State {name: "SettingsView"; PropertyChanges { target: settingsView; opacity: 1; }}
        ]
        transitions: [
            Transition {
                NumberAnimation {
                    properties: "opacity"
                    easing.type: "Linear"
                    duration: 10
                }
            }
        ]

        // some views are based on certain filters
        onStateChanged: {
            if (state == "TodoView") {
                intersectionFilter.filters = [todoFilter, modelCollectionFilter];
            } else if (intersectionFilter.filters.length != 1) {
                // No need to change the filter if filter is the same
                // (Currently changing the filter triggers also a full update.)
                intersectionFilter.filters = [modelCollectionFilter];
            }
        }

        Item {
            id: contentArea;
            anchors.top: menuBar.bottom;
            anchors.left: calendar.left;
            anchors.right: calendar.right;
            anchors.bottom: (statusBar.opacity != 0) ? statusBar.top : statusBar.bottom;

            MonthView {
                id: monthView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                month:calendar.month
                year:calendar.year
                anchors.fill: contentArea;
            }
            TimelineView {
                id: timelineView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                anchors.fill: contentArea;
            }
            WeekView {
                id: weekView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                anchors.fill: contentArea;
            }
            DayView {
                id: dayView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                anchors.fill: contentArea;
            }

            AgenderView {
                id: agenderView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                anchors.fill: contentArea;
            }
            DetailsView {
                id: detailsView;
                width: calendar.width;
                height: calendar.height - menuBar.height - statusBar.height;
                opacity: 0;
                anchors.fill: contentArea;
            }
            SelectionView {
                id: addNewItemview;
                title: "Select type:"

                model: VisualItemModel {
                    Button {
                        text: "New event"
                        width: addNewItemview.width / 2
                        onClicked: {
                            detailsView.isNewItem = true;
                            detailsView.item = createEmptyItem(Type.Event);
                            detailsView.item.displayLabel = "Event"+(organizer.itemCount+1)
                            calendar.state = "DetailsView";
                        }
                    }
                    Button {
                        text: "New todo-item"
                        width: addNewItemview.width / 2
                        onClicked: {
                            detailsView.isNewItem = true;
                            detailsView.item = createEmptyItem(Type.Todo);
                            detailsView.item.displayLabel = "Todo"+(organizer.itemCount+1)
                            calendar.state = "DetailsView";
                        }
                    }
                    Button {
                        text: "Cancel"
                        width: addNewItemview.width / 2
                        onClicked: {
                            calendar.state = calendar.preState;
                        }
                    }

                }
            }
            SelectionView {
                id: occurrenceDialog;
                //title: "This is a recurring item. Open this instance or whole series?"
                title: "Recurring item"

                model: VisualItemModel {
                    Button {
                        text: "Open this instance"
                        width: addNewItemview.width / 2
                        onClicked: {
                            calendar.state = "DetailsView";
                        }
                    }
                    Button {
                        text: "Open whole series"
                        width: addNewItemview.width / 2
                        onClicked: {
                            var parentDetail = detailsView.item.detail(Detail.Parent);
                            organizer.fetchItems([parentDetail.parentId]);
                        }
                    }
                }
            }
            TodoView {
                id: todoView;
            }
            AttendeeDetailsView {
                id: attendeeDetailsView;
            }
            SettingsView {
                id: settingsView;
            }
        }

        function createEmptyItem(type)
        {
            if (type == Type.Event) {
                return Qt.createQmlObject("import QtOrganizer 5.0; Event { }", organizer);
            } else if (type == Type.Todo) {
                return Qt.createQmlObject("import QtOrganizer 5.0; Todo { }", organizer);
    //        } else if (type == Type.EventOccurrence) {
    //            return Qt.createQmlObject("import QtOrganizer 5.0; EventOccurrence { }", organizer);
    //        } else if (type == Type.TodoOccurrence) {
    //            return Qt.createQmlObject("import QtOrganizer 5.0; TodoOccurrence { }", organizer);
            } else {
                return Qt.createQmlObject("import QtOrganizer 5.0; Event { }", organizer);
            }
        }
}