47 #include "cnttransformemail.h" |
47 #include "cnttransformemail.h" |
48 #include "cnttransformurl.h" |
48 #include "cnttransformurl.h" |
49 #include "cnttransformaddress.h" |
49 #include "cnttransformaddress.h" |
50 #include "cnttransformbirthday.h" |
50 #include "cnttransformbirthday.h" |
51 #include "cnttransformonlineaccount.h" |
51 #include "cnttransformonlineaccount.h" |
|
52 #include "cnttransformonlineaccountsimple.h" |
52 #include "cnttransformorganisation.h" |
53 #include "cnttransformorganisation.h" |
53 #include "cnttransformavatar.h" |
54 #include "cnttransformavatar.h" |
54 #include "cnttransformringtone.h" |
55 #include "cnttransformringtone.h" |
55 #include "cnttransformthumbnail.h" |
56 #include "cnttransformthumbnail.h" |
56 #include "cnttransformsynctarget.h" |
57 #include "cnttransformsynctarget.h" |
80 |
81 |
81 CntTransformContact::~CntTransformContact() |
82 CntTransformContact::~CntTransformContact() |
82 { |
83 { |
83 delete m_tzConverter; |
84 delete m_tzConverter; |
84 m_tzoneServer.Close(); |
85 m_tzoneServer.Close(); |
|
86 |
|
87 m_fieldTypeToTransformContact.clear(); |
85 |
88 |
86 QMap<ContactData, CntTransformContactData*>::iterator itr; |
89 QMap<ContactData, CntTransformContactData*>::iterator itr; |
87 |
90 |
88 for (itr = m_transformContactData.begin(); itr != m_transformContactData.end(); ++itr) |
91 for (itr = m_transformContactData.begin(); itr != m_transformContactData.end(); ++itr) |
89 { |
92 { |
130 |
133 |
131 m_transformContactData.insert(Thumbnail, new CntTransformThumbnail); |
134 m_transformContactData.insert(Thumbnail, new CntTransformThumbnail); |
132 |
135 |
133 // variated transform classes |
136 // variated transform classes |
134 m_transformContactData.insert(Anniversary, new CntTransformAnniversarySimple); |
137 m_transformContactData.insert(Anniversary, new CntTransformAnniversarySimple); |
|
138 m_transformContactData.insert(OnlineAccount, new CntTransformOnlineAccount); |
135 #endif |
139 #endif |
136 } |
140 } |
137 |
141 |
138 /*! |
142 /*! |
139 * Converts Symbian contact item to QContact. Note that the contact is not |
143 * Converts Symbian contact item to QContact. Note that the contact is not |
141 * in the database are not transformed. Use transformPostSaveDetailsL to |
145 * in the database are not transformed. Use transformPostSaveDetailsL to |
142 * transform those details after the contact item has been saved. |
146 * transform those details after the contact item has been saved. |
143 * \param contact A reference to a symbian contact item to be converted. |
147 * \param contact A reference to a symbian contact item to be converted. |
144 * \return Qt Contact |
148 * \return Qt Contact |
145 */ |
149 */ |
146 QContact CntTransformContact::transformContactL(CContactItem &contact, const QStringList& definitionRestrictions) const |
150 QContact CntTransformContact::transformContactL(CContactItem &contact) |
147 { |
151 { |
148 // Create a new QContact |
152 // Create a new QContact |
149 QContact newQtContact; |
153 QContact newQtContact; |
150 |
154 |
151 // set the corect type |
155 // set the corect type |
286 ++i; |
286 ++i; |
287 } |
287 } |
288 return uids; |
288 return uids; |
289 } |
289 } |
290 |
290 |
|
291 QList<TUid> CntTransformContact::itemFieldUidsL(const QString detailDefinitionName) const |
|
292 { |
|
293 QList<TUid> fieldUids; |
|
294 QMap<ContactData, CntTransformContactData*>::const_iterator i = m_transformContactData.constBegin(); |
|
295 |
|
296 while (i != m_transformContactData.constEnd()) { |
|
297 if (i.value()->supportsDetail(detailDefinitionName)) { |
|
298 // The leaf class supports this detail, so check which field type |
|
299 // uids it supports, use empty field name to get all the supported uids |
|
300 fieldUids << i.value()->supportedFields(); |
|
301 |
|
302 // Assume there are no more leaf classes for this detail |
|
303 break; |
|
304 } |
|
305 i++; |
|
306 } |
|
307 return fieldUids; |
|
308 } |
|
309 |
291 TUint32 CntTransformContact::GetIdForDetailL(const QContactDetailFilter& detailFilter, bool& isSubtype) const |
310 TUint32 CntTransformContact::GetIdForDetailL(const QContactDetailFilter& detailFilter, bool& isSubtype) const |
292 { |
311 { |
293 isSubtype = false; |
312 isSubtype = false; |
294 QString defnitionName = detailFilter.detailDefinitionName(); |
313 QString defnitionName = detailFilter.detailDefinitionName(); |
295 QString fieldName = detailFilter.detailFieldName(); |
314 QString fieldName = detailFilter.detailFieldName(); |
357 ++i; |
376 ++i; |
358 } |
377 } |
359 return itemFieldList; |
378 return itemFieldList; |
360 } |
379 } |
361 |
380 |
362 QContactDetail *CntTransformContact::transformItemField(const CContactItemField& field, const QContact &contact) const |
381 QContactDetail *CntTransformContact::transformItemField(const CContactItemField& field, const QContact &contact) |
363 { |
382 { |
364 QContactDetail *detail(0); |
383 QContactDetail *detail(0); |
365 |
384 |
366 if(field.ContentType().FieldTypeCount()) { |
385 if(field.ContentType().FieldTypeCount()) { |
367 TUint32 fieldType(field.ContentType().FieldType(0).iUid); |
386 TUint32 fieldType(field.ContentType().FieldType(0).iUid); |
368 |
387 |
369 QMap<ContactData, CntTransformContactData*>::const_iterator i = m_transformContactData.constBegin(); |
388 // Check if the mapping from field type to transform class pointer is available |
370 while (i != m_transformContactData.constEnd()) { |
389 // (this is faster than iterating through all the transform classes) |
371 if (i.value()->supportsField(fieldType)) { |
390 if (m_fieldTypeToTransformContact.contains(fieldType)) { |
372 detail = i.value()->transformItemField(field, contact); |
391 detail = m_fieldTypeToTransformContact[fieldType]->transformItemField(field, contact); |
373 break; |
392 } else { |
374 } |
393 // Mapping from field type to transform class pointer not found, |
375 ++i; |
394 // find the correct transform class by iterating through all the |
376 } |
395 // transform classes |
377 } |
396 QMap<ContactData, CntTransformContactData*>::const_iterator i = m_transformContactData.constBegin(); |
378 |
397 while (i != m_transformContactData.constEnd()) { |
379 return detail; |
398 if (i.value()->supportsField(fieldType)) { |
|
399 detail = i.value()->transformItemField(field, contact); |
|
400 m_fieldTypeToTransformContact.insert(fieldType, i.value()); |
|
401 break; |
|
402 } |
|
403 i++; |
|
404 } |
|
405 } |
|
406 } |
|
407 |
|
408 return detail; |
380 } |
409 } |
381 |
410 |
382 QContactDetail* CntTransformContact::transformGuidItemFieldL(const CContactItem &contactItem, const CContactDatabase &contactDatabase) const |
411 QContactDetail* CntTransformContact::transformGuidItemFieldL(const CContactItem &contactItem, const CContactDatabase &contactDatabase) const |
383 { |
412 { |
384 QContactGuid *guidDetail = 0; |
413 QContactGuid *guidDetail = 0; |