• 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
  • vcardparser
vcard.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2003 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 "vcard.h"
22 
23 using namespace KABC;
24 
25 VCard::VCard()
26 {
27 }
28 
29 VCard::VCard( const VCard &vcard )
30 {
31  mLineMap = vcard.mLineMap;
32 }
33 
34 VCard::~VCard()
35 {
36 }
37 
38 VCard &VCard::operator=( const VCard &vcard )
39 {
40  if ( &vcard == this ) {
41  return *this;
42  }
43 
44  mLineMap = vcard.mLineMap;
45 
46  return *this;
47 }
48 
49 void VCard::clear()
50 {
51  mLineMap.clear();
52 }
53 
54 QStringList VCard::identifiers() const
55 {
56  return mLineMap.keys();
57 }
58 
59 void VCard::addLine( const VCardLine &line )
60 {
61  mLineMap[ line.identifier() ].append( line );
62 }
63 
64 VCardLine::List VCard::lines( const QString &identifier ) const
65 {
66  LineMap::ConstIterator it = mLineMap.find( identifier );
67  if ( it == mLineMap.end() ) {
68  return VCardLine::List();
69  }
70 
71  return *it;
72 }
73 
74 VCardLine VCard::line( const QString &identifier ) const
75 {
76  LineMap::ConstIterator it = mLineMap.find( identifier );
77  if ( it == mLineMap.end() ) {
78  return VCardLine();
79  }
80 
81  if ( ( *it ).isEmpty() ) {
82  return VCardLine();
83  } else {
84  return ( *it ).first();
85  }
86 }
87 
88 void VCard::setVersion( Version version )
89 {
90  mLineMap.remove( QLatin1String( "VERSION" ) );
91 
92  VCardLine line;
93  line.setIdentifier( QLatin1String( "VERSION" ) );
94  if ( version == v2_1 ) {
95  line.setIdentifier( QLatin1String( "2.1" ) );
96  } else if ( version == v3_0 ) {
97  line.setIdentifier( QLatin1String( "3.0" ) );
98  }
99 
100  mLineMap[ QLatin1String( "VERSION" ) ].append( line );
101 }
102 
103 VCard::Version VCard::version() const
104 {
105  LineMap::ConstIterator versionEntry = mLineMap.find( QLatin1String( "VERSION" ) );
106  if ( versionEntry == mLineMap.end() ) {
107  return v3_0;
108  }
109 
110  VCardLine line = ( *versionEntry )[ 0 ];
111  if ( line.value() == QLatin1String( "2.1" ) ) {
112  return v2_1;
113  } else {
114  return v3_0;
115  }
116 }
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