summaryrefslogtreecommitdiffstats
path: root/src/imports/organizer/qdeclarativeorganizeritem_p.h
blob: 5c85a2d0533ad31f239dc1fa4ded9d1ba6185f83 (plain)
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtOrganizer module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** 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 Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** 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-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QDECLARATIVEORGANIZERITEM_H
#define QDECLARATIVEORGANIZERITEM_H

#include <QtQml/qqml.h>

#include <QtOrganizer/qorganizeritems.h>

#include "qdeclarativeorganizeritemdetail_p.h"

QTORGANIZER_USE_NAMESPACE

QT_BEGIN_NAMESPACE

class QDeclarativeOrganizerItem : public QObject
{
    Q_OBJECT

    // basic information
    Q_PROPERTY(bool modified READ modified NOTIFY itemChanged)

    Q_PROPERTY(QDeclarativeOrganizerItemType::ItemType itemType READ itemType NOTIFY itemChanged)
    Q_PROPERTY(QQmlListProperty<QDeclarativeOrganizerItemDetail> itemDetails READ itemDetails NOTIFY itemChanged)
    Q_PROPERTY(QString itemId READ itemId NOTIFY itemChanged)
    Q_PROPERTY(QString manager READ manager NOTIFY itemChanged)
    Q_PROPERTY(QString collectionId READ collectionId WRITE setCollectionId NOTIFY itemChanged)

    // convenient access to most frequently used details
    Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY itemChanged)
    Q_PROPERTY(QString displayLabel READ displayLabel WRITE setDisplayLabel NOTIFY itemChanged)
    Q_PROPERTY(QString guid READ guid WRITE setGuid NOTIFY itemChanged)
    Q_CLASSINFO("DefaultProperty", "itemDetails")

public:
    explicit QDeclarativeOrganizerItem(QObject *parent = nullptr);
    ~QDeclarativeOrganizerItem();

    // basic information
    bool modified() const;

    QDeclarativeOrganizerItemType::ItemType itemType() const;
    QQmlListProperty<QDeclarativeOrganizerItemDetail> itemDetails();
    QString itemId() const;
    QString manager() const;

    QString collectionId() const;
    void setCollectionId(const QString& collectionId);

    // convenient access to most frequently used details
    QString displayLabel() const;
    void setDisplayLabel(const QString &label);

    QString description() const;
    void setDescription(const QString &description);

    QString guid() const;
    void setGuid(const QString& guid);

    // functions
    // use int instead of QDeclarativeOrganizerItemDetail::ItemDetailType as a work-around for QTBUG-20639
    Q_INVOKABLE QDeclarativeOrganizerItemDetail *detail(int type);
    Q_INVOKABLE QVariantList details(int type);

    Q_INVOKABLE virtual void setDetail(QDeclarativeOrganizerItemDetail *detail);
    Q_INVOKABLE virtual void removeDetail(QDeclarativeOrganizerItemDetail *detail);
    Q_INVOKABLE virtual void clearDetails();

    // non-QML APIs, used internal only
    bool _q_setDetail(QDeclarativeOrganizerItemDetail *detail);
    bool _q_removeDetail(QDeclarativeOrganizerItemDetail *detail);
    bool _q_clearDetails();

    Q_INVOKABLE void save();

    // non-QML APIs, used by model only
    void setItem(const QOrganizerItem &item);
    QOrganizerItem item() const;

    bool generatedOccurrence() const;

    QDateTime itemStartTime() const;
    QDateTime itemEndTime() const;

Q_SIGNALS:
    void itemChanged();

protected:
    bool m_modified;

    QOrganizerItemId m_id;
    QOrganizerCollectionId m_collectionId;

    // always create a copy of the detail for QML
    // however, seems the garbage collection can't delete all of them (QTBUG-20377)
    QList<QDeclarativeOrganizerItemDetail *> m_details;

