| 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 QtContacts 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 QDECLARATIVECONTACTANNIVERSARY_H | 
| 35 | #define QDECLARATIVECONTACTANNIVERSARY_H | 
| 36 |  | 
| 37 | #include <QtContacts/qcontactanniversary.h> | 
| 38 |  | 
| 39 | #include "qdeclarativecontactdetail_p.h" | 
| 40 |  | 
| 41 | QTCONTACTS_USE_NAMESPACE | 
| 42 |  | 
| 43 | QT_BEGIN_NAMESPACE | 
| 44 |  | 
| 45 | class QDeclarativeContactAnniversary : public QDeclarativeContactDetail | 
| 46 | { | 
| 47 |     Q_OBJECT | 
| 48 |  | 
| 49 |     Q_PROPERTY(QString calendarId READ calendarId WRITE setCalendarId NOTIFY valueChanged) | 
| 50 |     Q_PROPERTY(QDate originalDate READ originalDate WRITE setOriginalDate NOTIFY valueChanged) | 
| 51 |     Q_PROPERTY(QDateTime originalDateTime READ originalDateTime WRITE setOriginalDateTime NOTIFY valueChanged) | 
| 52 |     Q_PROPERTY(QString event READ event WRITE setEvent NOTIFY valueChanged) | 
| 53 |     Q_PROPERTY(AnniversarySubType subType READ subType WRITE setSubType NOTIFY valueChanged) | 
| 54 |     Q_ENUMS(FieldType) | 
| 55 |     Q_ENUMS(AnniversarySubType) | 
| 56 | public: | 
| 57 |     enum FieldType { | 
| 58 |         CalendarId = QContactAnniversary::FieldCalendarId, | 
| 59 |         OriginalDate = QContactAnniversary::FieldOriginalDate, | 
| 60 |         Event = QContactAnniversary::FieldEvent, | 
| 61 |         SubType = QContactAnniversary::FieldSubType | 
| 62 |     }; | 
| 63 |  | 
| 64 |     enum AnniversarySubType { | 
| 65 |         Wedding = QContactAnniversary::SubTypeWedding, | 
| 66 |         Engagement = QContactAnniversary::SubTypeEngagement, | 
| 67 |         House = QContactAnniversary::SubTypeHouse, | 
| 68 |         Employment = QContactAnniversary::SubTypeEmployment, | 
| 69 |         Memorial = QContactAnniversary::SubTypeMemorial | 
| 70 |     }; | 
| 71 |  | 
| 72 |     QDeclarativeContactAnniversary(QObject* parent = Q_NULLPTR) | 
| 73 |         :QDeclarativeContactDetail(parent) | 
| 74 |     { | 
| 75 |         setDetail(QContactAnniversary()); | 
| 76 |         connect(asender: this, SIGNAL(valueChanged()), SIGNAL(detailChanged())); | 
| 77 |     } | 
| 78 |  | 
| 79 |     DetailType detailType() const | 
| 80 |     { | 
| 81 |         return QDeclarativeContactDetail::Anniversary; | 
| 82 |     } | 
| 83 |  | 
| 84 |     void setOriginalDate(const QDate& v) | 
| 85 |     { | 
| 86 |         if (!readOnly() && v != originalDate()) { | 
| 87 |             detail().setValue(field: QContactAnniversary::FieldOriginalDate, value: v); | 
| 88 |             emit valueChanged(); | 
| 89 |         } | 
| 90 |     } | 
| 91 |     QDate originalDate() const {return detail().value<QDate>(field: QContactAnniversary::FieldOriginalDate);} | 
| 92 |     void setOriginalDateTime(const QDateTime& v) | 
| 93 |     { | 
| 94 |         if (!readOnly() && v != originalDateTime()) { | 
| 95 |             detail().setValue(field: QContactAnniversary::FieldOriginalDate, value: v); | 
| 96 |             emit valueChanged(); | 
| 97 |         } | 
| 98 |     } | 
| 99 |     QDateTime originalDateTime() const {return detail().value<QDateTime>(field: QContactAnniversary::FieldOriginalDate);} | 
| 100 |  | 
| 101 |     void setCalendarId(const QString& v) | 
| 102 |     { | 
| 103 |         if (!readOnly() && v != calendarId()) { | 
| 104 |             detail().setValue(field: QContactAnniversary::FieldCalendarId, value: v); | 
| 105 |             emit valueChanged(); | 
| 106 |         } | 
| 107 |     } | 
| 108 |     QString calendarId() const {return detail().value(field: QContactAnniversary::FieldCalendarId).toString();} | 
| 109 |     void setEvent(const QString& v) | 
| 110 |     { | 
| 111 |         if (!readOnly() && v != event()) { | 
| 112 |             detail().setValue(field: QContactAnniversary::FieldEvent, value: v); | 
| 113 |             emit valueChanged(); | 
| 114 |         } | 
| 115 |     } | 
| 116 |     QString event() const {return detail().value(field: QContactAnniversary::FieldEvent).toString();} | 
| 117 |  | 
| 118 |     void setSubType(AnniversarySubType v) | 
| 119 |     { | 
| 120 |         if (!readOnly() && v != subType()) { | 
| 121 |             detail().setValue(field: QContactAnniversary::FieldSubType, value: v); | 
| 122 |         } | 
| 123 |     } | 
| 124 |  | 
| 125 |     AnniversarySubType subType() const | 
| 126 |     { | 
| 127 |         return static_cast<AnniversarySubType>(detail().value<int>(field: QContactAnniversary::FieldSubType)); | 
| 128 |     } | 
| 129 | signals: | 
| 130 |     void valueChanged(); | 
| 131 | }; | 
| 132 |  | 
| 133 | QT_END_NAMESPACE | 
| 134 |  | 
| 135 | QML_DECLARE_TYPE(QDeclarativeContactAnniversary) | 
| 136 |  | 
| 137 | #endif // QDECLARATIVECONTACTANNIVERSARY_H | 
| 138 |  |