summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Adams <chris.adams@jollamobile.com>2015-11-02 21:08:16 +1000
committerChristopher Adams <chris.adams@jollamobile.com>2015-11-12 01:24:10 +0000
commit480303e8ee89fb1d39b4f00f77559f3021e2ccae (patch)
treed94f0f920082b434ac8c42d33ce1ae6f181ae4d4
parent6ff25f70afa5b4cdb84845b29c8b01371b7d3e19 (diff)
QtContacts: detail-leaf-class API improvements
This commit improves the API of various detail leaf classes by adding support for more commonly-required fields. It also fixes the QContactGender class so that the enum definitions are sensible and consistent with the rest of the API. Finally, it adds support for providing per-detail provenance information, to enable the Aggregate/Facet contact story. Change-Id: Idf465f99963d372ec4f0d439cf9f3be8a7823202 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
-rw-r--r--src/contacts/details/qcontactavatar.h6
-rw-r--r--src/contacts/details/qcontactdetails.cpp105
-rw-r--r--src/contacts/details/qcontactgender.h13
-rw-r--r--src/contacts/details/qcontactname.h5
-rw-r--r--src/contacts/details/qcontactphonenumber.h4
-rw-r--r--src/contacts/details/qcontacttimestamp.h5
-rw-r--r--src/contacts/qcontactdetail.cpp18
-rw-r--r--src/contacts/qcontactdetail.h6
-rw-r--r--src/contacts/qcontactdetail_p.h24
-rw-r--r--src/contacts/qcontactmanagerengine.cpp21
-rw-r--r--src/contacts/qcontactmanagerengine.h1
-rw-r--r--tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp7
-rw-r--r--tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp17
13 files changed, 214 insertions, 18 deletions
diff --git a/src/contacts/details/qcontactavatar.h b/src/contacts/details/qcontactavatar.h
index 583e3f5a0..88376f2ba 100644
--- a/src/contacts/details/qcontactavatar.h
+++ b/src/contacts/details/qcontactavatar.h
@@ -52,7 +52,8 @@ public:
enum AvatarField {
FieldImageUrl = 0,
- FieldVideoUrl
+ FieldVideoUrl,
+ FieldMetaData
};
void setImageUrl(const QUrl& _imageUrl);
@@ -60,6 +61,9 @@ public:
void setVideoUrl(const QUrl& _videoUrl);
QUrl videoUrl() const;
+
+ void setMetaData(const QString& _metaData);
+ QString metaData() const;
};
QT_END_NAMESPACE_CONTACTS
diff --git a/src/contacts/details/qcontactdetails.cpp b/src/contacts/details/qcontactdetails.cpp
index 17fd9206e..ae962a951 100644
--- a/src/contacts/details/qcontactdetails.cpp
+++ b/src/contacts/details/qcontactdetails.cpp
@@ -565,8 +565,9 @@ class QContactAvatarPrivate : public QContactDetailBuiltinPrivate<QContactAvatar
public:
QUrl m_imageUrl;
QUrl m_videoUrl;
+ QString m_metaData;
- enum { FieldCount = 2 };
+ enum { FieldCount = 3 };
QContactAvatarPrivate() : QContactDetailBuiltinPrivate<QContactAvatarPrivate>(QContactAvatar::Type) {}
};
@@ -575,6 +576,7 @@ template<>
const QContactDetailBuiltinPrivateBase::Member QContactDetailBuiltinPrivate<QContactAvatarPrivate>::s_members[] = {
{ QContactDetailBuiltinPrivateBase::Url, offsetof(QContactAvatarPrivate, m_imageUrl) },
{ QContactDetailBuiltinPrivateBase::Url, offsetof(QContactAvatarPrivate, m_videoUrl) },
+ { QContactDetailBuiltinPrivateBase::String, offsetof(QContactAvatarPrivate, m_metaData) },
};
/*!
@@ -629,6 +631,24 @@ void QContactAvatar::setVideoUrl(const QUrl& _value)
reinterpret_cast<QContactAvatarPrivate*>(d.data())->setMemberValue<QUrl>(QContactAvatar::FieldVideoUrl, _value);
}
+/*!
+ \fn QContactAvatar::metaData() const
+ Returns the meta data associated with the avatar url.
+ */
+QString QContactAvatar::metaData() const
+{
+ return reinterpret_cast<const QContactAvatarPrivate*>(d.constData())->memberValue<QString>(QContactAvatar::FieldMetaData);
+}
+
+/*!
+ \fn QContactAvatar::setMetaData(const QString& metaData)
+ Sets the meta data associated with the avatar url to \a metaData.
+ */
+void QContactAvatar::setMetaData(const QString& _value)
+{
+ reinterpret_cast<QContactAvatarPrivate*>(d.data())->setMemberValue<QString>(QContactAvatar::FieldMetaData, _value);
+}
+
/* ==================== QContactAddress ======================= */
@@ -992,9 +1012,10 @@ class QContactPhoneNumberPrivate : public QContactDetailBuiltinPrivate<QContactP
{
public:
QString m_number;
+ QString m_normalizedNumber;
QList<int> m_subTypes;
- enum { FieldCount = 2 };
+ enum { FieldCount = 3 };
QContactPhoneNumberPrivate() : QContactDetailBuiltinPrivate<QContactPhoneNumberPrivate>(QContactPhoneNumber::Type) {}
};
@@ -1002,6 +1023,7 @@ public:
template<>
const QContactDetailBuiltinPrivateBase::Member QContactDetailBuiltinPrivate<QContactPhoneNumberPrivate>::s_members[] = {
{ QContactDetailBuiltinPrivateBase::String, offsetof(QContactPhoneNumberPrivate, m_number) },
+ { QContactDetailBuiltinPrivateBase::String, offsetof(QContactPhoneNumberPrivate, m_normalizedNumber) },
{ QContactDetailBuiltinPrivateBase::IntList, offsetof(QContactPhoneNumberPrivate, m_subTypes) },
};
@@ -1061,6 +1083,25 @@ void QContactPhoneNumber::setNumber(const QString& _value)
}
/*!
+ \fn QContactPhoneNumber::normalizedNumber() const
+ Returns the normalized version of the phone number stored in this detail.
+ This value may be backend-generated, and may not be exportable.
+ */
+QString QContactPhoneNumber::normalizedNumber() const
+{
+ return reinterpret_cast<const QContactPhoneNumberPrivate*>(d.constData())->memberValue<QString>(QContactPhoneNumber::FieldNormalizedNumber);
+}
+
+/*!
+ \fn QContactPhoneNumber::setNormalizedNumber(const QString& normalizedNumber)
+ Sets the normalized version of the phone number stored in this detail to \a normalizedNumber.
+ */
+void QContactPhoneNumber::setNormalizedNumber(const QString& _value)
+{
+ reinterpret_cast<QContactPhoneNumberPrivate*>(d.data())->setMemberValue<QString>(QContactPhoneNumber::FieldNormalizedNumber, _value);
+}
+
+/*!
\fn QContactPhoneNumber::setSubTypes(const QList<int>& subTypes)
Sets the subtypes which this detail implements to be those contained in the list of given \a subTypes
*/
@@ -1272,9 +1313,15 @@ const QContactDetail::DetailType QContactGender::Type(QContactDetail::TypeGender
\enum QContactGender::GenderField
This enumeration defines the fields supported by QContactGender.
\value FieldGender The value stored in this field contains the gender.
+ \sa gender(), setGender()
+ */
+
+/*!
+ \enum QContactGender::GenderType
+ This enumeration defines built-in gender values
+ \value GenderUnspecified The value that identifies this contact as being of unspecified gender.
\value GenderMale The value that identifies this contact as being male.
\value GenderFemale The value that identifies this contact as being female.
- \value GenderUnspecified The value that identifies this contact as being of unspecified gender.
\sa gender(), setGender()
*/
@@ -1285,19 +1332,19 @@ const QContactDetail::DetailType QContactGender::Type(QContactDetail::TypeGender
possible values for the value stored are "Male", "Female" and
"Unspecified".
*/
-QContactGender::GenderField QContactGender::gender() const
+QContactGender::GenderType QContactGender::gender() const
{
- return static_cast<QContactGender::GenderField>(reinterpret_cast<const QContactGenderPrivate*>(d.constData())->memberValue<int>(QContactGender::FieldGender));
+ return static_cast<QContactGender::GenderType>(reinterpret_cast<const QContactGenderPrivate*>(d.constData())->memberValue<int>(QContactGender::FieldGender));
}
/*!
- \fn QContactGender::setGender(const GenderField gender)
+ \fn QContactGender::setGender(GenderType gender)
Sets the gender of the contact (as stored in this detail) to \a
gender, if \a gender is either GenderMale or GenderFemale, otherwise sets
it to GenderUnspecified.
*/
-void QContactGender::setGender(QContactGender::GenderField _value)
+void QContactGender::setGender(QContactGender::GenderType _value)
{
reinterpret_cast<QContactGenderPrivate*>(d.data())->setMemberValue<int>(QContactGender::FieldGender, static_cast<int>(_value));
}
@@ -1702,8 +1749,9 @@ public:
QString m_middleName;
QString m_lastName;
QString m_suffix;
+ QString m_customLabel;
- enum { FieldCount = 5 };
+ enum { FieldCount = 6 };
QContactNamePrivate() : QContactDetailBuiltinPrivate<QContactNamePrivate>(QContactName::Type) {}
};
@@ -1715,6 +1763,7 @@ const QContactDetailBuiltinPrivateBase::Member QContactDetailBuiltinPrivate<QCon
{ QContactDetailBuiltinPrivateBase::String, offsetof(QContactNamePrivate, m_middleName) },
{ QContactDetailBuiltinPrivateBase::String, offsetof(QContactNamePrivate, m_lastName) },
{ QContactDetailBuiltinPrivateBase::String, offsetof(QContactNamePrivate, m_suffix) },
+ { QContactDetailBuiltinPrivateBase::String, offsetof(QContactNamePrivate, m_customLabel) },
};
/*!
@@ -1832,6 +1881,24 @@ void QContactName::setSuffix(const QString& _value)
reinterpret_cast<QContactNamePrivate*>(d.data())->setMemberValue<QString>(QContactName::FieldSuffix, _value);
}
+/*!
+ \fn QContactName::customLabel() const
+ Returns the custom label data for the name stored in this detail.
+ */
+QString QContactName::customLabel() const
+{
+ return reinterpret_cast<const QContactNamePrivate*>(d.constData())->memberValue<QString>(QContactName::FieldCustomLabel);
+}
+
+/*!
+ \fn QContactName::setCustomLabel(const QString& customLabel)
+ Sets the custom label of the name stored in this detail to \a customLabel.
+ */
+void QContactName::setCustomLabel(const QString& _value)
+{
+ reinterpret_cast<QContactNamePrivate*>(d.data())->setMemberValue<QString>(QContactName::FieldCustomLabel, _value);
+}
+
/* ==================== QContactNickname ======================= */
/*!
@@ -2038,8 +2105,9 @@ class QContactTimestampPrivate : public QContactDetailBuiltinPrivate<QContactTim
public:
QDateTime m_modificationTimestamp;
QDateTime m_creationTimestamp;
+ QDateTime m_deletionTimestamp;
- enum { FieldCount = 2 };
+ enum { FieldCount = 3 };
QContactTimestampPrivate() : QContactDetailBuiltinPrivate<QContactTimestampPrivate>(QContactTimestamp::Type) {}
};
@@ -2048,6 +2116,7 @@ template<>
const QContactDetailBuiltinPrivateBase::Member QContactDetailBuiltinPrivate<QContactTimestampPrivate>::s_members[] = {
{ QContactDetailBuiltinPrivateBase::DateTime, offsetof(QContactTimestampPrivate, m_modificationTimestamp) },
{ QContactDetailBuiltinPrivateBase::DateTime, offsetof(QContactTimestampPrivate, m_creationTimestamp) },
+ { QContactDetailBuiltinPrivateBase::DateTime, offsetof(QContactTimestampPrivate, m_deletionTimestamp) },
};
/*!
@@ -2101,6 +2170,24 @@ QDateTime QContactTimestamp::lastModified() const
return reinterpret_cast<const QContactTimestampPrivate*>(d.constData())->memberValue<QDateTime>(QContactTimestamp::FieldModificationTimestamp);
}
+/*!
+ \fn QContactTimestamp::setDeleted(const QDateTime& dateTime)
+ Sets the deletion timestamp saved in this detail to \a dateTime.
+ */
+void QContactTimestamp::setDeleted(const QDateTime& _value)
+{
+ reinterpret_cast<QContactTimestampPrivate*>(d.data())->setMemberValue<QDateTime>(QContactTimestamp::FieldDeletionTimestamp, _value);
+}
+
+/*!
+ \fn QContactTimestamp::deleted() const
+ Returns the deletion timestamp saved in this detail.
+ */
+QDateTime QContactTimestamp::deleted() const
+{
+ return reinterpret_cast<const QContactTimestampPrivate*>(d.constData())->memberValue<QDateTime>(QContactTimestamp::FieldDeletionTimestamp);
+}
+
/* ==================== QContactType ======================= */
diff --git a/src/contacts/details/qcontactgender.h b/src/contacts/details/qcontactgender.h
index d1bf07813..5f7d32f28 100644
--- a/src/contacts/details/qcontactgender.h
+++ b/src/contacts/details/qcontactgender.h
@@ -49,14 +49,17 @@ public:
#endif
enum GenderField {
- FieldGender = 0,
+ FieldGender = 0
+ };
+
+ enum GenderType {
+ GenderUnspecified = 0,
GenderMale,
- GenderFemale,
- GenderUnspecified
+ GenderFemale
};
- void setGender(const GenderField _gender);
- GenderField gender() const;
+ void setGender(GenderType _gender);
+ GenderType gender() const;
};
QT_END_NAMESPACE_CONTACTS
diff --git a/src/contacts/details/qcontactname.h b/src/contacts/details/qcontactname.h
index 0aa3cf288..efad0ad79 100644
--- a/src/contacts/details/qcontactname.h
+++ b/src/contacts/details/qcontactname.h
@@ -55,7 +55,8 @@ public:
FieldFirstName,
FieldMiddleName,
FieldLastName,
- FieldSuffix
+ FieldSuffix,
+ FieldCustomLabel
};
QString prefix() const;
@@ -63,12 +64,14 @@ public:
QString middleName() const;
QString lastName() const;
QString suffix() const;
+ QString customLabel() const;
void setPrefix(const QString& _prefix);
void setFirstName(const QString& _firstName);
void setMiddleName(const QString& _middleName);
void setLastName(const QString& _lastName);
void setSuffix(const QString& _suffix);
+ void setCustomLabel(const QString& _customLabel);
// Convenience filter
static QContactFilter match(const QString& name);
diff --git a/src/contacts/details/qcontactphonenumber.h b/src/contacts/details/qcontactphonenumber.h
index 728bb1844..733a4287b 100644
--- a/src/contacts/details/qcontactphonenumber.h
+++ b/src/contacts/details/qcontactphonenumber.h
@@ -53,6 +53,7 @@ public:
enum PhoneNumberField {
FieldNumber = 0,
+ FieldNormalizedNumber,
FieldSubTypes
};
@@ -75,6 +76,9 @@ public:
void setNumber(const QString &_number);
QString number() const;
+ void setNormalizedNumber(const QString &_normalizedNumber);
+ QString normalizedNumber() const;
+
void setSubTypes(const QList<int> &_subTypes);
QList<int> subTypes() const;
diff --git a/src/contacts/details/qcontacttimestamp.h b/src/contacts/details/qcontacttimestamp.h
index ac5221992..92783c405 100644
--- a/src/contacts/details/qcontacttimestamp.h
+++ b/src/contacts/details/qcontacttimestamp.h
@@ -52,13 +52,16 @@ public:
enum TimestampField {
FieldModificationTimestamp = 0,
- FieldCreationTimestamp
+ FieldCreationTimestamp,
+ FieldDeletionTimestamp
};
void setLastModified(const QDateTime& timestamp);
QDateTime lastModified() const;
void setCreated(const QDateTime& timestamp);
QDateTime created() const;
+ void setDeleted(const QDateTime& timestamp);
+ QDateTime deleted() const;
};
QT_END_NAMESPACE_CONTACTS
diff --git a/src/contacts/qcontactdetail.cpp b/src/contacts/qcontactdetail.cpp
index 4eab92751..8cc033c95 100644
--- a/src/contacts/qcontactdetail.cpp
+++ b/src/contacts/qcontactdetail.cpp
@@ -493,6 +493,22 @@ QContactDetail::AccessConstraints QContactDetail::accessConstraints() const
return d.constData()->m_access;
}
+
+/*!
+ \fn QString QContactDetail::provenance() const
+
+ This is a convenience function to return the \c Provenance field of this detail.
+ Any detail in an aggregate contact which originally comes from a \c Facet contact
+ should have provenance information.
+
+ It is equivalent to the following code:
+ \code
+ value(QContactDetail::FieldProvenance);
+ \endcode
+
+ \sa value()
+ */
+
/*!
\enum QContactDetail::DetailContext
@@ -552,9 +568,11 @@ QContactDetail::AccessConstraints QContactDetail::accessConstraints() const
\value FieldContext The field containing the contexts of a detail.
\value FieldDetailUri The field containing the detail URI of a detail.
\value FieldLinkedDetailUris The field containing the URIs of other details linked to a detail.
+ \value FieldProvenance The field containing the provenance information for the detail.
\sa setContexts(), contexts()
\sa setDetailUri(), detailUri()
\sa setLinkedDetailUris(), linkedDetailUris()
+ \sa provenance()
*/
/*!
diff --git a/src/contacts/qcontactdetail.h b/src/contacts/qcontactdetail.h
index 9724733bd..8aff7c93d 100644
--- a/src/contacts/qcontactdetail.h
+++ b/src/contacts/qcontactdetail.h
@@ -91,6 +91,7 @@ public:
FieldContext = 5000, //to avoid clashing with other detail field values from leaf classes
FieldDetailUri,
FieldLinkedDetailUris,
+ FieldProvenance,
FieldMaximumUserVisible = 10000 // keys above this will not be reported to clients via values() etc accessors.
};
@@ -175,6 +176,11 @@ public:
return value<QStringList>(FieldLinkedDetailUris);
}
+ QString provenance() const
+ {
+ return value(FieldProvenance).toString();
+ }
+
protected:
QContactDetail(const QContactDetail &other, DetailType expectedType);
QContactDetail& assign(const QContactDetail &other, DetailType expectedType);
diff --git a/src/contacts/qcontactdetail_p.h b/src/contacts/qcontactdetail_p.h
index c9dd189b2..923eb23be 100644
--- a/src/contacts/qcontactdetail_p.h
+++ b/src/contacts/qcontactdetail_p.h
@@ -67,6 +67,7 @@ public:
QList<int> m_contexts;
// detail metadata
+ QString m_provenance;
QContactDetail::DetailType m_type;
QContactDetail::AccessConstraints m_access;
int m_detailId;
@@ -88,6 +89,7 @@ public:
QContactDetailPrivate(const QContactDetailPrivate& other)
: QSharedData(other)
, m_contexts(other.m_contexts)
+ , m_provenance(other.m_provenance)
, m_type(other.m_type)
, m_access(other.m_access)
, m_detailId(other.m_detailId)
@@ -102,7 +104,7 @@ public:
return new QContactDetailPrivate(*this);
}
- virtual bool operator==(const QContactDetailPrivate& other) const { // doesn't check detailId
+ virtual bool operator==(const QContactDetailPrivate& other) const { // doesn't check detailId or provenance
if (m_type != other.m_type
|| m_hasValueBitfield != other.m_hasValueBitfield
|| m_contexts != other.m_contexts
@@ -133,6 +135,11 @@ public:
d->d->m_access = constraint;
}
+ static void setProvenance(QContactDetail *d, const QString &newProvenance)
+ {
+ d->d->m_provenance = newProvenance;
+ }
+
static const QContactDetailPrivate* detailPrivate(const QContactDetail& detail)
{
return detail.d.constData();
@@ -170,6 +177,11 @@ public:
setHasValueBitfieldBit(true, FieldContextBit);
return true;
}
+ case QContactDetail::FieldProvenance: {
+ m_provenance = _value.toString();
+ setHasValueBitfieldBit(!m_provenance.isEmpty(), FieldProvenanceBit);
+ return true;
+ }
default: {
// add the data as an extraData field
m_extraData.insert(field, _value);
@@ -186,6 +198,11 @@ public:
setHasValueBitfieldBit(false, FieldContextBit);
return true;
}
+ case QContactDetail::FieldProvenance: {
+ m_provenance = QString();
+ setHasValueBitfieldBit(false, FieldProvenanceBit);
+ return true;
+ }
default: {
return m_extraData.remove(field);
// don't need to clear hasValueBitfield bit for fields stored in extra data.
@@ -196,6 +213,7 @@ public:
virtual bool hasValue(int field) const {
switch (field) {
case QContactDetail::FieldContext: return hasValueBitfieldBitSet(FieldContextBit);
+ case QContactDetail::FieldProvenance: return hasValueBitfieldBitSet(FieldProvenanceBit);
default: return m_extraData.contains(field);
}
}
@@ -209,6 +227,9 @@ public:
if (hasValueBitfieldBitSet(FieldContextBit)) {
retn.insert(QContactDetail::FieldContext, QVariant::fromValue<QList<int> >(m_contexts));
}
+ if (hasValueBitfieldBitSet(FieldProvenanceBit)) {
+ retn.insert(QContactDetail::FieldProvenance, QVariant::fromValue<QString>(m_provenance));
+ }
QMap<int, QVariant>::const_iterator it = m_extraData.constBegin(), end = m_extraData.constEnd();
for ( ; it != end; ++it) {
if (it.key() <= QContactDetail::FieldMaximumUserVisible) {
@@ -221,6 +242,7 @@ public:
virtual QVariant value(int field) const {
switch (field) {
case QContactDetail::FieldContext: return QVariant::fromValue<QList<int> >(m_contexts);
+ case QContactDetail::FieldProvenance: return QVariant::fromValue<QString>(m_provenance);
default: return m_extraData.value(field);
}
}
diff --git a/src/contacts/qcontactmanagerengine.cpp b/src/contacts/qcontactmanagerengine.cpp
index 44b282108..2236590ea 100644
--- a/src/contacts/qcontactmanagerengine.cpp
+++ b/src/contacts/qcontactmanagerengine.cpp
@@ -820,6 +820,27 @@ void QContactManagerEngine::setDetailAccessConstraints(QContactDetail *detail, Q
}
}
+/*!
+ Sets the provenance of \a detail to the supplied \a provenance.
+
+ This function is provided to allow engine implementations to report the
+ provenance of retrieved details, without generally allowing the
+ provenance metadata to be modified after retrieval.
+
+ The provenance of a detail in an aggregate Contact should include the
+ id of the Facet contact and the detail id of the particular detail in
+ that Facet contact from which the aggregate Contact's detail was promoted.
+
+ Application code should not call this function, since validation of the
+ detail will happen in the engine in any case.
+ */
+void QContactManagerEngine::setDetailProvenance(QContactDetail *detail, const QString &provenance)
+{
+ if (detail) {
+ QContactDetailPrivate::setProvenance(detail, provenance);
+ }
+}
+
/*!
Adds the given \a contact to the database if \a contact has a
diff --git a/src/contacts/qcontactmanagerengine.h b/src/contacts/qcontactmanagerengine.h
index 82079d93a..b7e06f78d 100644
--- a/src/contacts/qcontactmanagerengine.h
+++ b/src/contacts/qcontactmanagerengine.h
@@ -156,6 +156,7 @@ public:
// Other protected area update functions
static void setDetailAccessConstraints(QContactDetail *detail, QContactDetail::AccessConstraints constraints);
static void setContactRelationships(QContact *contact, const QList<QContactRelationship> &relationships);
+ static void setDetailProvenance(QContactDetail *detail, const QString &provenance);
/* Helper functions */
static int compareContact(const QContact &a, const QContact &b, const QList<QContactSortOrder> &sortOrders);
diff --git a/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp b/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp
index 5fb75b6e0..a96550596 100644
--- a/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp
+++ b/tests/auto/contacts/qcontactdetail/tst_qcontactdetail.cpp
@@ -224,6 +224,13 @@ void tst_QContactDetail::assignment()
p1 = p2;
QVERIFY(p1 == p2);
+ QContactManagerEngine::setDetailProvenance(&p2, QStringLiteral("test-provenance"));
+ QCOMPARE(p2.provenance(), QStringLiteral("test-provenance"));
+ QCOMPARE(p1.provenance(), QString());
+ QVERIFY(p1 == p2); // provenance shouldn't affect comparison
+ p1 = p2; // but should be copied on copy/assignment
+ QCOMPARE(p2.provenance(), p1.provenance());
+
QContactEmailAddress e1;
e1.setEmailAddress("test@nokia.com");
QVERIFY(e1 != p1);
diff --git a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
index bae8bdbb6..26f7d80b9 100644
--- a/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
+++ b/tests/auto/contacts/qcontactdetails/tst_qcontactdetails.cpp
@@ -247,10 +247,13 @@ void tst_QContactDetails::avatar()
QCOMPARE(a1.value<QUrl>(QContactAvatar::FieldImageUrl), QUrl("1234"));
a2.setVideoUrl(QUrl("videoUrl"));
a2.setImageUrl(QUrl("imageUrl"));
+ a2.setMetaData(QString("1234"));
QCOMPARE(a2.videoUrl(), QUrl("videoUrl"));
QCOMPARE(a2.value<QUrl>(QContactAvatar::FieldVideoUrl), QUrl("videoUrl"));
QCOMPARE(a2.imageUrl(), QUrl("imageUrl"));
QCOMPARE(a2.value<QUrl>(QContactAvatar::FieldImageUrl), QUrl("imageUrl"));
+ QCOMPARE(a2.metaData(), QString("1234"));
+ QCOMPARE(a2.value<QString>(QContactAvatar::FieldMetaData), QString("1234"));
// test property add
QVERIFY(c.saveDetail(&a1));
@@ -750,11 +753,13 @@ void tst_QContactDetails::name()
n1.setMiddleName("William Preston");
n1.setLastName("Gumboots");
n1.setSuffix("Esquire");
+ n1.setCustomLabel("Frederick The Example");
QCOMPARE(n1.prefix(), QString("Dr"));
QCOMPARE(n1.firstName(), QString("Freddy"));
QCOMPARE(n1.middleName(), QString("William Preston"));
QCOMPARE(n1.lastName(), QString("Gumboots"));
QCOMPARE(n1.suffix(), QString("Esquire"));
+ QCOMPARE(n1.customLabel(), QString("Frederick The Example"));
// Values based (QString)
QCOMPARE(n1.value(QContactName::FieldPrefix).toString(), QString("Dr"));
@@ -762,6 +767,7 @@ void tst_QContactDetails::name()
QCOMPARE(n1.value(QContactName::FieldMiddleName).toString(), QString("William Preston"));
QCOMPARE(n1.value(QContactName::FieldLastName).toString(), QString("Gumboots"));
QCOMPARE(n1.value(QContactName::FieldSuffix).toString(), QString("Esquire"));
+ QCOMPARE(n1.value(QContactName::FieldCustomLabel).toString(), QString("Frederick The Example"));
// test property add
QVERIFY(c.saveDetail(&n1));
@@ -983,6 +989,11 @@ void tst_QContactDetails::phoneNumber()
QCOMPARE(p1.number(), QString("1234"));
QCOMPARE(p1.value(QContactPhoneNumber::FieldNumber).toString(), QString("1234"));
+ // normalized number
+ p1.setNormalizedNumber("123");
+ QCOMPARE(p1.normalizedNumber(), QString("123"));
+ QCOMPARE(p1.value(QContactPhoneNumber::FieldNormalizedNumber).toString(), QString("123"));
+
// Sub types
p1.setSubTypes(QList<int>() << QContactPhoneNumber::SubTypeCar);
QCOMPARE(p1.subTypes(), QList<int>() << QContactPhoneNumber::SubTypeCar);
@@ -1192,16 +1203,21 @@ void tst_QContactDetails::timestamp()
QContactTimestamp t1, t2;
QDateTime modified = QDateTime::currentDateTime();
QDateTime created = modified.addSecs(-43);
+ QDateTime deleted = modified.addSecs(20);
// test property set
t1.setCreated(created);
+ t1.setDeleted(deleted);
QCOMPARE(t1.created(), created);
QCOMPARE(t1.value(QContactTimestamp::FieldCreationTimestamp).toDateTime(), created);
+ QCOMPARE(t1.deleted(), deleted);
+ QCOMPARE(t1.value(QContactTimestamp::FieldDeletionTimestamp).toDateTime(), deleted);
// test property add
QVERIFY(c.saveDetail(&t1));
QCOMPARE(c.details(QContactTimestamp::Type).count(), 1);
QCOMPARE(QContactTimestamp(c.details(QContactTimestamp::Type).value(0)).created(), t1.created());
+ QCOMPARE(QContactTimestamp(c.details(QContactTimestamp::Type).value(0)).deleted(), t1.deleted());
// test property update
t1.setValue(QContactTimestamp::FieldContext, QContactDetail::ContextWork);
@@ -1210,6 +1226,7 @@ void tst_QContactDetails::timestamp()
QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldContext).value<QList<int> >(), QList<int>() << QContactDetail::ContextWork);
QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldCreationTimestamp).toDateTime(), created);
QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldModificationTimestamp).toDateTime(), modified);
+ QCOMPARE(c.details(QContactTimestamp::Type).value(0).value(QContactTimestamp::FieldDeletionTimestamp).toDateTime(), deleted);
// test property remove
QVERIFY(c.removeDetail(&t1));