![]() |
Home · All Classes · All Functions · | ![]() |
The QVersitContactImporter class creates QContacts from QVersitDocuments. More...
#include <QVersitContactImporter>
This class is under development and is subject to change.
QVersitContactImporter () | |
~QVersitContactImporter () | |
QList<QContact> | importContacts ( const QList<QVersitDocument> & documents ) |
QVersitContactImporterPropertyHandler * | propertyHandler () const |
QVersitResourceHandler * | resourceHandler () const |
void | setPropertyHandler ( QVersitContactImporterPropertyHandler * handler ) |
void | setResourceHandler ( QVersitResourceHandler * handler ) |
The QVersitContactImporter class creates QContacts from QVersitDocuments.
A QVersitResourceHandler is associated with the importer to supply the behaviour for saving files to persistent storage. By default, this is set to a QVersitDefaultResourceHandler, which does not save files to persistent storage. Note that although avatars found in vCards are not saved to disk by default, the importer does set the pixmap of the contact detail to the image. If a full-sized avatar image needs to be persisted, a custom QVersitResourceHandler should be supplied which implements this.
By associating a QVersitContactImporterPropertyHandler with the importer using setPropertyHandler(), the client can pass in a handler to override the processing of properties and/or handle properties that QVersitContactImporter doesn't support.
An example property handler that logs unknown properties:
class MyPropertyHandler : public QVersitContactImporterPropertyHandler { public: bool preProcessProperty(const QVersitDocument& document, const QVersitProperty& property, int contactIndex, QContact* contact) { return false; } bool postProcessProperty(const QVersitDocument& document, const QVersitProperty& property, bool alreadyProcessed, int contactIndex, QContact* contact) { if (!alreadyProcessed) mUnknownProperties.append(property); return false; } QList<QVersitProperty> mUnknownProperties; };
An example usage of QVersitContactImporter
QVersitContactImporter importer; MyPropertyHandler propertyHandler; importer.setPropertyHandler(&propertyHandler); QVersitDocument document; QVersitProperty property; property.setName(QString::fromAscii("N")); property.setValue("Citizen;John;Q;;"); document.addProperty(property); property.setName(QString::fromAscii("X-UNKNOWN-PROPERTY")); property.setValue("some value"); document.addProperty(property); QList<QVersitDocument> list; list.append(document); QList<QContact> contactList = importer.importContacts(list); // contactList.first() now contains the "N" property as a QContactName // propertyHandler.mUnknownProperties contains the list of unknown properties
See also QVersitDocument, QVersitReader, and QVersitContactImporterPropertyHandler.
Constructs a new importer
Frees the memory used by the importer
Converts documents into a corresponding list of QContacts.
Gets the handler for processing QVersitProperties.
See also setPropertyHandler().
Returns the associated resource handler.
See also setResourceHandler().
Sets handler to be the handler for processing QVersitProperties, or 0 to have no handler.
See also propertyHandler().
Sets handler to be the handler to save files with, or 0 to have no handler.
See also resourceHandler().
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt Mobility Project 1.0.0 |