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:
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     };
00091 
00092     IncidenceBase();
00093     IncidenceBase( const IncidenceBase & );
00094     virtual ~IncidenceBase();
00095 
00096     bool operator==( const IncidenceBase & ) const;
00097 
00105     virtual bool accept(Visitor &) { return false; }
00106 
00107     virtual QCString type() const = 0;
00108 
00110     void setUid( const QString & );
00112     QString uid() const;
00113 
00115     void setLastModified( const QDateTime &lm );
00117     QDateTime lastModified() const;
00118 
00120     void setOrganizer( const Person &o );
00121     void setOrganizer( const QString &o );
00122     Person organizer() const;
00123 
00125     virtual void setReadOnly( bool );
00127     bool isReadOnly() const { return mReadOnly; }
00128 
00130     virtual void setDtStart( const QDateTime &dtStart );
00132     virtual QDateTime dtStart() const;
00135     virtual QString dtStartTimeStr() const;
00138     virtual QString dtStartDateStr( bool shortfmt = true ) const;
00141     virtual QString dtStartStr() const;
00142 
00143     virtual void setDuration( int seconds );
00144     int duration() const;
00145     void setHasDuration( bool );
00146     bool hasDuration() const;
00147 
00150     bool doesFloat() const;
00152     void setFloats( bool f );
00153 
00154     //
00155     // Comments
00156     //
00157 
00165     void addComment(const QString& comment);
00166 
00175     bool removeComment( const QString& comment );
00176 
00178     void clearComments();
00179 
00181     QStringList comments() const;
00182 
00190     void addAttendee( Attendee *attendee, bool doUpdate = true );
00194     void clearAttendees();
00198     const Attendee::List &attendees() const { return mAttendees; };
00202     int attendeeCount() const { return mAttendees.count(); };
00206     Attendee *attendeeByMail( const QString & ) const;
00210     Attendee *attendeeByMails( const QStringList &,
00211                                const QString &email = QString::null ) const;
00215     Attendee *attendeeByUid( const QString &uid ) const;
00216 
00220     enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
00224     void setSyncStatus( int status );
00228     int syncStatus() const;
00229 
00233     void setPilotId( unsigned long id );
00237     unsigned long pilotId() const;
00238 
00243     void registerObserver( Observer * );
00247     void unRegisterObserver( Observer * );
00252     void updated();
00253 
00254   protected:
00259     virtual void customPropertyUpdated();
00260 
00261     bool mReadOnly;
00262 
00263   private:
00264     // base components
00265     QDateTime mDtStart;
00266     Person mOrganizer;
00267     QString mUid;
00268     QDateTime mLastModified;
00269     Attendee::List mAttendees;
00270     QStringList mComments;
00271 
00272     bool mFloats;
00273 
00274     int mDuration;
00275     bool mHasDuration;
00276 
00277     // PILOT SYNCHRONIZATION STUFF
00278     unsigned long mPilotId;                         // unique id for pilot sync
00279     int mSyncStatus;                      // status (for sync)
00280 
00281     QPtrList<Observer> mObservers;
00282 
00283     class Private;
00284     Private *d;
00285 };
00286 
00287 }
00288 
00289 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys