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 <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 }
00053 
00054 void Attendee::setStatus( Attendee::PartStat s )
00055 {
00056   mStatus = s;
00057 }
00058 
00059 Attendee::PartStat Attendee::status() const
00060 {
00061   return mStatus;
00062 }
00063 
00064 QString Attendee::statusStr() const
00065 {
00066   return statusName( mStatus );
00067 }
00068 
00069 QString Attendee::statusName( Attendee::PartStat s )
00070 {
00071   switch ( s ) {
00072     default:
00073     case NeedsAction:
00074       return i18n("Needs Action");
00075       break;
00076     case Accepted:
00077       return i18n("Accepted");
00078       break;
00079     case Declined:
00080       return i18n("Declined");
00081       break;
00082     case Tentative:
00083       return i18n("attendee status", "Tentative");
00084       break;
00085     case Delegated:
00086       return i18n("Delegated");
00087       break;
00088     case Completed:
00089       return i18n("Completed");
00090       break;
00091     case InProcess:
00092       return i18n("In Process");
00093       break;
00094   }
00095 }
00096 
00097 QStringList Attendee::statusList()
00098 {
00099   QStringList list;
00100   list << statusName( NeedsAction );
00101   list << statusName( Accepted );
00102   list << statusName( Declined );
00103   list << statusName( Tentative );
00104   list << statusName( Delegated );
00105   list << statusName( Completed );
00106   list << statusName( InProcess );
00107 
00108   return list;
00109 }
00110 
00111 
00112 void Attendee::setRole( Attendee::Role r )
00113 {
00114   mRole = r;
00115 }
00116 
00117 Attendee::Role Attendee::role() const
00118 {
00119   return mRole;
00120 }
00121 
00122 QString Attendee::roleStr() const
00123 {
00124   return roleName( mRole );
00125 }
00126 
00127 void Attendee::setUid( const QString &uid )
00128 {
00129   mUid = uid;
00130 }
00131 
00132 QString Attendee::uid() const
00133 {
00134   return mUid;
00135 }
00136 
00137 QString Attendee::roleName( Attendee::Role r )
00138 {
00139   switch ( r ) {
00140     case Chair:
00141       return i18n("Chair");
00142       break;
00143     default:
00144     case ReqParticipant:
00145       return i18n("Participant");
00146       break;
00147     case OptParticipant:
00148       return i18n("Optional Participant");
00149       break;
00150     case NonParticipant:
00151       return i18n("Observer");
00152       break;
00153   }
00154 }
00155 
00156 QStringList Attendee::roleList()
00157 {
00158   QStringList list;
00159   list << roleName( ReqParticipant );
00160   list << roleName( OptParticipant );
00161   list << roleName( NonParticipant );
00162   list << roleName( Chair );
00163 
00164   return list;
00165 }
KDE Home | KDE Accessibility Home | Description of Access Keys