libkcal

attendee.cpp

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 <tqstringlist.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 TQString &name, const TQString &email, bool _rsvp,
00032                     Attendee::PartStat s, Attendee::Role r, const TQString &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 TQString Attendee::statusStr() const
00067 {
00068   return statusName( mStatus );
00069 }
00070 
00071 TQString 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     case None:
00097       return i18n("attendee status unknown", "Unknown");
00098       break;
00099   }
00100 }
00101 
00102 TQStringList Attendee::statusList()
00103 {
00104   TQStringList list;
00105   list << statusName( NeedsAction );
00106   list << statusName( Accepted );
00107   list << statusName( Declined );
00108   list << statusName( Tentative );
00109   list << statusName( Delegated );
00110   list << statusName( Completed );
00111   list << statusName( InProcess );
00112 
00113   return list;
00114 }
00115 
00116 
00117 void Attendee::setRole( Attendee::Role r )
00118 {
00119   mRole = r;
00120 }
00121 
00122 Attendee::Role Attendee::role() const
00123 {
00124   return mRole;
00125 }
00126 
00127 TQString Attendee::roleStr() const
00128 {
00129   return roleName( mRole );
00130 }
00131 
00132 void Attendee::setUid( const TQString &uid )
00133 {
00134   mUid = uid;
00135 }
00136 
00137 TQString Attendee::uid() const
00138 {
00139   return mUid;
00140 }
00141 
00142 TQString Attendee::roleName( Attendee::Role r )
00143 {
00144   switch ( r ) {
00145     case Chair:
00146       return i18n("Chair");
00147       break;
00148     default:
00149     case ReqParticipant:
00150       return i18n("Participant");
00151       break;
00152     case OptParticipant:
00153       return i18n("Optional Participant");
00154       break;
00155     case NonParticipant:
00156       return i18n("Observer");
00157       break;
00158   }
00159 }
00160 
00161 TQStringList Attendee::roleList()
00162 {
00163   TQStringList list;
00164   list << roleName( ReqParticipant );
00165   list << roleName( OptParticipant );
00166   list << roleName( NonParticipant );
00167   list << roleName( Chair );
00168 
00169   return list;
00170 }