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 QtQml 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 QDECLARATIVECONTACTDETAIL_P_H
35#define QDECLARATIVECONTACTDETAIL_P_H
36
37#include <QtCore/qset.h>
38#include <QtCore/qstringlist.h>
39
40#include <QtQml/qqml.h>
41
42#include <QtContacts/qcontactdetail.h>
43
44QTCONTACTS_USE_NAMESPACE
45
46QT_BEGIN_NAMESPACE
47
48class QDeclarativeContactDetail : public QObject
49{
50 Q_OBJECT
51 Q_PROPERTY(DetailType type READ detailType NOTIFY detailChanged)
52 Q_PROPERTY(QList<int> contexts READ contexts WRITE setContexts NOTIFY detailChanged)
53 Q_PROPERTY(QString detailUri READ detailUri WRITE setDetailUri NOTIFY detailChanged)
54 Q_PROPERTY(QStringList linkedDetailUris READ linkedDetailUris WRITE setLinkedDetailUris NOTIFY detailChanged)
55 Q_PROPERTY(QList<int> fields READ fields NOTIFY detailChanged)
56 Q_PROPERTY(bool readOnly READ readOnly NOTIFY detailChanged)
57 Q_PROPERTY(bool removable READ removable NOTIFY detailChanged)
58
59 Q_ENUMS(DetailType)
60 Q_ENUMS(ContextField)
61public:
62 QDeclarativeContactDetail(QObject* parent = Q_NULLPTR);
63
64
65 enum DetailType {
66 Address = QContactDetail::TypeAddress,
67 Anniversary = QContactDetail::TypeAnniversary,
68 Avatar = QContactDetail::TypeAvatar,
69 Birthday = QContactDetail::TypeBirthday,
70 DisplayLabel = QContactDetail::TypeDisplayLabel,
71 Email = QContactDetail::TypeEmailAddress,
72 ExtendedDetail = QContactDetail::TypeExtendedDetail,
73 Family = QContactDetail::TypeFamily,
74 Favorite = QContactDetail::TypeFavorite,
75 Gender = QContactDetail::TypeGender,
76 Geolocation = QContactDetail::TypeGeoLocation,
77 GlobalPresence = QContactDetail::TypeGlobalPresence,
78 Guid = QContactDetail::TypeGuid,
79 Hobby = QContactDetail::TypeHobby,
80 Name = QContactDetail::TypeName,
81 NickName = QContactDetail::TypeNickname,
82 Note = QContactDetail::TypeNote,
83 OnlineAccount = QContactDetail::TypeOnlineAccount,
84 Organization = QContactDetail::TypeOrganization,
85 PhoneNumber = QContactDetail::TypePhoneNumber,
86 Presence = QContactDetail::TypePresence,
87 Ringtone = QContactDetail::TypeRingtone,
88 SyncTarget = QContactDetail::TypeSyncTarget,
89 Tag = QContactDetail::TypeTag,
90 Timestamp = QContactDetail::TypeTimestamp,
91 Type = QContactDetail::TypeType,
92 Url = QContactDetail::TypeUrl,
93 Version = QContactDetail::TypeVersion,
94 Unknown = QContactDetail::TypeUndefined
95 };
96
97 enum ContextField {
98 FieldContext = QContactDetail::FieldContext,
99 ContextHome = QContactDetail::ContextHome,
100 ContextWork = QContactDetail::ContextWork,
101 ContextOther = QContactDetail::ContextOther
102 };
103
104 ~QDeclarativeContactDetail();
105
106 // QML functions
107 Q_INVOKABLE QVariant value(int field) const;
108 Q_INVOKABLE bool setValue(int field, const QVariant& value);
109 Q_INVOKABLE bool removeValue(int field);
110
111 QContactDetail& detail();
112 const QContactDetail& detail() const;
113 void setDetail(const QContactDetail& detail);
114
115 bool readOnly() const;
116 bool removable() const;
117
118 QList<int> contexts() const;
119 void setContexts(const QList<int>& context);
120
121 QString detailUri() const;
122 void setDetailUri(const QString& detailUri);
123
124 QStringList linkedDetailUris() const;
125 void setLinkedDetailUris(const QStringList& linkedDetailUris);
126 virtual DetailType detailType() const;
127
128 QList<int> fields() const;
129Q_SIGNALS:
130 void detailChanged();
131
132protected:
133 QContactDetail m_detail;
134};
135
136class QDeclarativeContactDetailFactory
137{
138public:
139 static QDeclarativeContactDetail *createContactDetail(const QDeclarativeContactDetail::DetailType type);
140};
141
142QT_END_NAMESPACE
143
144QML_DECLARE_TYPE(QDeclarativeContactDetail)
145
146#endif // QDECLARATIVECONTACTDETAIL_P_H
147

source code of qtpim/src/imports/contacts/qdeclarativecontactdetail_p.h