private:
     Q_DISABLE_COPY(QDeclarativeOrganizerItem)

    // call-back functions for list property
    static void _q_detail_append(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, QDeclarativeOrganizerItemDetail *value);
    static QDeclarativeOrganizerItemDetail *_q_detail_at(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, qsizetype index);
    static void _q_detail_clear(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property);
    static qsizetype _q_detail_count(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property);
};


class QDeclarativeOrganizerEvent : public QDeclarativeOrganizerItem
{
    Q_OBJECT

    Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged)
    Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime endDateTime READ endDateTime WRITE setEndDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemRecurrence *recurrence READ recurrence NOTIFY valueChanged)
    Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY valueChanged)
    Q_PROPERTY(QQmlListProperty<QDeclarativeOrganizerEventAttendee> attendees READ attendees NOTIFY valueChanged)

public:
    explicit QDeclarativeOrganizerEvent(QObject *parent = nullptr);

    QQmlListProperty<QDeclarativeOrganizerEventAttendee> attendees();

    Q_INVOKABLE virtual void setDetail(QDeclarativeOrganizerItemDetail *detail);
    Q_INVOKABLE virtual void removeDetail(QDeclarativeOrganizerItemDetail *detail);
    Q_INVOKABLE virtual void clearDetails();

    void setAllDay(bool isAllDay);
    bool isAllDay() const;

    void setStartDateTime(const QDateTime &startDateTime);
    QDateTime startDateTime() const;

    void setEndDateTime(const QDateTime &endDateTime);
    QDateTime endDateTime() const;

    void setPriority(QDeclarativeOrganizerItemPriority::Priority priority);
    QDeclarativeOrganizerItemPriority::Priority priority() const;

    void setLocation(const QString &location);
    QString location() const;

    QDeclarativeOrganizerItemRecurrence *recurrence();

Q_SIGNALS:
    void valueChanged();

private:
    // call-back functions for attendees list property
    static void _q_attendee_append(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, QDeclarativeOrganizerEventAttendee *value);
    static QDeclarativeOrganizerEventAttendee *_q_attendee_at(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, qsizetype index);
    static void _q_attendee_clear(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property);
    static qsizetype _q_attendee_count(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property);
};


class QDeclarativeOrganizerEventOccurrence : public QDeclarativeOrganizerItem
{
    Q_OBJECT

    Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged)
    Q_PROPERTY(QDateTime originalDate READ originalDate WRITE setOriginalDate NOTIFY valueChanged)
    Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime endDateTime READ endDateTime WRITE setEndDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged)
    Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY valueChanged)
    Q_PROPERTY(QString parentId READ parentId WRITE setParentId NOTIFY valueChanged)

public:
    explicit QDeclarativeOrganizerEventOccurrence(QObject *parent = nullptr);

    void setAllDay(bool isAllDay);
    bool isAllDay() const;

    void setOriginalDate(const QDateTime &date);
    QDateTime originalDate() const;

    void setStartDateTime(const QDateTime &startDateTime);
    QDateTime startDateTime() const;

    void setEndDateTime(const QDateTime &endDateTime);
    QDateTime endDateTime() const;

    void setPriority(QDeclarativeOrganizerItemPriority::Priority priority);
    QDeclarativeOrganizerItemPriority::Priority priority() const;

    void setLocation(const QString &location);
    QString location() const;

    void setParentId(const QString &parentId);
    QString parentId() const;

Q_SIGNALS:
    void valueChanged();
};


class QDeclarativeOrganizerJournal : public QDeclarativeOrganizerItem
{
    Q_OBJECT

    Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY valueChanged)

public:
    explicit QDeclarativeOrganizerJournal(QObject *parent = nullptr);

    void setDateTime(const QDateTime &dateTime);
    QDateTime dateTime() const;

Q_SIGNALS:
    void valueChanged();
};


class QDeclarativeOrganizerNote : public QDeclarativeOrganizerItem
{
    Q_OBJECT

public:
    explicit QDeclarativeOrganizerNote(QObject *parent = nullptr);

Q_SIGNALS:
    void valueChanged();
};


