incidencebase.h
00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2001-2003 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., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 */ 00021 #ifndef KCAL_INCIDENCEBASE_H 00022 #define KCAL_INCIDENCEBASE_H 00023 00024 #include <qdatetime.h> 00025 #include <qstringlist.h> 00026 #include <qvaluelist.h> 00027 #include <qptrlist.h> 00028 00029 #include "customproperties.h" 00030 #include "attendee.h" 00031 00032 namespace KCal { 00033 00034 typedef QValueList<QDate> DateList; 00035 typedef QValueList<QDateTime> DateTimeList; 00036 00040 class IncidenceBase : public CustomProperties 00041 { 00042 public: 00043 class Observer { 00044 public: 00045 virtual void incidenceUpdated( IncidenceBase * ) = 0; 00046 }; 00047 00048 IncidenceBase(); 00049 IncidenceBase( const IncidenceBase & ); 00050 virtual ~IncidenceBase(); 00051 bool operator==( const IncidenceBase & ) const; 00052 00053 virtual QCString type() const = 0; 00054 00056 void setUid( const QString & ); 00058 QString uid() const; 00059 00061 void setLastModified( const QDateTime &lm ); 00063 QDateTime lastModified() const; 00064 00066 void setOrganizer( const Person &o ); 00067 void setOrganizer( const QString &o ); 00068 Person organizer() const; 00069 00071 virtual void setReadOnly( bool ); 00073 bool isReadOnly() const { return mReadOnly; } 00074 00076 virtual void setDtStart( const QDateTime &dtStart ); 00078 virtual QDateTime dtStart() const; 00081 virtual QString dtStartTimeStr() const; 00084 virtual QString dtStartDateStr( bool shortfmt = true ) const; 00087 virtual QString dtStartStr() const; 00088 00089 virtual void setDuration( int seconds ); 00090 int duration() const; 00091 void setHasDuration( bool ); 00092 bool hasDuration() const; 00093 00096 bool doesFloat() const; 00098 void setFloats( bool f ); 00099 00100 // 00101 // Comments 00102 // 00103 00111 void addComment(const QString& comment); 00112 00121 bool removeComment(QString& comment); 00122 00124 void clearComments(); 00125 00127 QStringList comments() const; 00128 00135 void addAttendee( Attendee *a, bool doUpdate = true ); 00139 void clearAttendees(); 00143 const Attendee::List &attendees() const { return mAttendees; }; 00147 int attendeeCount() const { return mAttendees.count(); }; 00151 Attendee *attendeeByMail( const QString & ) const; 00155 Attendee *attendeeByMails( const QStringList &, 00156 const QString &email = QString::null ) const; 00160 Attendee *attendeeByUid( const QString &uid ) const; 00161 00165 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 00169 void setSyncStatus( int status ); 00173 int syncStatus() const; 00174 00178 void setPilotId( unsigned long id ); 00182 unsigned long pilotId() const; 00183 00188 void registerObserver( Observer * ); 00192 void unRegisterObserver( Observer * ); 00197 void updated(); 00198 00199 protected: 00200 bool mReadOnly; 00201 00202 private: 00203 // base components 00204 QDateTime mDtStart; 00205 Person mOrganizer; 00206 QString mUid; 00207 QDateTime mLastModified; 00208 Attendee::List mAttendees; 00209 QStringList mComments; 00210 00211 bool mFloats; 00212 00213 int mDuration; 00214 bool mHasDuration; 00215 00216 // PILOT SYNCHRONIZATION STUFF 00217 unsigned long mPilotId; // unique id for pilot sync 00218 int mSyncStatus; // status (for sync) 00219 00220 QPtrList<Observer> mObservers; 00221 00222 class Private; 00223 Private *d; 00224 }; 00225 00226 } 00227 00228 #endif
