KContacts::VCardConverter Class
class KContacts::VCardConverterClass to converting contact objects into vCard format and vice versa. More...
Header: | #include <KContacts/VCardConverter> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Contacts) target_link_libraries(mytarget PRIVATE KF6::Contacts) |
Public Types
enum | Version { v2_1, v3_0, v4_0 } |
Public Functions
VCardConverter() | |
QByteArray | createVCard(const KContacts::Addressee &addr, KContacts::VCardConverter::Version version = v3_0) const |
QByteArray | createVCards(const KContacts::Addressee::List &list, KContacts::VCardConverter::Version version = v3_0) const |
(since 4.9.1) QByteArray | exportVCard(const KContacts::Addressee &addr, KContacts::VCardConverter::Version version) const |
(since 4.9.1) QByteArray | exportVCards(const KContacts::Addressee::List &list, KContacts::VCardConverter::Version version) const |
KContacts::Addressee | parseVCard(const QByteArray &vcard) const |
KContacts::Addressee::List | parseVCards(const QByteArray &vcard) const |
Detailed Description
This class implements reading and writing of contact using from/to the vCard format. Currently vCard version 2.1 and 3.0 is supported.
Example:
QFile file( "myfile.vcf" ); file.open( QIODevice::ReadOnly ); QByteArray data = file.readAll(); VCardConverter converter; Addressee::List list = converter.parseVCards( data ); // print formatted name of first contact qDebug( "name=%s", list[ 0 ].formattedName().toLatin1() );
Member Type Documentation
enum VCardConverter::Version
Constant | Value | Description |
---|---|---|
KContacts::VCardConverter::v2_1 | 0 | VCard format version 2.1 |
KContacts::VCardConverter::v3_0 | 1 | VCard format version 3.0 |
KContacts::VCardConverter::v4_0 | 2 | VCard format version 4.0 |
Member Function Documentation
VCardConverter::VCardConverter()
Constructor.
QByteArray VCardConverter::createVCard(const KContacts::Addressee &addr, KContacts::VCardConverter::Version version = v3_0) const
Creates a string in vCard format which contains the given contact.
addr The contact object
version The version of the generated vCard format
QByteArray VCardConverter::createVCards(const KContacts::Addressee::List &list, KContacts::VCardConverter::Version version = v3_0) const
Creates a string in vCard format which contains the given list of contact.
list The list of contact objects
version The version of the generated vCard format
[since 4.9.1]
QByteArray VCardConverter::exportVCard(const KContacts::Addressee &addr, KContacts::VCardConverter::Version version) const
This function was introduced in 4.9.1.
[since 4.9.1]
QByteArray VCardConverter::exportVCards(const KContacts::Addressee::List &list, KContacts::VCardConverter::Version version) const
This function was introduced in 4.9.1.
KContacts::Addressee VCardConverter::parseVCard(const QByteArray &vcard) const
Parses a string in vCard format and returns the first contact.
KContacts::Addressee::List VCardConverter::parseVCards(const QByteArray &vcard) const
Parses a string in vCard format and returns a list of contact objects.