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 QDECLARATIVECONTACTGLOBALPRESENCE_H |
35 | #define QDECLARATIVECONTACTGLOBALPRESENCE_H |
36 | |
37 | #include <QtContacts/qcontactglobalpresence.h> |
38 | |
39 | #include "qdeclarativecontactdetail_p.h" |
40 | #include "qdeclarativecontactpresence_p.h" |
41 | |
42 | QTCONTACTS_USE_NAMESPACE |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | class QDeclarativeContactGlobalPresence : public QDeclarativeContactDetail |
47 | { |
48 | Q_OBJECT |
49 | Q_PROPERTY(QDateTime timestamp READ timestamp WRITE setTimestamp NOTIFY valueChanged) |
50 | Q_PROPERTY(QString nickname READ nickname WRITE setNickname NOTIFY valueChanged) |
51 | Q_PROPERTY(QDeclarativeContactPresence::PresenceStateType state READ presenceState WRITE setPresenceState NOTIFY valueChanged) |
52 | Q_PROPERTY(QString stateText READ presenceStateText WRITE setPresenceStateText NOTIFY valueChanged) |
53 | Q_PROPERTY(QUrl imageUrl READ presenceStateImageUrl WRITE setPresenceStateImageUrl NOTIFY valueChanged) |
54 | Q_PROPERTY(QString customMessage READ customMessage WRITE setCustomMessage NOTIFY valueChanged) |
55 | Q_CLASSINFO("DefaultProperty" , "state" ) |
56 | Q_ENUMS(FieldType) |
57 | public: |
58 | enum FieldType { |
59 | Timestamp = QContactGlobalPresence::FieldTimestamp, |
60 | Nickname = QContactGlobalPresence::FieldNickname, |
61 | State = QContactGlobalPresence::FieldPresenceState, |
62 | StateText = QContactGlobalPresence::FieldPresenceStateText, |
63 | ImageUrl = QContactGlobalPresence::FieldPresenceStateImageUrl, |
64 | CustomMessage = QContactGlobalPresence::FieldCustomMessage |
65 | }; |
66 | |
67 | QDeclarativeContactGlobalPresence(QObject* parent = Q_NULLPTR) |
68 | :QDeclarativeContactDetail(parent) |
69 | { |
70 | setDetail(QContactGlobalPresence()); |
71 | connect(asender: this, SIGNAL(valueChanged()), SIGNAL(detailChanged())); |
72 | } |
73 | DetailType detailType() const |
74 | { |
75 | return QDeclarativeContactDetail::GlobalPresence; |
76 | } |
77 | |
78 | void setTimestamp(const QDateTime& v) |
79 | { |
80 | if (!readOnly() && v != timestamp()) { |
81 | detail().setValue(field: QContactGlobalPresence::FieldTimestamp, value: v); |
82 | emit valueChanged(); |
83 | } |
84 | } |
85 | QDateTime timestamp() const {return detail().value<QDateTime>(field: QContactGlobalPresence::FieldTimestamp);} |
86 | void setNickname(const QString& v) |
87 | { |
88 | if (!readOnly() && v != nickname()) { |
89 | detail().setValue(field: QContactGlobalPresence::FieldNickname, value: v); |
90 | emit valueChanged(); |
91 | } |
92 | } |
93 | QString nickname() const {return detail().value(field: QContactGlobalPresence::FieldNickname).toString();} |
94 | void setPresenceState(QDeclarativeContactPresence::PresenceStateType v) |
95 | { |
96 | if (!readOnly() && v != presenceState()) { |
97 | detail().setValue(field: QContactGlobalPresence::FieldPresenceState, value: static_cast<int>(v)); |
98 | emit valueChanged(); |
99 | } |
100 | } |
101 | |
102 | QDeclarativeContactPresence::PresenceStateType presenceState() const |
103 | { |
104 | return static_cast<QDeclarativeContactPresence::PresenceStateType>(detail().value<int>(field: QContactGlobalPresence::FieldPresenceState)); |
105 | |
106 | } |
107 | void setPresenceStateText(const QString& v) |
108 | { |
109 | if (!readOnly() && v != presenceStateText()) { |
110 | detail().setValue(field: QContactGlobalPresence::FieldPresenceStateText, value: v); |
111 | emit valueChanged(); |
112 | } |
113 | } |
114 | QString presenceStateText() const {return detail().value(field: QContactGlobalPresence::FieldPresenceStateText).toString();} |
115 | void setPresenceStateImageUrl(const QUrl& v) |
116 | { |
117 | if (!readOnly() && v != presenceStateImageUrl()) { |
118 | detail().setValue(field: QContactGlobalPresence::FieldPresenceStateImageUrl, value: v); |
119 | emit valueChanged(); |
120 | } |
121 | } |
122 | QUrl presenceStateImageUrl() const {return detail().value<QUrl>(field: QContactGlobalPresence::FieldPresenceStateImageUrl);} |
123 | void setCustomMessage(const QString& v) |
124 | { |
125 | if (!readOnly() && v != customMessage()) { |
126 | detail().setValue(field: QContactGlobalPresence::FieldCustomMessage, value: v); |
127 | emit valueChanged(); |
128 | } |
129 | } |
130 | QString customMessage() const {return detail().value(field: QContactGlobalPresence::FieldCustomMessage).toString();} |
131 | signals: |
132 | void valueChanged(); |
133 | }; |
134 | |
135 | QT_END_NAMESPACE |
136 | |
137 | QML_DECLARE_TYPE(QDeclarativeContactGlobalPresence) |
138 | |
139 | #endif // QDECLARATIVECONTACTGLOBALPRESENCE_H |
140 | |