KCal Library
attendee.cpp
Go to the documentation of this file.
00001 /* 00002 This file is part of the kcal library. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00032 #include "attendee.h" 00033 00034 #include <kdebug.h> 00035 #include <klocale.h> 00036 00037 #include <QtCore/QStringList> 00038 00039 using namespace KCal; 00040 00045 //@cond PRIVATE 00046 class KCal::Attendee::Private 00047 { 00048 public: 00049 bool mRSVP; 00050 Role mRole; 00051 PartStat mStatus; 00052 QString mUid; 00053 QString mDelegate; 00054 QString mDelegator; 00055 CustomProperties mCustomProperties; 00056 }; 00057 //@endcond 00058 00059 Attendee::Attendee( const QString &name, const QString &email, bool rsvp, 00060 Attendee::PartStat status, Attendee::Role role, const QString &uid ) 00061 : d( new Attendee::Private ) 00062 { 00063 setName( name ); 00064 setEmail( email ); 00065 d->mRSVP = rsvp; 00066 d->mStatus = status; 00067 d->mRole = role; 00068 d->mUid = uid; 00069 } 00070 00071 Attendee::Attendee( const Attendee &attendee ) 00072 : Person( attendee ), 00073 d( new Attendee::Private( *attendee.d ) ) 00074 { 00075 } 00076 00077 Attendee::~Attendee() 00078 { 00079 delete d; 00080 } 00081 00082 bool KCal::Attendee::operator==( const Attendee &attendee ) 00083 { 00084 return 00085 ( Person & )*this == ( const Person & )attendee && 00086 d->mRSVP == attendee.d->mRSVP && 00087 d->mRole == attendee.d->mRole && 00088 d->mStatus == attendee.d->mStatus && 00089 d->mUid == attendee.d->mUid && 00090 d->mDelegate == attendee.d->mDelegate && 00091 d->mDelegator == attendee.d->mDelegator; 00092 } 00093 00094 Attendee &KCal::Attendee::operator=( const Attendee &attendee ) 00095 { 00096 // check for self assignment 00097 if ( &attendee == this ) { 00098 return *this; 00099 } 00100 00101 *d = *attendee.d; 00102 setName( attendee.name() ); 00103 setEmail( attendee.email() ); 00104 return *this; 00105 } 00106 00107 void Attendee::setRSVP( bool r ) 00108 { 00109 d->mRSVP = r; 00110 } 00111 00112 bool Attendee::RSVP() const 00113 { 00114 return d->mRSVP; 00115 } 00116 00117 void Attendee::setStatus( Attendee::PartStat status ) 00118 { 00119 d->mStatus = status; 00120 } 00121 00122 Attendee::PartStat Attendee::status() const 00123 { 00124 return d->mStatus; 00125 } 00126 00127 QString Attendee::statusStr() const 00128 { 00129 return statusName( d->mStatus ); 00130 } 00131 00132 QString Attendee::statusName( Attendee::PartStat status ) 00133 { 00134 switch ( status ) { 00135 default: 00136 case NeedsAction: 00137 return i18nc( "@item event, to-do or journal needs action", "Needs Action" ); 00138 break; 00139 case Accepted: 00140 return i18nc( "@item event, to-do or journal accepted", "Accepted" ); 00141 break; 00142 case Declined: 00143 return i18nc( "@item event, to-do or journal declined", "Declined" ); 00144 break; 00145 case Tentative: 00146 return i18nc( "@item event or to-do tentatively accepted", "Tentative" ); 00147 break; 00148 case Delegated: 00149 return i18nc( "@item event or to-do delegated", "Delegated" ); 00150 break; 00151 case Completed: 00152 return i18nc( "@item to-do completed", "Completed" ); 00153 break; 00154 case InProcess: 00155 return i18nc( "@item to-do in process of being completed", "In Process" ); 00156 break; 00157 case None: 00158 return i18nc( "@item event or to-do status unknown", "Unknown" ); 00159 break; 00160 } 00161 } 00162 00163 QStringList Attendee::statusList() 00164 { 00165 QStringList list; 00166 list << statusName( NeedsAction ); 00167 list << statusName( Accepted ); 00168 list << statusName( Declined ); 00169 list << statusName( Tentative ); 00170 list << statusName( Delegated ); 00171 list << statusName( Completed ); 00172 list << statusName( InProcess ); 00173 00174 return list; 00175 } 00176 00177 void Attendee::setRole( Attendee::Role role ) 00178 { 00179 d->mRole = role; 00180 } 00181 00182 Attendee::Role Attendee::role() const 00183 { 00184 return d->mRole; 00185 } 00186 00187 QString Attendee::roleStr() const 00188 { 00189 return roleName( d->mRole ); 00190 } 00191 00192 void Attendee::setUid( const QString &uid ) 00193 { 00194 d->mUid = uid; 00195 } 00196 00197 QString Attendee::uid() const 00198 { 00199 return d->mUid; 00200 } 00201 00202 QString Attendee::roleName( Attendee::Role role ) 00203 { 00204 switch ( role ) { 00205 case Chair: 00206 return i18nc( "@item chairperson", "Chair" ); 00207 break; 00208 default: 00209 case ReqParticipant: 00210 return i18nc( "@item participation is required", "Participant" ); 00211 break; 00212 case OptParticipant: 00213 return i18nc( "@item participation is optional", "Optional Participant" ); 00214 break; 00215 case NonParticipant: 00216 return i18nc( "@item non-participant copied for information", "Observer" ); 00217 break; 00218 } 00219 } 00220 00221 QStringList Attendee::roleList() 00222 { 00223 QStringList list; 00224 list << roleName( ReqParticipant ); 00225 list << roleName( OptParticipant ); 00226 list << roleName( NonParticipant ); 00227 list << roleName( Chair ); 00228 00229 return list; 00230 } 00231 00232 void Attendee::setDelegate( const QString &delegate ) 00233 { 00234 d->mDelegate = delegate; 00235 } 00236 00237 QString Attendee::delegate() const 00238 { 00239 return d->mDelegate; 00240 } 00241 00242 void Attendee::setDelegator( const QString &delegator ) 00243 { 00244 d->mDelegator = delegator; 00245 } 00246 00247 QString Attendee::delegator() const 00248 { 00249 return d->mDelegator; 00250 } 00251 00252 void Attendee::setCustomProperty( const QByteArray &xname, const QString &xvalue ) 00253 { 00254 d->mCustomProperties.setNonKDECustomProperty( xname, xvalue ); 00255 } 00256 00257 CustomProperties &Attendee::customProperties() 00258 { 00259 return d->mCustomProperties; 00260 } 00261 00262 const CustomProperties &Attendee::customProperties() const 00263 { 00264 return d->mCustomProperties; 00265 }