incidencebase.h
00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 #ifndef KCAL_INCIDENCEBASE_H 00023 #define KCAL_INCIDENCEBASE_H 00024 00025 #include <tqdatetime.h> 00026 #include <tqstringlist.h> 00027 #include <tqvaluelist.h> 00028 #include <tqptrlist.h> 00029 00030 #include "customproperties.h" 00031 #include "attendee.h" 00032 00033 namespace KCal { 00034 00035 typedef TQValueList<TQDate> DateList; 00036 typedef TQValueList<TQDateTime> DateTimeList; 00037 class Event; 00038 class Todo; 00039 class Journal; 00040 class FreeBusy; 00041 00045 class LIBKCAL_EXPORT IncidenceBase : public CustomProperties 00046 { 00047 public: 00054 class Visitor 00055 { 00056 public: 00058 virtual ~Visitor() {} 00059 00064 virtual bool visit(Event *) { return false; } 00069 virtual bool visit(Todo *) { return false; } 00074 virtual bool visit(Journal *) { return false; } 00079 virtual bool visit(FreeBusy *) { return false; } 00080 00081 protected: 00083 Visitor() {} 00084 }; 00085 00086 class Observer { 00087 public: 00088 virtual ~Observer() {} 00089 virtual void incidenceUpdated( IncidenceBase * ) = 0; 00090 virtual void incidenceUpdatedSilent( IncidenceBase * ) {}; 00091 }; 00092 00093 IncidenceBase(); 00094 IncidenceBase( const IncidenceBase & ); 00095 virtual ~IncidenceBase(); 00096 00097 IncidenceBase& operator=( const IncidenceBase &i ); 00098 bool operator==( const IncidenceBase & ) const; 00099 00107 virtual bool accept(Visitor &) { return false; } 00108 00109 virtual TQCString type() const = 0; 00110 00112 void setUid( const TQString & ); 00114 TQString uid() const; 00115 00117 void setLastModified( const TQDateTime &lm ); 00119 TQDateTime lastModified() const; 00120 00122 void setOrganizer( const Person &o ); 00123 void setOrganizer( const TQString &o ); 00124 Person organizer() const; 00125 00127 virtual void setReadOnly( bool ); 00129 bool isReadOnly() const { return mReadOnly; } 00130 00132 virtual void setDtStart( const TQDateTime &dtStart ); 00135 virtual TQDateTime dtStart() const; 00136 00142 virtual KDE_DEPRECATED TQString dtStartTimeStr() const; 00143 00149 virtual KDE_DEPRECATED TQString dtStartDateStr( bool shortfmt = true ) const; 00155 virtual KDE_DEPRECATED TQString dtStartStr() const; 00156 00157 virtual void setDuration( int seconds ); 00158 int duration() const; 00159 void setHasDuration( bool ); 00160 bool hasDuration() const; 00161 00164 bool doesFloat() const; 00166 void setFloats( bool f ); 00167 00168 // 00169 // Comments 00170 // 00171 00179 void addComment(const TQString& comment); 00180 00189 bool removeComment( const TQString& comment ); 00190 00192 void clearComments(); 00193 00195 TQStringList comments() const; 00196 00204 void addAttendee( Attendee *attendee, bool doUpdate = true ); 00208 void clearAttendees(); 00212 const Attendee::List &attendees() const { return mAttendees; }; 00216 int attendeeCount() const { return mAttendees.count(); }; 00220 Attendee *attendeeByMail( const TQString & ) const; 00224 Attendee *attendeeByMails( const TQStringList &, 00225 const TQString &email = TQString() ) const; 00229 Attendee *attendeeByUid( const TQString &uid ) const; 00230 00234 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 00238 void setSyncStatus( int status ); 00239 void setSyncStatusSilent( int status ); 00243 int syncStatus() const; 00244 00248 void setPilotId( unsigned long id ); 00252 unsigned long pilotId() const; 00253 00258 void registerObserver( Observer * ); 00262 void unRegisterObserver( Observer * ); 00267 void updated(); 00268 void updatedSilent(); 00269 00270 protected: 00275 virtual void customPropertyUpdated(); 00276 00277 bool mReadOnly; 00278 00279 private: 00280 // base components 00281 TQDateTime mDtStart; 00282 Person mOrganizer; 00283 TQString mUid; 00284 TQDateTime mLastModified; 00285 Attendee::List mAttendees; 00286 TQStringList mComments; 00287 00288 bool mFloats; 00289 00290 int mDuration; 00291 bool mHasDuration; 00292 00293 // PILOT SYNCHRONIZATION STUFF 00294 unsigned long mPilotId; // unique id for pilot sync 00295 int mSyncStatus; // status (for sync) 00296 00297 TQPtrList<Observer> mObservers; 00298 00299 class Private; 00300 Private *d; 00301 }; 00302 00303 } 00304 00305 #endif