1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtQml module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
41
#ifndef QDECLARATIVECONTACT_P_H
42
#define QDECLARATIVECONTACT_P_H
45
#include <qcontactid.h>
46
#include "qdeclarativecontactdetails_p.h"
47
#include "qdeclarativecontacturl_p.h"
48
#include "qdeclarativecontacthobby_p.h"
49
#include "qdeclarativecontactdetail_p.h"
50
#include <QtQml/qqmllist.h>
52
QT_BEGIN_NAMESPACE_CONTACTS
54
class QDeclarativeContact : public QObject
59
Q_PROPERTY (bool modified READ modified)
61
Q_PROPERTY (QDeclarativeContactType::ContactType type READ type NOTIFY contactChanged)
62
Q_PROPERTY (QString contactId READ contactId NOTIFY contactIdChanged)
63
Q_PROPERTY (QString manager READ manager NOTIFY managerChanged)
64
Q_PROPERTY (QQmlListProperty<QDeclarativeContactDetail> contactDetails READ contactDetails NOTIFY contactChanged)
65
Q_PROPERTY (QDeclarativeContactAddress* address READ address NOTIFY contactChanged)
66
Q_PROPERTY (QQmlListProperty<QDeclarativeContactAddress> addresses READ addresses NOTIFY contactChanged)
67
Q_PROPERTY (QDeclarativeContactAnniversary* anniversary READ anniversary NOTIFY contactChanged)
68
Q_PROPERTY (QDeclarativeContactAvatar* avatar READ avatar NOTIFY contactChanged)
69
Q_PROPERTY (QDeclarativeContactBirthday* birthday READ birthday NOTIFY contactChanged)
70
Q_PROPERTY (QDeclarativeContactDisplayLabel* displayLabel READ displayLabel NOTIFY contactChanged)
71
Q_PROPERTY (QDeclarativeContactEmailAddress* email READ email NOTIFY contactChanged)
72
Q_PROPERTY (QQmlListProperty<QDeclarativeContactEmailAddress> emails READ emails NOTIFY contactChanged)
73
Q_PROPERTY (QDeclarativeContactExtendedDetail* extendedDetail READ extendedDetail NOTIFY contactChanged)
74
Q_PROPERTY (QQmlListProperty<QDeclarativeContactExtendedDetail> extendedDetails READ extendedDetails NOTIFY contactChanged)
75
Q_PROPERTY (QDeclarativeContactFamily* family READ family NOTIFY contactChanged)
76
Q_PROPERTY (QDeclarativeContactFavorite* favorite READ favorite NOTIFY contactChanged)
77
Q_PROPERTY (QDeclarativeContactGender* gender READ gender NOTIFY contactChanged)
78
Q_PROPERTY (QDeclarativeContactGeoLocation* geolocation READ geolocation NOTIFY contactChanged)
79
Q_PROPERTY (QDeclarativeContactGlobalPresence* globalPresence READ globalPresence NOTIFY contactChanged)
80
Q_PROPERTY (QDeclarativeContactGuid* guid READ guid NOTIFY contactChanged)
81
Q_PROPERTY (QDeclarativeContactHobby* hobby READ hobby NOTIFY contactChanged)
82
Q_PROPERTY (QDeclarativeContactName* name READ name NOTIFY contactChanged)
83
Q_PROPERTY (QDeclarativeContactNickname* nickname READ nickname NOTIFY contactChanged)
84
Q_PROPERTY (QDeclarativeContactNote* note READ note NOTIFY contactChanged)
85
Q_PROPERTY (QDeclarativeContactOnlineAccount* onlineAccount READ onlineAccount NOTIFY contactChanged)
86
Q_PROPERTY (QDeclarativeContactOrganization* organization READ organization NOTIFY contactChanged)
87
Q_PROPERTY (QQmlListProperty<QDeclarativeContactOrganization> organizations READ organizations NOTIFY contactChanged)
88
Q_PROPERTY (QDeclarativeContactPhoneNumber* phoneNumber READ phoneNumber NOTIFY contactChanged)
89
Q_PROPERTY (QQmlListProperty<QDeclarativeContactPhoneNumber> phoneNumbers READ phoneNumbers NOTIFY contactChanged)
90
Q_PROPERTY (QDeclarativeContactPresence* presence READ presence NOTIFY contactChanged)
91
Q_PROPERTY (QDeclarativeContactRingtone* ringtone READ ringtone NOTIFY contactChanged)
92
Q_PROPERTY (QDeclarativeContactSyncTarget* syncTarget READ syncTarget NOTIFY contactChanged)
93
Q_PROPERTY (QDeclarativeContactTag* tag READ tag NOTIFY contactChanged)
94
Q_PROPERTY (QDeclarativeContactTimestamp* timestamp READ timestamp NOTIFY contactChanged)
95
Q_PROPERTY (QDeclarativeContactUrl* url READ url NOTIFY contactChanged)
96
Q_PROPERTY (QQmlListProperty<QDeclarativeContactUrl> urls READ urls NOTIFY contactChanged)
97
Q_PROPERTY (QDeclarativeContactVersion* version READ version NOTIFY contactChanged)
98
Q_PROPERTY (QVariantMap preferredDetails READ preferredDetails NOTIFY contactChanged)
99
Q_CLASSINFO("DefaultProperty", "contactDetails")
103
explicit QDeclarativeContact(QObject *parent = 0);
104
~QDeclarativeContact();
106
void setContact(const QContact& c);
107
QContact contact() const;
108
bool modified() const;
110
QDeclarativeContactType::ContactType type() const;
112
QString contactId() const;
113
QString manager() const;
114
QQmlListProperty<QDeclarativeContactDetail> contactDetails();
116
// use int instead of QDeclarativeContactDetail::ContactType as a work-around for QTBUG-20639
117
Q_INVOKABLE QDeclarativeContactDetail* detail(int type);
118
Q_INVOKABLE QVariantList details(int type);
120
Q_INVOKABLE bool removeDetail(QDeclarativeContactDetail* detail);
121
Q_INVOKABLE bool addDetail(QDeclarativeContactDetail* detail);
123
Q_INVOKABLE bool setPreferredDetail(const QString& actionName, QDeclarativeContactDetail* detail);
124
Q_INVOKABLE bool isPreferredDetail(const QString& actionName, QDeclarativeContactDetail* detail) const;
125
Q_INVOKABLE QDeclarativeContactDetail* preferredDetail(const QString& actionName) const;
126
QVariantMap preferredDetails() const;
128
QDeclarativeContactAddress* address();
129
QQmlListProperty<QDeclarativeContactAddress> addresses();
130
QDeclarativeContactAnniversary* anniversary();
131
QDeclarativeContactAvatar* avatar();
132
QDeclarativeContactBirthday* birthday();
133
QDeclarativeContactDisplayLabel* displayLabel();
134
QDeclarativeContactEmailAddress* email();
135
QQmlListProperty<QDeclarativeContactEmailAddress> emails();
136
QDeclarativeContactExtendedDetail* extendedDetail();
137
QQmlListProperty<QDeclarativeContactExtendedDetail> extendedDetails();
138
QDeclarativeContactFamily* family();
139
QDeclarativeContactFavorite* favorite();
140
QDeclarativeContactGender* gender();
141
QDeclarativeContactGeoLocation* geolocation();
142
QDeclarativeContactGlobalPresence* globalPresence();
143
QDeclarativeContactGuid* guid();
144
QDeclarativeContactHobby* hobby();
145
QDeclarativeContactName* name();
146
QDeclarativeContactNickname* nickname();
147
QDeclarativeContactNote* note();
148
QDeclarativeContactOnlineAccount* onlineAccount();
149
QDeclarativeContactOrganization* organization();
150
QQmlListProperty<QDeclarativeContactOrganization> organizations();
151
QDeclarativeContactPhoneNumber* phoneNumber();
152
QQmlListProperty<QDeclarativeContactPhoneNumber> phoneNumbers();
153
QDeclarativeContactPresence* presence();
154
QDeclarativeContactRingtone* ringtone();
155
QDeclarativeContactSyncTarget* syncTarget();
156
QDeclarativeContactTag* tag();
157
QDeclarativeContactTimestamp* timestamp();
158
QDeclarativeContactUrl* url();
159
QQmlListProperty<QDeclarativeContactUrl> urls();
160
QDeclarativeContactVersion* version();
166
// always create a copy of the detail for QML
167
// however, seems the garbage collection can't delete all of them (QTBUG-20377)
168
QList<QDeclarativeContactDetail *> m_details;
169
QMap<QString, int> m_preferredDetails;
175
void contactIdChanged();
176
void managerChanged();
177
void contactChanged();
183
Q_DISABLE_COPY(QDeclarativeContact)
185
template<typename T> T* getDetail(const QDeclarativeContactDetail::DetailType &type)
187
foreach (QDeclarativeContactDetail *detail, m_details) {
188
if (type == detail->detailType())
190
T* tempDetail = static_cast<T *>(detail);
196
m_details.append(detail);
197
emit contactChanged();
203
void removePreferredDetail(QDeclarativeContactDetail *detail);
205
// call-back functions for list property
206
static void _q_detail_append(QQmlListProperty<QDeclarativeContactDetail> *property, QDeclarativeContactDetail *value);
207
static QDeclarativeContactDetail *_q_detail_at(QQmlListProperty<QDeclarativeContactDetail> *property, int index);
208
static void _q_detail_clear(QQmlListProperty<QDeclarativeContactDetail> *property);
209
static int _q_detail_count(QQmlListProperty<QDeclarativeContactDetail> *property);
212
QT_END_NAMESPACE_CONTACTS
214
QTCONTACTS_USE_NAMESPACE
216
QML_DECLARE_TYPE(QDeclarativeContact)
218
#endif // QDECLARATIVECONTACT_P_H