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 QString &o ); 00067 QString organizer() const; 00068 00070 virtual void setReadOnly( bool ); 00072 bool isReadOnly() const { return mReadOnly; } 00073 00075 virtual void setDtStart( const QDateTime &dtStart ); 00077 QDateTime dtStart() const; 00080 QString dtStartTimeStr() const; 00083 QString dtStartDateStr( bool shortfmt = true ) const; 00086 QString dtStartStr() const; 00087 00088 virtual void setDuration( int seconds ); 00089 int duration() const; 00090 void setHasDuration( bool ); 00091 bool hasDuration() const; 00092 00095 bool doesFloat() const; 00097 void setFloats( bool f ); 00098 00105 void addAttendee( Attendee *a, bool doUpdate = true ); 00109 void clearAttendees(); 00113 const Attendee::List &attendees() const { return mAttendees; }; 00117 int attendeeCount() const { return mAttendees.count(); }; 00121 Attendee *attendeeByMail( const QString & ); 00125 Attendee *attendeeByMails( const QStringList &, 00126 const QString &email = QString::null ); 00127 00131 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 00135 void setSyncStatus( int status ); 00139 int syncStatus() const; 00140 00144 void setPilotId( int id ); 00148 int pilotId() const; 00149 00154 void registerObserver( Observer * ); 00158 void unRegisterObserver( Observer * ); 00163 void updated(); 00164 00165 protected: 00166 bool mReadOnly; 00167 00168 private: 00169 // base components 00170 QDateTime mDtStart; 00171 QString mOrganizer; 00172 QString mUid; 00173 QDateTime mLastModified; 00174 Attendee::List mAttendees; 00175 00176 bool mFloats; 00177 00178 int mDuration; 00179 bool mHasDuration; 00180 00181 // PILOT SYNCHRONIZATION STUFF 00182 int mPilotId; // unique id for pilot sync 00183 int mSyncStatus; // status (for sync) 00184 00185 QPtrList<Observer> mObservers; 00186 00187 class Private; 00188 Private *d; 00189 }; 00190 00191 } 00192 00193 #endif