kabc
vcard.cpp
00001 /* 00002 This file is part of libkabc. 00003 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "vcard.h" 00022 00023 using namespace KABC; 00024 00025 VCard::VCard() 00026 { 00027 } 00028 00029 VCard::VCard( const VCard &vcard ) 00030 { 00031 mLineMap = vcard.mLineMap; 00032 } 00033 00034 VCard::~VCard() 00035 { 00036 } 00037 00038 VCard &VCard::operator=( const VCard &vcard ) 00039 { 00040 if ( &vcard == this ) { 00041 return *this; 00042 } 00043 00044 mLineMap = vcard.mLineMap; 00045 00046 return *this; 00047 } 00048 00049 void VCard::clear() 00050 { 00051 mLineMap.clear(); 00052 } 00053 00054 QStringList VCard::identifiers() const 00055 { 00056 return mLineMap.keys(); 00057 } 00058 00059 void VCard::addLine( const VCardLine &line ) 00060 { 00061 mLineMap[ line.identifier() ].append( line ); 00062 } 00063 00064 VCardLine::List VCard::lines( const QString &identifier ) const 00065 { 00066 LineMap::ConstIterator it = mLineMap.find( identifier ); 00067 if ( it == mLineMap.end() ) { 00068 return VCardLine::List(); 00069 } 00070 00071 return *it; 00072 } 00073 00074 VCardLine VCard::line( const QString &identifier ) const 00075 { 00076 LineMap::ConstIterator it = mLineMap.find( identifier ); 00077 if ( it == mLineMap.end() ) { 00078 return VCardLine(); 00079 } 00080 00081 if ( (*it).isEmpty() ) { 00082 return VCardLine(); 00083 } else { 00084 return (*it).first(); 00085 } 00086 } 00087 00088 void VCard::setVersion( Version version ) 00089 { 00090 mLineMap.remove( QLatin1String( "VERSION" ) ); 00091 00092 VCardLine line; 00093 line.setIdentifier( QLatin1String( "VERSION" ) ); 00094 if ( version == v2_1 ) { 00095 line.setIdentifier( QLatin1String( "2.1" ) ); 00096 } else if ( version == v3_0 ) { 00097 line.setIdentifier( QLatin1String( "3.0" ) ); 00098 } 00099 00100 mLineMap[ QLatin1String( "VERSION" ) ].append( line ); 00101 } 00102 00103 VCard::Version VCard::version() const 00104 { 00105 LineMap::ConstIterator versionEntry = mLineMap.find( QLatin1String( "VERSION" ) ); 00106 if ( versionEntry == mLineMap.end() ) { 00107 return v3_0; 00108 } 00109 00110 VCardLine line = ( *versionEntry )[ 0 ]; 00111 if ( line.value() == QLatin1String( "2.1" ) ) { 00112 return v2_1; 00113 } else { 00114 return v3_0; 00115 } 00116 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:26:08 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:26:08 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.