| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtOrganizer module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 2.1 or version 3 as published by the Free |
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| 22 | ** following information to ensure the GNU Lesser General Public License |
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 25 | ** |
| 26 | ** As a special exception, The Qt Company gives you certain additional |
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception |
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 29 | ** |
| 30 | ** $QT_END_LICENSE$ |
| 31 | ** |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | #ifndef QDECLARATIVEORGANIZERITEM_H |
| 35 | #define QDECLARATIVEORGANIZERITEM_H |
| 36 | |
| 37 | #include <QtQml/qqml.h> |
| 38 | |
| 39 | #include <QtOrganizer/qorganizeritems.h> |
| 40 | |
| 41 | #include "qdeclarativeorganizeritemdetail_p.h" |
| 42 | |
| 43 | QTORGANIZER_USE_NAMESPACE |
| 44 | |
| 45 | QT_BEGIN_NAMESPACE |
| 46 | |
| 47 | class QDeclarativeOrganizerItem : public QObject |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | |
| 51 | // basic information |
| 52 | Q_PROPERTY(bool modified READ modified NOTIFY itemChanged) |
| 53 | |
| 54 | Q_PROPERTY(QDeclarativeOrganizerItemType::ItemType itemType READ itemType NOTIFY itemChanged) |
| 55 | Q_PROPERTY(QQmlListProperty<QDeclarativeOrganizerItemDetail> itemDetails READ itemDetails NOTIFY itemChanged) |
| 56 | Q_PROPERTY(QString itemId READ itemId NOTIFY itemChanged) |
| 57 | Q_PROPERTY(QString manager READ manager NOTIFY itemChanged) |
| 58 | Q_PROPERTY(QString collectionId READ collectionId WRITE setCollectionId NOTIFY itemChanged) |
| 59 | |
| 60 | // convenient access to most frequently used details |
| 61 | Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY itemChanged) |
| 62 | Q_PROPERTY(QString displayLabel READ displayLabel WRITE setDisplayLabel NOTIFY itemChanged) |
| 63 | Q_PROPERTY(QString guid READ guid WRITE setGuid NOTIFY itemChanged) |
| 64 | Q_CLASSINFO("DefaultProperty" , "itemDetails" ) |
| 65 | |
| 66 | public: |
| 67 | explicit QDeclarativeOrganizerItem(QObject *parent = Q_NULLPTR); |
| 68 | ~QDeclarativeOrganizerItem(); |
| 69 | |
| 70 | // basic information |
| 71 | bool modified() const; |
| 72 | |
| 73 | QDeclarativeOrganizerItemType::ItemType itemType() const; |
| 74 | QQmlListProperty<QDeclarativeOrganizerItemDetail> itemDetails(); |
| 75 | QString itemId() const; |
| 76 | QString manager() const; |
| 77 | |
| 78 | QString collectionId() const; |
| 79 | void setCollectionId(const QString& collectionId); |
| 80 | |
| 81 | // convenient access to most frequently used details |
| 82 | QString displayLabel() const; |
| 83 | void setDisplayLabel(const QString &label); |
| 84 | |
| 85 | QString description() const; |
| 86 | void setDescription(const QString &description); |
| 87 | |
| 88 | QString guid() const; |
| 89 | void setGuid(const QString& guid); |
| 90 | |
| 91 | // functions |
| 92 | // use int instead of QDeclarativeOrganizerItemDetail::ItemDetailType as a work-around for QTBUG-20639 |
| 93 | Q_INVOKABLE QDeclarativeOrganizerItemDetail *detail(int type); |
| 94 | Q_INVOKABLE QVariantList details(int type); |
| 95 | |
| 96 | Q_INVOKABLE virtual void setDetail(QDeclarativeOrganizerItemDetail *detail); |
| 97 | Q_INVOKABLE virtual void removeDetail(QDeclarativeOrganizerItemDetail *detail); |
| 98 | Q_INVOKABLE virtual void clearDetails(); |
| 99 | |
| 100 | // non-QML APIs, used internal only |
| 101 | bool _q_setDetail(QDeclarativeOrganizerItemDetail *detail); |
| 102 | bool _q_removeDetail(QDeclarativeOrganizerItemDetail *detail); |
| 103 | bool _q_clearDetails(); |
| 104 | |
| 105 | Q_INVOKABLE void save(); |
| 106 | |
| 107 | // non-QML APIs, used by model only |
| 108 | void setItem(const QOrganizerItem &item); |
| 109 | QOrganizerItem item() const; |
| 110 | |
| 111 | bool generatedOccurrence() const; |
| 112 | |
| 113 | QDateTime itemStartTime() const; |
| 114 | QDateTime itemEndTime() const; |
| 115 | |
| 116 | Q_SIGNALS: |
| 117 | void itemChanged(); |
| 118 | |
| 119 | protected: |
| 120 | bool m_modified; |
| 121 | |
| 122 | QOrganizerItemId m_id; |
| 123 | QOrganizerCollectionId m_collectionId; |
| 124 | |
| 125 | // always create a copy of the detail for QML |
| 126 | // however, seems the garbage collection can't delete all of them (QTBUG-20377) |
| 127 | QList<QDeclarativeOrganizerItemDetail *> m_details; |
| 128 | |
| 129 | private: |
| 130 | Q_DISABLE_COPY(QDeclarativeOrganizerItem) |
| 131 | |
| 132 | // call-back functions for list property |
| 133 | static void _q_detail_append(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, QDeclarativeOrganizerItemDetail *value); |
| 134 | static QDeclarativeOrganizerItemDetail *_q_detail_at(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property, int index); |
| 135 | static void _q_detail_clear(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property); |
| 136 | static int _q_detail_count(QQmlListProperty<QDeclarativeOrganizerItemDetail> *property); |
| 137 | }; |
| 138 | |
| 139 | |
| 140 | class QDeclarativeOrganizerEvent : public QDeclarativeOrganizerItem |
| 141 | { |
| 142 | Q_OBJECT |
| 143 | |
| 144 | Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged) |
| 145 | Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged) |
| 146 | Q_PROPERTY(QDateTime endDateTime READ endDateTime WRITE setEndDateTime NOTIFY valueChanged) |
| 147 | Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged) |
| 148 | Q_PROPERTY(QDeclarativeOrganizerItemRecurrence *recurrence READ recurrence NOTIFY valueChanged) |
| 149 | Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY valueChanged) |
| 150 | Q_PROPERTY(QQmlListProperty<QDeclarativeOrganizerEventAttendee> attendees READ attendees NOTIFY valueChanged) |
| 151 | |
| 152 | public: |
| 153 | explicit QDeclarativeOrganizerEvent(QObject *parent = Q_NULLPTR); |
| 154 | |
| 155 | QQmlListProperty<QDeclarativeOrganizerEventAttendee> attendees(); |
| 156 | |
| 157 | Q_INVOKABLE virtual void setDetail(QDeclarativeOrganizerItemDetail *detail); |
| 158 | Q_INVOKABLE virtual void removeDetail(QDeclarativeOrganizerItemDetail *detail); |
| 159 | Q_INVOKABLE virtual void clearDetails(); |
| 160 | |
| 161 | void setAllDay(bool isAllDay); |
| 162 | bool isAllDay() const; |
| 163 | |
| 164 | void setStartDateTime(const QDateTime &startDateTime); |
| 165 | QDateTime startDateTime() const; |
| 166 | |
| 167 | void setEndDateTime(const QDateTime &endDateTime); |
| 168 | QDateTime endDateTime() const; |
| 169 | |
| 170 | void setPriority(QDeclarativeOrganizerItemPriority::Priority priority); |
| 171 | QDeclarativeOrganizerItemPriority::Priority priority() const; |
| 172 | |
| 173 | void setLocation(const QString &location); |
| 174 | QString location() const; |
| 175 | |
| 176 | QDeclarativeOrganizerItemRecurrence *recurrence(); |
| 177 | |
| 178 | Q_SIGNALS: |
| 179 | void valueChanged(); |
| 180 | |
| 181 | private: |
| 182 | // call-back functions for attendees list property |
| 183 | static void _q_attendee_append(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, QDeclarativeOrganizerEventAttendee *value); |
| 184 | static QDeclarativeOrganizerEventAttendee *_q_attendee_at(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property, int index); |
| 185 | static void _q_attendee_clear(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property); |
| 186 | static int _q_attendee_count(QQmlListProperty<QDeclarativeOrganizerEventAttendee> *property); |
| 187 | }; |
| 188 | |
| 189 | |
| 190 | class QDeclarativeOrganizerEventOccurrence : public QDeclarativeOrganizerItem |
| 191 | { |
| 192 | Q_OBJECT |
| 193 | |
| 194 | Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged) |
| 195 | Q_PROPERTY(QDateTime originalDate READ originalDate WRITE setOriginalDate NOTIFY valueChanged) |
| 196 | Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged) |
| 197 | Q_PROPERTY(QDateTime endDateTime READ endDateTime WRITE setEndDateTime NOTIFY valueChanged) |
| 198 | Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged) |
| 199 | Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY valueChanged) |
| 200 | Q_PROPERTY(QString parentId READ parentId WRITE setParentId NOTIFY valueChanged) |
| 201 | |
| 202 | public: |
| 203 | explicit QDeclarativeOrganizerEventOccurrence(QObject *parent = Q_NULLPTR); |
| 204 | |
| 205 | void setAllDay(bool isAllDay); |
| 206 | bool isAllDay() const; |
| 207 | |
| 208 | void setOriginalDate(const QDateTime &date); |
| 209 | QDateTime originalDate() const; |
| 210 | |
| 211 | void setStartDateTime(const QDateTime &startDateTime); |
| 212 | QDateTime startDateTime() const; |
| 213 | |
| 214 | void setEndDateTime(const QDateTime &endDateTime); |
| 215 | QDateTime endDateTime() const; |
| 216 | |
| 217 | void setPriority(QDeclarativeOrganizerItemPriority::Priority priority); |
| 218 | QDeclarativeOrganizerItemPriority::Priority priority() const; |
| 219 | |
| 220 | void setLocation(const QString &location); |
| 221 | QString location() const; |
| 222 | |
| 223 | void setParentId(const QString &parentId); |
| 224 | QString parentId() const; |
| 225 | |
| 226 | Q_SIGNALS: |
| 227 | void valueChanged(); |
| 228 | }; |
| 229 | |
| 230 | |
| 231 | class QDeclarativeOrganizerJournal : public QDeclarativeOrganizerItem |
| 232 | { |
| 233 | Q_OBJECT |
| 234 | |
| 235 | Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY valueChanged) |
| 236 | |
| 237 | public: |
| 238 | explicit QDeclarativeOrganizerJournal(QObject *parent = Q_NULLPTR); |
| 239 | |
| 240 | void setDateTime(const QDateTime &dateTime); |
| 241 | QDateTime dateTime() const; |
| 242 | |
| 243 | Q_SIGNALS: |
| 244 | void valueChanged(); |
| 245 | }; |
| 246 | |
| 247 | |
| 248 | class QDeclarativeOrganizerNote : public QDeclarativeOrganizerItem |
| 249 | { |
| 250 | Q_OBJECT |
| 251 | |
| 252 | public: |
| 253 | explicit QDeclarativeOrganizerNote(QObject *parent = Q_NULLPTR); |
| 254 | |
| 255 | Q_SIGNALS: |
| 256 | void valueChanged(); |
| 257 | }; |
| 258 | |
| 259 | |
| 260 | class QDeclarativeOrganizerTodo : public QDeclarativeOrganizerItem |
| 261 | { |
| 262 | Q_OBJECT |
| 263 | |
| 264 | Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged) |
| 265 | Q_PROPERTY(int percentageComplete READ percentageComplete WRITE setPercentageComplete NOTIFY valueChanged) |
| 266 | Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged) |
| 267 | Q_PROPERTY(QDateTime dueDateTime READ dueDateTime WRITE setDueDateTime NOTIFY valueChanged) |
| 268 | Q_PROPERTY(QDateTime finishedDateTime READ finishedDateTime WRITE setFinishedDateTime NOTIFY valueChanged) |
| 269 | Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged) |
| 270 | Q_PROPERTY(QDeclarativeOrganizerTodoProgress::StatusType status READ status WRITE setStatus NOTIFY valueChanged) |
| 271 | Q_PROPERTY(QDeclarativeOrganizerItemRecurrence* recurrence READ recurrence NOTIFY valueChanged) |
| 272 | |
| 273 | public: |
| 274 | explicit QDeclarativeOrganizerTodo(QObject *parent = Q_NULLPTR); |
| 275 | |
| 276 | void setAllDay(bool isAllDay); |
| 277 | bool isAllDay() const; |
| 278 | |
| 279 | void setPercentageComplete(int percentageComplete); |
| 280 | int percentageComplete() const; |
| 281 | |
| 282 | void setStartDateTime(const QDateTime &startDateTime); |
| 283 | QDateTime startDateTime() const; |
| 284 | |
| 285 | void setDueDateTime(const QDateTime &dueDateTime); |
| 286 | QDateTime dueDateTime() const; |
| 287 | |
| 288 | void setFinishedDateTime(const QDateTime &finishedDateTime); |
| 289 | QDateTime finishedDateTime() const; |
| 290 | |
| 291 | void setPriority(QDeclarativeOrganizerItemPriority::Priority priority); |
| 292 | QDeclarativeOrganizerItemPriority::Priority priority() const; |
| 293 | |
| 294 | void setStatus(QDeclarativeOrganizerTodoProgress::StatusType status); |
| 295 | QDeclarativeOrganizerTodoProgress::StatusType status() const; |
| 296 | |
| 297 | QDeclarativeOrganizerItemRecurrence *recurrence(); |
| 298 | |
| 299 | Q_SIGNALS: |
| 300 | void valueChanged(); |
| 301 | }; |
| 302 | |
| 303 | |
| 304 | class QDeclarativeOrganizerTodoOccurrence : public QDeclarativeOrganizerItem |
| 305 | { |
| 306 | Q_OBJECT |
| 307 | |
| 308 | Q_PROPERTY(bool allDay READ isAllDay WRITE setAllDay NOTIFY valueChanged) |
| 309 | Q_PROPERTY(int percentageComplete READ percentageComplete WRITE setPercentageComplete NOTIFY valueChanged) |
| 310 | Q_PROPERTY(QDateTime originalDate READ originalDate WRITE setOriginalDate NOTIFY valueChanged) |
| 311 | Q_PROPERTY(QDateTime startDateTime READ startDateTime WRITE setStartDateTime NOTIFY valueChanged) |
| 312 | Q_PROPERTY(QDateTime dueDateTime READ dueDateTime WRITE setDueDateTime NOTIFY valueChanged) |
| 313 | Q_PROPERTY(QDateTime finishedDateTime READ finishedDateTime WRITE setFinishedDateTime NOTIFY valueChanged) |
| 314 | Q_PROPERTY(QDeclarativeOrganizerItemPriority::Priority priority READ priority WRITE setPriority NOTIFY valueChanged) |
| 315 | Q_PROPERTY(QDeclarativeOrganizerTodoProgress::StatusType status READ status WRITE setStatus NOTIFY valueChanged) |
| 316 | Q_PROPERTY(QString parentId READ parentId WRITE setParentId NOTIFY valueChanged) |
| 317 | |
| 318 | public: |
| 319 | explicit QDeclarativeOrganizerTodoOccurrence(QObject *parent = Q_NULLPTR); |
| 320 | |
| 321 | void setAllDay(bool isAllDay); |
| 322 | bool isAllDay() const; |
| 323 | |
| 324 | void setPercentageComplete(int percentageComplete); |
| 325 | int percentageComplete() const; |
| 326 | |
| 327 | void setOriginalDate(const QDateTime &date); |
| 328 | QDateTime originalDate() const; |
| 329 | |
| 330 | void setStartDateTime(const QDateTime &startDateTime); |
| 331 | QDateTime startDateTime() const; |
| 332 | |
| 333 | void setDueDateTime(const QDateTime &dueDateTime); |
| 334 | QDateTime dueDateTime() const; |
| 335 | |
| 336 | void setFinishedDateTime(const QDateTime &finishedDateTime); |
| 337 | QDateTime finishedDateTime() const; |
| 338 | |
| 339 | void setPriority(QDeclarativeOrganizerItemPriority::Priority priority); |
| 340 | QDeclarativeOrganizerItemPriority::Priority priority() const; |
| 341 | |
| 342 | void setStatus(QDeclarativeOrganizerTodoProgress::StatusType status); |
| 343 | QDeclarativeOrganizerTodoProgress::StatusType status() const; |
| 344 | |
| 345 | QString parentId() const; |
| 346 | void setParentId(const QString &parentId); |
| 347 | |
| 348 | Q_SIGNALS: |
| 349 | void valueChanged(); |
| 350 | }; |
| 351 | |
| 352 | QT_END_NAMESPACE |
| 353 | |
| 354 | QML_DECLARE_TYPE(QDeclarativeOrganizerItem) |
| 355 | QML_DECLARE_TYPE(QDeclarativeOrganizerEvent) |
| 356 | QML_DECLARE_TYPE(QDeclarativeOrganizerEventOccurrence) |
| 357 | QML_DECLARE_TYPE(QDeclarativeOrganizerJournal) |
| 358 | QML_DECLARE_TYPE(QDeclarativeOrganizerNote) |
| 359 | QML_DECLARE_TYPE(QDeclarativeOrganizerTodo) |
| 360 | QML_DECLARE_TYPE(QDeclarativeOrganizerTodoOccurrence) |
| 361 | |
| 362 | #endif // QDECLARATIVEORGANIZERITEM_H |
| 363 | |