• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
vcardconverter.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "vcardconverter.h"
22 #include "vcardtool.h"
23 
24 using namespace KABC;
25 
26 VCardConverter::VCardConverter()
27  : d( 0 )
28 {
29 }
30 
31 VCardConverter::~VCardConverter()
32 {
33 }
34 
35 QByteArray VCardConverter::exportVCard( const Addressee &addr, Version version ) const
36 {
37  Addressee::List list;
38  list.append( addr );
39 
40  return exportVCards( list, version );
41 }
42 
43 QByteArray VCardConverter::exportVCards( const Addressee::List &list, Version version ) const
44 {
45  VCardTool tool;
46 
47  return tool.exportVCards( list, ( version == v3_0 ? VCard::v3_0 : VCard::v2_1 ) );
48 }
49 
50 QByteArray VCardConverter::createVCard( const Addressee &addr, Version version ) const
51 {
52  Addressee::List list;
53  list.append( addr );
54 
55  return createVCards( list, version );
56 }
57 
58 QByteArray VCardConverter::createVCards( Addressee::List list, Version version ) const
59 {
60  VCardTool tool;
61 
62  return tool.createVCards( list, ( version == v3_0 ? VCard::v3_0 : VCard::v2_1 ) );
63 }
64 
65 Addressee VCardConverter::parseVCard( const QByteArray &vcard ) const
66 {
67  Addressee::List list = parseVCards( vcard );
68 
69  return list.isEmpty() ? Addressee() : list[ 0 ];
70 }
71 
72 Addressee::List VCardConverter::parseVCards( const QByteArray &vcard ) const
73 {
74  VCardTool tool;
75 
76  return tool.parseVCards( vcard );
77 }
78 
79 /* Helper functions */
80 
81 QString KABC::dateToVCardString( const QDateTime &dateTime )
82 {
83  return dateTime.toString( QLatin1String( "yyyyMMddThhmmssZ" ) );
84 }
85 
86 QString KABC::dateToVCardString( const QDate &date )
87 {
88  return date.toString( QLatin1String( "yyyyMMdd" ) );
89 }
90 
91 QDateTime KABC::VCardStringToDate( const QString &dateString )
92 {
93  QDate date;
94  QTime time;
95  QString d( dateString );
96 
97  d = d.remove( QLatin1Char( '-' ) ).remove( QLatin1Char( ':' ) );
98 
99  if ( d.length() >= 8 ) {
100  date = QDate( d.mid( 0, 4 ).toUInt(), d.mid( 4, 2 ).toUInt(), d.mid( 6, 2 ).toUInt() );
101  }
102 
103  if ( d.length() > 9 && d[ 8 ].toUpper() == QLatin1Char( 'T' ) ) {
104  time = QTime( d.mid( 9, 2 ).toUInt(), d.mid( 11, 2 ).toUInt(), d.mid( 13, 2 ).toUInt() );
105  }
106 
107  return QDateTime( date, time );
108 }
KABC::VCardConverter::exportVCard
QByteArray exportVCard(const Addressee &addr, Version version) const
Definition: vcardconverter.cpp:35
KABC::VCardConverter::exportVCards
QByteArray exportVCards(const Addressee::List &list, Version version) const
Definition: vcardconverter.cpp:43
KABC::AddresseeList
a QValueList of Addressee, with sorting functionality
Definition: addresseelist.h:288
KABC::VCardConverter::parseVCard
Addressee parseVCard(const QByteArray &vcard) const
Parses a string in vCard format and returns the first contact.
Definition: vcardconverter.cpp:65
KABC::VCardConverter::parseVCards
Addressee::List parseVCards(const QByteArray &vcard) const
Parses a string in vCard format and returns a list of contact objects.
Definition: vcardconverter.cpp:72
KABC::VCardConverter::createVCard
QByteArray createVCard(const Addressee &addr, Version version=v3_0) const
Creates a string in vCard format which contains the given contact.
Definition: vcardconverter.cpp:50
KABC::VCardConverter::Version
Version
Definition: vcardconverter.h:61
KABC::VCardConverter::createVCards
QByteArray createVCards(Addressee::List list, Version version=v3_0) const
Creates a string in vCard format which contains the given list of contact.
Definition: vcardconverter.cpp:58
KABC::Addressee
address book entry
Definition: addressee.h:74
KABC::VCardConverter::VCardConverter
VCardConverter()
Constructor.
Definition: vcardconverter.cpp:26
KABC::VCardConverter::~VCardConverter
~VCardConverter()
Destructor.
Definition: vcardconverter.cpp:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal