libkcal

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 <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:
00048     // Only FieldPercentComplete and FieldAttendees are currently set.
00049     // The rest of this feature will be implemented when it's needed.
00050     enum Field {
00051       FieldDtStart,         
00052       FieldDtEnd,           
00053       FieldLastModified,    
00054       FieldDescription,     
00055       FieldSummary,         
00056       FieldLocation,        
00057       FieldCompleted,       
00058       FieldPercentComplete, 
00059       FieldDtDue,           
00060       FieldCategories,      
00061       FieldRelatedTo,       
00062       FieldRecurrence,      
00063       FieldAttachment,      
00064       FieldSecrecy,         
00065       FieldStatus,          
00066       FieldTransparency,    
00067       FieldResources,       
00068       FieldPriority,        
00069       FieldGeoLatitude,     
00070       FieldGeoLongitude,    
00071       FieldRecurrenceId,    
00072       FieldAlarms,          
00073       FieldSchedulingId,    
00074       FieldAttendees,       
00075       FieldOrganizer,       
00076       FieldCreated,         
00077       FieldRevision,        
00078       FieldDuration,        
00079       FieldContact,         
00080       FieldComment,         
00081       FieldUid,             
00082       FieldUnknown          
00083     };
00084 
00091     class Visitor
00092     {
00093       public:
00095         virtual ~Visitor() {}
00096 
00101         virtual bool visit(Event *) { return false; }
00106         virtual bool visit(Todo *) { return false; }
00111         virtual bool visit(Journal *) { return false; }
00116         virtual bool visit(FreeBusy *) { return false; }
00117 
00118       protected:
00120         Visitor() {}
00121     };
00122 
00123     class Observer {
00124       public:
00125         virtual ~Observer() {}
00126         virtual void incidenceUpdated( IncidenceBase * ) = 0;
00127         virtual void incidenceUpdatedSilent( IncidenceBase * ) {};
00128     };
00129 
00130     IncidenceBase();
00131     IncidenceBase( const IncidenceBase & );
00132     virtual ~IncidenceBase();
00133 
00134     IncidenceBase& operator=( const IncidenceBase &i );
00135     bool operator==( const IncidenceBase & ) const;
00136 
00144     virtual bool accept(Visitor &) { return false; }
00145 
00146     virtual QCString type() const = 0;
00147 
00149     void setUid( const QString & );
00151     QString uid() const;
00152 
00154     void setLastModified( const QDateTime &lm );
00156     QDateTime lastModified() const;
00157 
00159     void setOrganizer( const Person &o );
00160     void setOrganizer( const QString &o );
00161     Person organizer() const;
00162 
00164     virtual void setReadOnly( bool );
00166     bool isReadOnly() const { return mReadOnly; }
00167 
00169     virtual void setDtStart( const QDateTime &dtStart );
00172     virtual QDateTime dtStart() const;
00173 
00179     virtual KDE_DEPRECATED QString dtStartTimeStr() const;
00180 
00186     virtual KDE_DEPRECATED QString dtStartDateStr( bool shortfmt = true ) const;
00192     virtual KDE_DEPRECATED QString dtStartStr() const;
00193 
00194     virtual void setDuration( int seconds );
00195     int duration() const;
00196     void setHasDuration( bool );
00197     bool hasDuration() const;
00198 
00201     bool doesFloat() const;
00203     void setFloats( bool f );
00204 
00205     //
00206     // Comments
00207     //
00208 
00216     void addComment(const QString& comment);
00217 
00226     bool removeComment( const QString& comment );
00227 
00229     void clearComments();
00230 
00232     QStringList comments() const;
00233 
00241     void addAttendee( Attendee *attendee, bool doUpdate = true );
00245     void clearAttendees();
00249     const Attendee::List &attendees() const { return mAttendees; };
00253     int attendeeCount() const { return mAttendees.count(); };
00257     Attendee *attendeeByMail( const QString & ) const;
00261     Attendee *attendeeByMails( const QStringList &,
00262                                const QString &email = QString::null ) const;
00266     Attendee *attendeeByUid( const QString &uid ) const;
00267 
00271     enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
00275     void setSyncStatus( int status );
00276     void setSyncStatusSilent( int status );
00280     int syncStatus() const;
00281 
00285     void setPilotId( unsigned long id );
00289     unsigned long pilotId() const;
00290 
00295     void registerObserver( Observer * );
00299     void unRegisterObserver( Observer * );
00304     void updated();
00305     void updatedSilent();
00306 
00307     // For debugging/Testing purposes.
00308     QPtrList<Observer> observers() const;
00309 
00319     QMap<IncidenceBase::Field,bool> dirtyFields() const;
00320 
00325     void resetDirtyFields();
00326 
00333     void setFieldDirty( IncidenceBase::Field field );
00334   protected:
00339     virtual void customPropertyUpdated();
00340 
00341     bool mReadOnly;
00342 
00343   private:
00344     // base components
00345     QMap<Field, bool> mDirtyFields; // Fields that changed since last time the incidence was created
00346                                     // or since resetDirtyFlags() was called. Ignore the value, I just wanted a QSet.
00347     QDateTime mDtStart;
00348     Person mOrganizer;
00349     QString mUid;
00350     QDateTime mLastModified;
00351     Attendee::List mAttendees;
00352     QStringList mComments;
00353 
00354     bool mFloats;
00355 
00356     int mDuration;
00357     bool mHasDuration;
00358 
00359     // PILOT SYNCHRONIZATION STUFF
00360     unsigned long mPilotId;                         // unique id for pilot sync
00361     int mSyncStatus;                      // status (for sync)
00362 
00363     QPtrList<Observer> mObservers;
00364 
00365     class Private;
00366     Private *d;
00367 };
00368 
00369 }
00370 
00371 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys