summaryrefslogtreecommitdiffstats
path: root/src/versit/qversitcontactimporter_p.cpp
diff options
context:
space:
mode:
authorMika Tikkakoski <mika.tikkakoski@nokia.com>2012-04-27 16:44:32 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-03 15:10:54 +0200
commit5c1fc9abf40b14f77c677b32786fb887332ccad9 (patch)
tree6fbb448677dc44155c6db98b538d94fdaad7525b /src/versit/qversitcontactimporter_p.cpp
parentaf7b755e8293e6b8ed97be3ce4ae4e8601a603f2 (diff)
Added support for QContactVersion detail to Versit.
Vcard extension X-QTPROJECT-VERSION to store sequenceNumber and extendedVersion from QContactVersion detail as a compound property. Change-Id: I1461b8d23372789e42228ba20bab7167f9fbb93c Reviewed-by: Cristiano di Flora <cristiano.di-flora@nokia.com>
Diffstat (limited to 'src/versit/qversitcontactimporter_p.cpp')
-rw-r--r--src/versit/qversitcontactimporter_p.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/versit/qversitcontactimporter_p.cpp b/src/versit/qversitcontactimporter_p.cpp
index f9579056e..f5352c1eb 100644
--- a/src/versit/qversitcontactimporter_p.cpp
+++ b/src/versit/qversitcontactimporter_p.cpp
@@ -249,6 +249,9 @@ void QVersitContactImporterPrivate::importProperty(
case QContactDetail::TypeTimestamp:
success = createTimeStamp(property, contact, &updatedDetails);
break;
+ case QContactDetail::TypeVersion:
+ success = createVersion(property, contact, &updatedDetails);
+ break;
default:
// Look up mDetailMappings for a simple mapping from property to detail.
success = createNameValueDetail(property, contact, &updatedDetails);
@@ -489,6 +492,36 @@ bool QVersitContactImporterPrivate::createTimeStamp(
}
/*!
+ * Creates a QContactVersion from \a property
+ */
+bool QVersitContactImporterPrivate::createVersion(
+ const QVersitProperty& property,
+ QContact* contact,
+ QList<QContactDetail>* updatedDetails)
+{
+ // Allow only on version detail, discard others.
+ QContactDetail detail = contact->detail(QContactVersion::Type);
+ if (!detail.isEmpty())
+ return false; // Only one version detail is created
+
+ QVariant variant = property.variantValue();
+ if (property.valueType() != QVersitProperty::CompoundType
+ || variant.type() != QVariant::StringList)
+ return false;
+ QStringList values = variant.toStringList();
+ bool ok;
+ QContactVersion version;
+ version.setSequenceNumber(takeFirst(values).toInt(&ok));
+ version.setExtendedVersion(takeFirst(values).toLocal8Bit());
+ if (ok) {
+ saveDetailWithContext(updatedDetails, version, extractContexts(property));
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/*!
* Creates a QContactAnniversary from \a property
*/
bool QVersitContactImporterPrivate::createAnniversary(