00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00031 #ifndef KCAL_CALENDAR_H
00032 #define KCAL_CALENDAR_H
00033
00034 #include <qobject.h>
00035 #include <qstring.h>
00036 #include <qdatetime.h>
00037 #include <qptrlist.h>
00038 #include <qdict.h>
00039 #include <kdepimmacros.h>
00040
00041 #include "customproperties.h"
00042 #include "event.h"
00043 #include "todo.h"
00044 #include "journal.h"
00045 #include "kcalversion.h"
00046 #include "person.h"
00047
00052 namespace KCal {
00053
00054 class CalFilter;
00055
00060 enum SortDirection
00061 {
00063 SortDirectionAscending,
00065 SortDirectionDescending
00066 };
00067
00072 enum EventSortField
00073 {
00075 EventSortUnsorted,
00077 EventSortStartDate,
00079 EventSortEndDate,
00081 EventSortSummary
00082 };
00083
00088 enum TodoSortField
00089 {
00091 TodoSortUnsorted,
00093 TodoSortStartDate,
00095 TodoSortDueDate,
00097 TodoSortPriority,
00099 TodoSortPercentComplete,
00101 TodoSortSummary
00102 };
00103
00108 enum JournalSortField
00109 {
00111 JournalSortUnsorted,
00113 JournalSortDate,
00115 JournalSortSummary
00116 };
00117
00167 class LIBKCAL_EXPORT Calendar : public QObject, public CustomProperties,
00168 public IncidenceBase::Observer
00169 {
00170 Q_OBJECT
00171
00172 public:
00173
00188 Calendar( const QString &timeZoneId );
00189
00193 virtual ~Calendar();
00194
00200 void setProductId( const QString &productId );
00201
00207 QString productId();
00208
00214 void setOwner( const Person &owner );
00215
00221 const Person &getOwner() const;
00222
00237 void setTimeZoneId( const QString &timeZoneId );
00238
00245 virtual void setTimeZoneIdViewOnly( const QString &timeZoneId ) = 0;
00246
00252 QString timeZoneId() const;
00253
00257 void setLocalTime();
00258
00265 bool isLocalTime() const;
00266
00273 void setModified( bool modified );
00274
00280 bool isModified() const { return mModified; }
00281
00285 virtual void close() = 0;
00286
00290 virtual void save() = 0;
00291
00297 virtual bool reload( const QString &tz ) = 0;
00298
00304 virtual bool isSaving() { return false; }
00305
00311 QStringList categories();
00312
00313
00314
00322 virtual bool addIncidence( Incidence *incidence );
00323
00331 virtual bool deleteIncidence( Incidence *incidence );
00332
00338 virtual Incidence::List incidences();
00339
00347 virtual Incidence::List incidences( const QDate &date );
00348
00354 virtual Incidence::List rawIncidences();
00355
00364 Incidence *incidence( const QString &uid );
00365
00374 Incidence *incidenceFromSchedulingID( const QString &sid );
00375
00380 Incidence::List incidencesFromSchedulingID( const QString &UID );
00381
00391 static Incidence::List mergeIncidenceList( const Event::List &events,
00392 const Todo::List &todos,
00393 const Journal::List &journals );
00394
00400 virtual bool beginChange( Incidence *incidence );
00401
00407 virtual bool endChange( Incidence *incidence );
00408
00425 Incidence *dissociateOccurrence( Incidence *incidence, QDate date,
00426 bool single = true );
00427
00428
00429
00437 virtual bool addEvent( Event *event ) = 0;
00438
00446 virtual bool deleteEvent( Event *event ) = 0;
00447
00457 static Event::List sortEvents( Event::List *eventList,
00458 EventSortField sortField,
00459 SortDirection sortDirection );
00468 virtual Event::List events(
00469 EventSortField sortField = EventSortUnsorted,
00470 SortDirection sortDirection = SortDirectionAscending );
00471
00479 Event::List events( const QDateTime &qdt );
00480
00492 Event::List events( const QDate &start, const QDate &end,
00493 bool inclusive = false);
00494
00506 Event::List events(
00507 const QDate &date,
00508 EventSortField sortField = EventSortUnsorted,
00509 SortDirection sortDirection = SortDirectionAscending );
00510
00519 virtual Event::List rawEvents(
00520 EventSortField sortField = EventSortUnsorted,
00521 SortDirection sortDirection = SortDirectionAscending ) = 0;
00522
00532 virtual Event::List rawEventsForDate( const QDateTime &qdt ) = 0;
00533
00545 virtual Event::List rawEvents( const QDate &start, const QDate &end,
00546 bool inclusive = false ) = 0;
00547
00559 virtual Event::List rawEventsForDate(
00560 const QDate &date,
00561 EventSortField sortField = EventSortUnsorted,
00562 SortDirection sortDirection = SortDirectionAscending ) = 0;
00563
00572 virtual Event *event( const QString &uid ) = 0;
00573
00574
00575
00583 virtual bool addTodo( Todo *todo ) = 0;
00584
00592 virtual bool deleteTodo( Todo *todo ) = 0;
00593
00603 static Todo::List sortTodos( Todo::List *todoList,
00604 TodoSortField sortField,
00605 SortDirection sortDirection );
00606
00615 virtual Todo::List todos(
00616 TodoSortField sortField = TodoSortUnsorted,
00617 SortDirection sortDirection = SortDirectionAscending );
00618
00626 virtual Todo::List todos( const QDate &date );
00627
00636 virtual Todo::List rawTodos(
00637 TodoSortField sortField = TodoSortUnsorted,
00638 SortDirection sortDirection = SortDirectionAscending ) = 0;
00639
00647 virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00648
00657 virtual Todo *todo( const QString &uid ) = 0;
00658
00659
00660
00668 virtual bool addJournal( Journal *journal ) = 0;
00669
00677 virtual bool deleteJournal( Journal *journal ) = 0;
00678
00688 static Journal::List sortJournals( Journal::List *journalList,
00689 JournalSortField sortField,
00690 SortDirection sortDirection );
00699 virtual Journal::List journals(
00700 JournalSortField sortField = JournalSortUnsorted,
00701 SortDirection sortDirection = SortDirectionAscending );
00702
00710 virtual Journal::List journals( const QDate &date );
00711
00720 virtual Journal::List rawJournals(
00721 JournalSortField sortField = JournalSortUnsorted,
00722 SortDirection sortDirection = SortDirectionAscending ) = 0;
00723
00731 virtual Journal::List rawJournalsForDate( const QDate &date ) = 0;
00732
00741 virtual Journal *journal( const QString &uid ) = 0;
00742
00743
00744
00751 virtual void setupRelations( Incidence *incidence );
00752
00759 virtual void removeRelations( Incidence *incidence );
00760
00761
00762
00769 void setFilter( CalFilter *filter );
00770
00777 CalFilter *filter();
00778
00779
00780
00789 virtual Alarm::List alarms( const QDateTime &from,
00790 const QDateTime &to ) = 0;
00791
00792
00793
00799 class Observer
00800 {
00801 public:
00802 virtual ~Observer() {}
00810 virtual void calendarModified( bool ,
00811 Calendar * ) {};
00812
00818 virtual void calendarIncidenceAdded( Incidence * ) {}
00819
00825 virtual void calendarIncidenceChanged( Incidence * ) {}
00826
00832 virtual void calendarIncidenceDeleted( Incidence * ) {}
00833 };
00834
00841 void registerObserver( Observer *observer );
00842
00849 void unregisterObserver( Observer *observer );
00850
00851 signals:
00855 void calendarChanged();
00856
00860 void calendarSaved();
00861
00865 void calendarLoaded();
00866
00867 protected:
00873 void incidenceUpdated( IncidenceBase *incidenceBase );
00874
00887 virtual void doSetTimeZoneId( const QString & ) {}
00888
00894 void notifyIncidenceAdded( Incidence *incidence );
00895
00901 void notifyIncidenceChanged( Incidence *incidence );
00902
00908 void notifyIncidenceDeleted( Incidence *incidence );
00909
00914 virtual void customPropertyUpdated();
00915
00922 void setObserversEnabled( bool enabled );
00923
00924
00925
00926
00927
00928 private:
00932 void init();
00933
00934 QString mProductId;
00935 Person mOwner;
00936 QString mTimeZoneId;
00937 bool mLocalTime;
00938
00939 bool mModified;
00940
00941 CalFilter *mFilter;
00942 CalFilter *mDefaultFilter;
00943
00944 QPtrList<Observer> mObservers;
00945 bool mNewObserver;
00946 bool mObserversEnabled;
00947
00948
00949 QDict<Incidence> mOrphans;
00950 QDict<Incidence> mOrphanUids;
00951
00952 class Private;
00953 Private *d;
00954 };
00955
00956 }
00957
00958 #endif