author | zautrix <zautrix> | 2005-03-10 22:11:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-10 22:11:30 (UTC) |
commit | b6845008e161e1bb355a32767c3e3f89ff8e5c01 (patch) (side-by-side diff) | |
tree | b1618c2a81ee8fa26d00332352fde82f2e3e51c9 /kabc/vcardparser/vcard.cpp | |
parent | 6e3c3178fa8e0c421753c08506b4a91bbcecc26f (diff) | |
download | kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.zip kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.tar.gz kdepimpi-b6845008e161e1bb355a32767c3e3f89ff8e5c01.tar.bz2 |
quoted printable for kapi
-rw-r--r-- | kabc/vcardparser/vcard.cpp | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/kabc/vcardparser/vcard.cpp b/kabc/vcardparser/vcard.cpp index da97ec2..24fd498 100644 --- a/kabc/vcardparser/vcard.cpp +++ b/kabc/vcardparser/vcard.cpp @@ -23,28 +23,16 @@ using namespace KABC; VCard::VCard() - : mLineMap( 0 ) { } VCard::VCard( const VCard& vcard ) - : mLineMap( 0 ) { - if ( vcard.mLineMap ) { - if ( !mLineMap ) - mLineMap = new QMap<QString, QValueList<VCardLine> >; - - *mLineMap = *(vcard.mLineMap); - } else { - delete mLineMap; - mLineMap = 0; - } + mLineMap = vcard.mLineMap; } VCard::~VCard() { - delete mLineMap; - mLineMap = 0; } VCard& VCard::operator=( const VCard& vcard ) @@ -52,91 +40,77 @@ VCard& VCard::operator=( const VCard& vcard ) if ( &vcard == this ) return *this; - if ( vcard.mLineMap ) { - if ( !mLineMap ) - mLineMap = new QMap<QString, QValueList<VCardLine> >; - - *mLineMap = *(vcard.mLineMap); - } else { - delete mLineMap; - mLineMap = 0; - } + mLineMap = vcard.mLineMap; return *this; } void VCard::clear() { - if ( mLineMap ) - mLineMap->clear(); + mLineMap.clear(); } QStringList VCard::identifiers() const { - if ( !mLineMap ) - return QStringList(); - else { -//US method QMap::keys() not available yet. SO collect the data manually -//US return mLineMap->keys(); - + //return mLineMap.keys(); +//PP re: US method QMap::keys() not available yet. SO collect the data manually + QStringList result; - - QMap< QString, VCardLine::List >::ConstIterator it; - for( it = mLineMap->begin(); it != mLineMap->end(); ++it ) { + + QMap<QString, VCardLine::List>::ConstIterator it; + for( it = mLineMap.begin(); it != mLineMap.end(); ++it ) { result << it.key().latin1(); } return result; - } } void VCard::addLine( const VCardLine& line ) { - if ( !mLineMap ) - mLineMap = new QMap<QString, QValueList<VCardLine> >; - - (*mLineMap)[ line.identifier() ].append( line ); + mLineMap[ line.identifier() ].append( line ); } -VCardLine::List VCard::lines( const QString& identifier ) +VCardLine::List VCard::lines( const QString& identifier ) const { - if ( !mLineMap ) + LineMap::ConstIterator it = mLineMap.find( identifier ); + if ( it == mLineMap.end() ) return VCardLine::List(); - else - return (*mLineMap)[ identifier ]; + + return *it; } -VCardLine VCard::line( const QString& identifier ) +VCardLine VCard::line( const QString& identifier ) const { - if ( !mLineMap ) + LineMap::ConstIterator it = mLineMap.find( identifier ); + if ( it == mLineMap.end() ) + return VCardLine(); + + if ( (*it).isEmpty() ) return VCardLine(); else - return (*mLineMap)[ identifier ][ 0 ]; + return (*it).first(); } void VCard::setVersion( Version version ) { - if ( !mLineMap ) - mLineMap = new QMap<QString, QValueList<VCardLine> >; - else { -//US mLineMap->erase( "VERSION" ); - mLineMap->remove( "VERSION" ); - } + mLineMap.remove( "VERSION" ); + VCardLine line; line.setIdentifier( "VERSION" ); if ( version == v2_1 ) line.setIdentifier( "2.1" ); - if ( version == v3_0 ) + else if ( version == v3_0 ) line.setIdentifier( "3.0" ); - (*mLineMap)[ "VERSION" ].append( line ); + mLineMap[ "VERSION" ].append( line ); } VCard::Version VCard::version() const { - if ( !mLineMap ) + LineMap::ConstIterator versionEntry = mLineMap.find( "VERSION" ); + if ( versionEntry == mLineMap.end() ) return v3_0; - VCardLine line = (*mLineMap)[ "VERSION" ][ 0 ]; + VCardLine line = ( *versionEntry )[ 0 ]; if ( line.value() == "2.1" ) return v2_1; else |