libkcal

attendee.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of libkcal.
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 */
00021 
00022 #include <qstringlist.h>
00023 
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 
00027 #include "attendee.h"
00028 
00029 using namespace KCal;
00030 
00031 Attendee::Attendee( const QString &name, const QString &email, bool _rsvp,
00032                     Attendee::PartStat s, Attendee::Role r, const QString &u)
00033   : Person( name, email )
00034 {
00035   mRSVP = _rsvp;
00036   mStatus = s;
00037   mRole = r;
00038   mUid = u;
00039 }
00040 
00041 Attendee::~Attendee()
00042 {
00043 }
00044 
00045 bool KCal::operator==( const Attendee& a1, const Attendee& a2 )
00046 {
00047     return ( operator==( (const Person&)a1, (const Person&) a2 ) &&
00048              a1.RSVP() == a2.RSVP() &&
00049              a1.role() == a2.role() &&
00050              a1.status() == a2.status() &&
00051              a1.uid() == a2.uid() &&
00052              a1.delegate() == a2.delegate() &&
00053              a1.delegator() == a2.delegator() );
00054 }
00055 
00056 void Attendee::setStatus( Attendee::PartStat s )
00057 {
00058   mStatus = s;
00059 }
00060 
00061 Attendee::PartStat Attendee::status() const
00062 {
00063   return mStatus;
00064 }
00065 
00066 QString Attendee::statusStr() const
00067 {
00068   return statusName( mStatus );
00069 }
00070 
00071 QString Attendee::statusName( Attendee::PartStat s )
00072 {
00073   switch ( s ) {
00074     default:
00075     case NeedsAction:
00076       return i18n("Needs Action");
00077       break;
00078     case Accepted:
00079       return i18n("Accepted");
00080       break;
00081     case Declined:
00082       return i18n("Declined");
00083       break;
00084     case Tentative:
00085       return i18n("attendee status", "Tentative");
00086       break;
00087     case Delegated:
00088       return i18n("Delegated");
00089       break;
00090     case Completed:
00091       return i18n("Completed");
00092       break;
00093     case InProcess:
00094       return i18n("In Process");
00095       break;
00096   }
00097 }
00098 
00099 QStringList Attendee::statusList()
00100 {
00101   QStringList list;
00102   list << statusName( NeedsAction );
00103   list << statusName( Accepted );
00104   list << statusName( Declined );
00105   list << statusName( Tentative );
00106   list << statusName( Delegated );
00107   list << statusName( Completed );
00108   list << statusName( InProcess );
00109 
00110   return list;
00111 }
00112 
00113 
00114 void Attendee::setRole( Attendee::Role r )
00115 {
00116   mRole = r;
00117 }
00118 
00119 Attendee::Role Attendee::role() const
00120 {
00121   return mRole;
00122 }
00123 
00124 QString Attendee::roleStr() const
00125 {
00126   return roleName( mRole );
00127 }
00128 
00129 void Attendee::setUid( const QString &uid )
00130 {
00131   mUid = uid;
00132 }
00133 
00134 QString Attendee::uid() const
00135 {
00136   return mUid;
00137 }
00138 
00139 QString Attendee::roleName( Attendee::Role r )
00140 {
00141   switch ( r ) {
00142     case Chair:
00143       return i18n("Chair");
00144       break;
00145     default:
00146     case ReqParticipant:
00147       return i18n("Participant");
00148       break;
00149     case OptParticipant:
00150       return i18n("Optional Participant");
00151       break;
00152     case NonParticipant:
00153       return i18n("Observer");
00154       break;
00155   }
00156 }
00157 
00158 QStringList Attendee::roleList()
00159 {
00160   QStringList list;
00161   list << roleName( ReqParticipant );
00162   list << roleName( OptParticipant );
00163   list << roleName( NonParticipant );
00164   list << roleName( Chair );
00165 
00166   return list;
00167 }