Qt Mobility Reference Documentation

QVersitContactExporterDetailHandlerV2 Class Reference

The QVersitContactExporterDetailHandlerV2 class is an interface for clients wishing to implement custom export behaviour for certain contact details. More...

 #include <QVersitContactExporterDetailHandlerV2>

Public Functions

virtual ~QVersitContactExporterDetailHandlerV2 ()
virtual void contactProcessed ( const QContact & contact, QVersitDocument * document ) = 0
virtual void detailProcessed ( const QContact & contact, const QContactDetail & detail, const QSet<QString> & processedFields, const QVersitDocument & document, QList<QVersitProperty> * toBeRemoved, QList<QVersitProperty> * toBeAdded ) = 0

Static Public Members

QVersitContactExporterDetailHandlerV2 * createBackupHandler ()

Detailed Description

The QVersitContactExporterDetailHandlerV2 class is an interface for clients wishing to implement custom export behaviour for certain contact details.

This interface supercedes QVersitContactImporterPropertyHandler.

See also QVersitContactExporter.


Member Function Documentation

QVersitContactExporterDetailHandlerV2::~QVersitContactExporterDetailHandlerV2 () [virtual]

Frees any memory in use by this handler.

void QVersitContactExporterDetailHandlerV2::contactProcessed ( const QContact & contact, QVersitDocument * document ) [pure virtual]

Perform any final processing on the document generated by the contact. This can be implemented by the handler to clear any internal state before moving onto the next contact.

This function is called after all QContactDetails have been handled by the QVersitContactExporter.

QVersitContactExporterDetailHandlerV2 * QVersitContactExporterDetailHandlerV2::createBackupHandler () [static]

Constructs and returns a detail handler that encodes all details not handled by the base exporter. The caller is responsible for deleting the object.

This handler encodes all writable details that the exporter doesn't recognise. The format it uses to encode the detail is as follows:

  • All generated properties will have the name X-NOKIA-QCONTACTFIELD
  • All generated properties will have a single Versit group, and all properties generated from a single detail will have the same group.
  • All generated properties will have at least the parameters DETAIL, which holds the definition name of the QContactDetail from which it was generated, and FIELD, which holds the name of the field within the detail from which it was generated.
  • If the field is of type QString or QByteArray, the property's value is set directly to the value of the field. (For a QByteArray value, the QVersitWriter will base-64 encode it.)
  • If the field is of type bool, int, uint, QDate, QTime, QDateTime or QUrl a the property's value is set to a string representation of the field. A parameter DATATYPE is added to the property with value BOOL, INT, UINT, DATE, TIME or DATETIME depending on the type.
  • If the field is of some other type, the field value is encoded to a QByteArray via QDataStream (and the resulting byte array is base-64 encoded by the QVersitWriter). In this case, the parameter DATATYPE=VARIANT is added to the Versit property.

For example, a detail with definition name "Pet" and fields "Name"="Rex" and "Age"=(int)14 will be exported to the vCard properties:

 G0.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Name:Rex
 G0.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Age;DATATYPE=INT:14

And the next detail (say, "Pet" with a field "Name"="Molly" will generate:

 G1.X-NOKIA-QCONTACTFIELD;DETAIL=Pet;FIELD=Name:Molly

The properties produced by this class can be imported by the importer "backup" property handler (created by QVersitContactImporterPropertyHandlerV2::createBackupHandler()) to reproduce the original QContactDetails.

Clients wishing to implement their own detail handler and also benefit from the functionality of the backup handler can use this function to construct one, and wrap a custom QVersitContactExporterDetailHandlerV2 around it. In the implementation of detailProcessed and contactProcessed, the respective functions in the backup handler should be called as the last step (ensuring the arguments are correctly updated and passed through).

void QVersitContactExporterDetailHandlerV2::detailProcessed ( const QContact & contact, const QContactDetail & detail, const QSet<QString> & processedFields, const QVersitDocument & document, QList<QVersitProperty> * toBeRemoved, QList<QVersitProperty> * toBeAdded ) [pure virtual]

Process detail and provide a list of updated QVersitProperties by modifying the toBeRemoved and toBeAdded lists.

This function is called on every QContactDetail encountered during an export, after the detail has been processed by the QVersitContactExporter. An implementation of this function can be made to provide support for QContactDetails not supported by QVersitContactExporter.

The supplied contact is the container for the detail. processedFields contains a list of fields in the detail that were considered by the QVersitContactExporter in processing the detail. document holds the state of the document before the detail was processed by the exporter.

toBeRemoved and toBeAdded are initially filled with a list of properties that the exporter will remove from and add to the document. These lists can be modified (by removing, modifying or adding properties) by the handler to control the changes that will actually be made to the document. If a property is to be modified in the document, the old version will appear in the toBeRemoved list and the new version will appear in the toBeAdded list.

After the handler returns control back to the exporter, the properties in the toBeRemoved list will be removed and the properties in the toBeAdded list will be appended to the document.


Copyright © 2009-2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Mobility Project 1.1.0