| # kabc Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, 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   mLineMap = vcard.mLineMap;
    00044
    00045   return *this;
    00046 }
    00047
    00048 void VCard::clear()
    00049 {
    00050   mLineMap.clear();
    00051 }
    00052
    00053 QStringList VCard::identifiers() const
    00054 {
    00055   return mLineMap.keys();
    00056 }
    00057
    00058 void VCard::addLine( const VCardLine& line )
    00059 {
    00060   mLineMap[ line.identifier() ].append( line );
    00061 }
    00062
    00063 VCardLine::List VCard::lines( const QString& identifier ) const
    00064 {
    00065   LineMap::ConstIterator it = mLineMap.find( identifier );
    00066   if ( it == mLineMap.end() )
    00067     return VCardLine::List();
    00068
    00069   return *it;
    00070 }
    00071
    00072 VCardLine VCard::line( const QString& identifier ) const
    00073 {
    00074   LineMap::ConstIterator it = mLineMap.find( identifier );
    00075   if ( it == mLineMap.end() )
    00076     return VCardLine();
    00077
    00078   if ( (*it).isEmpty() )
    00079     return VCardLine();
    00080   else
    00081     return (*it).first();
    00082 }
    00083
    00084 void VCard::setVersion( Version version )
    00085 {
    00086   mLineMap.erase( "VERSION" );
    00087
    00088   VCardLine line;
    00089   line.setIdentifier( "VERSION" );
    00090   if ( version == v2_1 )
    00091     line.setIdentifier( "2.1" );
    00092   else if ( version == v3_0 )
    00093     line.setIdentifier( "3.0" );
    00094
    00095   mLineMap[ "VERSION" ].append( line );
    00096 }
    00097
    00098 VCard::Version VCard::version() const
    00099 {
    00100   LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" );
    00101   if ( versionEntry == mLineMap.end() )
    00102     return v3_0;
    00103
    00104   VCardLine line = ( *versionEntry )[ 0 ];
    00105   if ( line.value() == "2.1" )
    00106     return v2_1;
    00107   else
    00108     return v3_0;
    00109 }

This file is part of the documentation for kabc Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:31 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003