libkcal
incidencebase.h
Go to the documentation of this file.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 <qdatetime.h> 00026 #include <qstringlist.h> 00027 #include <qvaluelist.h> 00028 #include <qptrlist.h> 00029 00030 #include "customproperties.h" 00031 #include "attendee.h" 00032 00033 namespace KCal { 00034 00035 typedef QValueList<QDate> DateList; 00036 typedef QValueList<QDateTime> 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 QCString type() const = 0; 00110 00112 void setUid( const QString & ); 00114 QString uid() const; 00115 00117 void setLastModified( const QDateTime &lm ); 00119 QDateTime lastModified() const; 00120 00122 void setOrganizer( const Person &o ); 00123 void setOrganizer( const QString &o ); 00124 Person organizer() const; 00125 00127 virtual void setReadOnly( bool ); 00129 bool isReadOnly() const { return mReadOnly; } 00130 00132 virtual void setDtStart( const QDateTime &dtStart ); 00134 virtual QDateTime dtStart() const; 00137 virtual QString dtStartTimeStr() const; 00140 virtual QString dtStartDateStr( bool shortfmt = true ) const; 00143 virtual QString dtStartStr() const; 00144 00145 virtual void setDuration( int seconds ); 00146 int duration() const; 00147 void setHasDuration( bool ); 00148 bool hasDuration() const; 00149 00152 bool doesFloat() const; 00154 void setFloats( bool f ); 00155 00156 // 00157 // Comments 00158 // 00159 00167 void addComment(const QString& comment); 00168 00177 bool removeComment( const QString& comment ); 00178 00180 void clearComments(); 00181 00183 QStringList comments() const; 00184 00192 void addAttendee( Attendee *attendee, bool doUpdate = true ); 00196 void clearAttendees(); 00200 const Attendee::List &attendees() const { return mAttendees; }; 00204 int attendeeCount() const { return mAttendees.count(); }; 00208 Attendee *attendeeByMail( const QString & ) const; 00212 Attendee *attendeeByMails( const QStringList &, 00213 const QString &email = QString::null ) const; 00217 Attendee *attendeeByUid( const QString &uid ) const; 00218 00222 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 00226 void setSyncStatus( int status ); 00227 void setSyncStatusSilent( int status ); 00231 int syncStatus() const; 00232 00236 void setPilotId( unsigned long id ); 00240 unsigned long pilotId() const; 00241 00246 void registerObserver( Observer * ); 00250 void unRegisterObserver( Observer * ); 00255 void updated(); 00256 void updatedSilent(); 00257 00258 protected: 00263 virtual void customPropertyUpdated(); 00264 00265 bool mReadOnly; 00266 00267 private: 00268 // base components 00269 QDateTime mDtStart; 00270 Person mOrganizer; 00271 QString mUid; 00272 QDateTime mLastModified; 00273 Attendee::List mAttendees; 00274 QStringList mComments; 00275 00276 bool mFloats; 00277 00278 int mDuration; 00279 bool mHasDuration; 00280 00281 // PILOT SYNCHRONIZATION STUFF 00282 unsigned long mPilotId; // unique id for pilot sync 00283 int mSyncStatus; // status (for sync) 00284 00285 QPtrList<Observer> mObservers; 00286 00287 class Private; 00288 Private *d; 00289 }; 00290 00291 } 00292 00293 #endif