KCalCore Library
incidencebase.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the kcalcore library. 00003 00004 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org> 00005 Copyright (c) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net> 00007 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00008 Contact: Alvaro Manera <alvaro.manera@nokia.com> 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Library General Public 00012 License as published by the Free Software Foundation; either 00013 version 2 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public License 00021 along with this library; see the file COPYING.LIB. If not, write to 00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 Boston, MA 02110-1301, USA. 00024 */ 00056 #ifndef KCALCORE_INCIDENCEBASE_H 00057 #define KCALCORE_INCIDENCEBASE_H 00058 00059 #include "attendee.h" 00060 #include "customproperties.h" 00061 #include "duration.h" 00062 #include "sortablelist.h" 00063 00064 #include <KDE/KDateTime> 00065 00066 #include <QtCore/QSet> 00067 00068 class KUrl; 00069 class QDate; 00070 00071 namespace KCalCore { 00072 00074 typedef SortableList<QDate> DateList; 00075 00077 typedef SortableList<KDateTime> DateTimeList; 00078 00079 class Event; 00080 class Todo; 00081 class Journal; 00082 class FreeBusy; 00083 class Visitor; 00084 00107 class KCALCORE_EXPORT IncidenceBase : public CustomProperties 00108 { 00109 public: 00113 typedef QSharedPointer<IncidenceBase> Ptr; 00114 00119 enum IncidenceType { 00120 TypeEvent = 0, 00121 TypeTodo, 00122 TypeJournal, 00123 TypeFreeBusy, 00124 TypeUnknown 00125 }; 00126 00131 enum DateTimeRole { 00132 RoleAlarmStartOffset = 0, 00133 RoleAlarmEndOffset, 00134 RoleSort, 00135 RoleCalendarHashing, 00136 RoleStartTimeZone, 00137 RoleEndTimeZone, 00138 RoleEndRecurrenceBase, 00139 RoleEnd, 00141 RoleDisplayEnd, 00143 RoleAlarm, 00145 RoleRecurrenceStart 00150 }; 00151 00152 enum Field { 00153 FieldDtStart, 00154 FieldDtEnd, 00155 FieldLastModified, 00156 FieldDescription, 00157 FieldSummary, 00158 FieldLocation, 00159 FieldCompleted, 00160 FieldPercentComplete, 00161 FieldDtDue, 00162 FieldCategories, 00163 FieldRelatedTo, 00164 FieldRecurrence, 00165 FieldAttachment, 00166 FieldSecrecy, 00167 FieldStatus, 00168 FieldTransparency, 00169 FieldResources, 00170 FieldPriority, 00171 FieldGeoLatitude, 00172 FieldGeoLongitude, 00173 FieldRecurrenceId, 00174 FieldAlarms, 00175 FieldSchedulingId, 00176 FieldAttendees, 00177 FieldOrganizer, 00178 FieldCreated, 00179 FieldRevision, 00180 FieldDuration, 00181 FieldContact, 00182 FieldComment, 00183 FieldUid, 00184 FieldUnknown 00185 }; 00186 00190 class KCALCORE_EXPORT IncidenceObserver 00191 { 00192 public: 00193 00197 virtual ~IncidenceObserver(); 00198 00205 virtual void incidenceUpdate( const QString &uid, const KDateTime &recurrenceId ) = 0; 00206 00213 virtual void incidenceUpdated( const QString &uid, const KDateTime &recurrenceId ) = 0; 00214 }; 00215 00219 IncidenceBase(); 00220 00224 virtual ~IncidenceBase(); 00225 00243 IncidenceBase &operator=( const IncidenceBase &other ); 00244 00251 bool operator==( const IncidenceBase &ib ) const; 00252 00258 bool operator!=( const IncidenceBase &ib ) const; 00259 00270 virtual bool accept( Visitor &v, IncidenceBase::Ptr incidence ); 00271 00275 virtual IncidenceType type() const = 0; 00276 00280 virtual QByteArray typeStr() const = 0; 00281 00287 void setUid( const QString &uid ); 00288 00293 QString uid() const; 00294 00298 KUrl uri() const; 00299 00308 virtual void setLastModified( const KDateTime &lm ); 00309 00314 KDateTime lastModified() const; 00315 00322 void setOrganizer( const Person::Ptr &organizer ); 00323 00330 void setOrganizer( const QString &organizer ); 00331 00336 Person::Ptr organizer() const; 00337 00345 virtual void setReadOnly( bool readOnly ); 00346 00351 bool isReadOnly() const; 00352 00361 virtual void setDtStart( const KDateTime &dtStart ); 00362 00367 virtual KDateTime dtStart() const; 00368 00376 virtual void setDuration( const Duration &duration ); 00377 00382 Duration duration() const; 00383 00389 void setHasDuration( bool hasDuration ); 00390 00395 bool hasDuration() const; 00396 00402 bool allDay() const; 00403 00412 void setAllDay( bool allDay ); 00413 00428 virtual void shiftTimes( const KDateTime::Spec &oldSpec, 00429 const KDateTime::Spec &newSpec ); 00430 00438 void addComment( const QString &comment ); 00439 00448 bool removeComment( const QString &comment ); 00449 00453 void clearComments(); 00454 00458 QStringList comments() const; 00459 00467 void addContact( const QString &contact ); 00468 00477 bool removeContact( const QString &contact ); 00478 00482 void clearContacts(); 00483 00487 QStringList contacts() const; 00488 00496 void addAttendee( const Attendee::Ptr &attendee, 00497 bool doUpdate = true ); 00498 00502 void clearAttendees(); 00503 00512 void deleteAttendee( const Attendee::Ptr &attendee, 00513 bool doUpdate = true ); 00514 00519 Attendee::List attendees() const; 00520 00524 int attendeeCount() const; 00525 00533 Attendee::Ptr attendeeByMail( const QString &email ) const; 00534 00545 Attendee::Ptr attendeeByMails( const QStringList &emails, 00546 const QString &email = QString() ) const; 00547 00554 Attendee::Ptr attendeeByUid( const QString &uid ) const; 00555 00564 void registerObserver( IncidenceObserver *observer ); 00565 00573 void unRegisterObserver( IncidenceObserver *observer ); 00574 00579 void update(); 00580 00585 void updated(); 00586 00592 void startUpdates(); 00593 00599 void endUpdates(); 00600 00605 virtual KDateTime dateTime( DateTimeRole role ) const = 0; 00606 00612 virtual void setDateTime( const KDateTime &dateTime, DateTimeRole role ) = 0; 00613 00618 virtual QLatin1String mimeType() const = 0; 00619 00625 virtual KDateTime recurrenceId() const; 00626 00633 QSet<IncidenceBase::Field> dirtyFields() const; 00634 00639 void resetDirtyFields(); 00640 00641 protected: 00642 00647 void setFieldDirty( IncidenceBase::Field field ); 00648 00653 virtual void customPropertyUpdate(); 00654 00659 virtual void customPropertyUpdated(); 00660 00666 IncidenceBase( const IncidenceBase &ib ); 00667 00675 virtual bool equals( const IncidenceBase &incidenceBase ) const; 00676 00681 virtual IncidenceBase &assign( const IncidenceBase &other ); 00682 00690 virtual void virtual_hook( int id, void *data ) = 0; 00691 00695 bool mReadOnly; 00696 00697 private: 00698 //@cond PRIVATE 00699 class Private; 00700 Private *const d; 00701 //@endcond 00702 }; 00703 00704 } 00705 00706 #endif