class QDeclarativeOrganizerTodo : public QDeclarativeOrganizerItem
{
    Q_OBJECT

    Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged)
    Q_PROPERTY(int percentageComplete READ percentageComplete WRITE setPercentageComplete NOTIFY valueChanged)
    Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime dueDateTime READ dueDateTime WRITE setDueDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime finishedDateTime READ finishedDateTime WRITE setFinishedDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerTodoProgress::StatusType status READ status WRITE setStatus NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemRecurrence* recurrence READ recurrence NOTIFY valueChanged)

public:
    explicit QDeclarativeOrganizerTodo(QObject *parent = nullptr);

    void setAllDay(bool isAllDay);
    bool isAllDay() const;

    void setPercentageComplete(int percentageComplete);
    int percentageComplete() const;

    void setStartDateTime(const QDateTime &startDateTime);
    QDateTime startDateTime() const;

    void setDueDateTime(const QDateTime &dueDateTime);
    QDateTime dueDateTime() const;

    void setFinishedDateTime(const QDateTime &finishedDateTime);
    QDateTime finishedDateTime() const;

    void setPriority(QDeclarativeOrganizerItemPriority::Priority priority);
    QDeclarativeOrganizerItemPriority::Priority priority() const;

    void setStatus(QDeclarativeOrganizerTodoProgress::StatusType status);
    QDeclarativeOrganizerTodoProgress::StatusType status() const;

    QDeclarativeOrganizerItemRecurrence *recurrence();

Q_SIGNALS:
    void valueChanged();
};


class QDeclarativeOrganizerTodoOccurrence : public QDeclarativeOrganizerItem
{
    Q_OBJECT

    Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged)
    Q_PROPERTY(int percentageComplete READ percentageComplete WRITE setPercentageComplete NOTIFY valueChanged)
    Q_PROPERTY(QDateTime originalDate READ originalDate WRITE setOriginalDate NOTIFY valueChanged)
    Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime dueDateTime READ dueDateTime WRITE setDueDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDateTime finishedDateTime READ finishedDateTime WRITE setFinishedDateTime NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged)
    Q_PROPERTY(QDeclarativeOrganizerTodoProgress::StatusType status READ status WRITE setStatus NOTIFY valueChanged)
    Q_PROPERTY(QString parentId READ parentId WRITE setParentId NOTIFY valueChanged)

public:
    explicit QDeclarativeOrganizerTodoOccurrence(QObject *parent = nullptr);

    void setAllDay(bool isAllDay);
    bool isAllDay() const;

    void setPercentageComplete(int percentageComplete);
    int percentageComplete() const;

    void setOriginalDate(const QDateTime &date);
    QDateTime originalDate() const;

    void setStartDateTime(const QDateTime &startDateTime);
    QDateTime startDateTime() const;

    void setDueDateTime(const QDateTime &dueDateTime);
    QDateTime dueDateTime() const;

    void setFinishedDateTime(const QDateTime &finishedDateTime);
    QDateTime finishedDateTime() const;

    void setPriority(QDeclarativeOrganizerItemPriority::Priority priority);
    QDeclarativeOrganizerItemPriority::Priority priority() const;

    void setStatus(QDeclarativeOrganizerTodoProgress::StatusType status);
    QDeclarativeOrganizerTodoProgress::StatusType status() const;

    QString parentId() const;
    void setParentId(const QString &parentId);

Q_SIGNALS:
    void valueChanged();
};

QT_END_NAMESPACE

QML_DECLARE_TYPE(QDeclarativeOrganizerItem)
QML_DECLARE_TYPE(QDeclarativeOrganizerEvent)
QML_DECLARE_TYPE(QDeclarativeOrganizerEventOccurrence)
QML_DECLARE_TYPE(QDeclarativeOrganizerJournal)
QML_DECLARE_TYPE(QDeclarativeOrganizerNote)
QML_DECLARE_TYPE(QDeclarativeOrganizerTodo)
QML_DECLARE_TYPE(QDeclarativeOrganizerTodoOccurrence)

#endif // QDECLARATIVEORGANIZERITEM_H