kabc
vcardline.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 "vcardline.h" 00022 00023 using namespace KABC; 00024 00025 VCardLine::VCardLine() 00026 { 00027 } 00028 00029 VCardLine::VCardLine( const QString &identifier ) 00030 { 00031 mIdentifier = identifier; 00032 } 00033 00034 VCardLine::VCardLine( const QString &identifier, const QVariant &value ) 00035 { 00036 mIdentifier = identifier; 00037 mValue = value; 00038 } 00039 00040 VCardLine::VCardLine( const VCardLine &line ) 00041 { 00042 mParamMap = line.mParamMap; 00043 mValue = line.mValue; 00044 mIdentifier = line.mIdentifier; 00045 } 00046 00047 VCardLine::~VCardLine() 00048 { 00049 } 00050 00051 VCardLine &VCardLine::operator=( const VCardLine &line ) 00052 { 00053 if ( &line == this ) { 00054 return *this; 00055 } 00056 00057 mParamMap = line.mParamMap; 00058 mValue = line.mValue; 00059 mIdentifier = line.mIdentifier; 00060 00061 return *this; 00062 } 00063 00064 void VCardLine::setIdentifier( const QString &identifier ) 00065 { 00066 mIdentifier = identifier; 00067 } 00068 00069 QString VCardLine::identifier() const 00070 { 00071 return mIdentifier; 00072 } 00073 00074 void VCardLine::setValue( const QVariant &value ) 00075 { 00076 mValue = value; 00077 } 00078 00079 QVariant VCardLine::value() const 00080 { 00081 return mValue; 00082 } 00083 00084 void VCardLine::setGroup( const QString &group ) 00085 { 00086 mGroup = group; 00087 } 00088 00089 QString VCardLine::group() const 00090 { 00091 return mGroup; 00092 } 00093 00094 bool VCardLine::hasGroup() const 00095 { 00096 return !mGroup.isEmpty(); 00097 } 00098 00099 QStringList VCardLine::parameterList() const 00100 { 00101 return mParamMap.keys(); 00102 } 00103 00104 void VCardLine::addParameter( const QString ¶m, const QString &value ) 00105 { 00106 QStringList &list = mParamMap[ param ]; 00107 if ( !list.contains( value ) ) { // not included yet 00108 list.append( value ); 00109 } 00110 } 00111 00112 QStringList VCardLine::parameters( const QString ¶m ) const 00113 { 00114 ParamMap::ConstIterator it = mParamMap.find( param ); 00115 if ( it == mParamMap.end() ) { 00116 return QStringList(); 00117 } else { 00118 return *it; 00119 } 00120 } 00121 00122 QString VCardLine::parameter( const QString ¶m ) const 00123 { 00124 ParamMap::ConstIterator it = mParamMap.find( param ); 00125 if ( it == mParamMap.end() ) { 00126 return QString(); 00127 } else { 00128 if ( (*it).isEmpty() ) { 00129 return QString(); 00130 } else { 00131 return (*it).first(); 00132 } 00133 } 00134 }