00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KCAL_RESOURCECACHED_H
00022 #define KCAL_RESOURCECACHED_H
00023
00024 #include "resourcecalendar.h"
00025
00026 #include "libemailfunctions/idmapper.h"
00027 #include "incidence.h"
00028 #include "calendarlocal.h"
00029
00030 #include <tdeconfig.h>
00031
00032 #include <tqptrlist.h>
00033 #include <tqstring.h>
00034 #include <tqdatetime.h>
00035 #include <tqtimer.h>
00036
00037 #include <tdepimmacros.h>
00038
00039 namespace KCal {
00040
00045 class KDE_EXPORT ResourceCached : public ResourceCalendar,
00046 public KCal::Calendar::Observer
00047 {
00048 Q_OBJECT
00049
00050 public:
00056 enum { ReloadNever, ReloadOnStartup, ReloadInterval };
00062 enum { SaveNever, SaveOnExit, SaveInterval, SaveDelayed, SaveAlways };
00063
00064 ResourceCached( const TDEConfig * );
00065 virtual ~ResourceCached();
00066
00067 void readConfig( const TDEConfig *config );
00068 void writeConfig( TDEConfig *config );
00069
00070 static bool editorWindowOpen();
00071 static void setEditorWindowOpen(bool open);
00072
00080 void setReloadPolicy( int policy );
00086 int reloadPolicy() const;
00087
00092 void setReloadInterval( int minutes );
00093
00097 int reloadInterval() const;
00098
00108 void setSavePolicy( int policy );
00114 int savePolicy() const;
00115
00120 void setSaveInterval( int minutes );
00121
00125 int saveInterval() const;
00126
00130 TQDateTime lastLoad() const;
00131
00135 TQDateTime lastSave() const;
00136
00140 KDE_DEPRECATED bool addEvent( Event *event );
00141 bool addEvent( Event *event, const TQString &subresource );
00142
00146 bool deleteEvent(Event *);
00147
00151 Event *event(const TQString &UniqueStr);
00155 Event::List events();
00159 Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00164 Event::List rawEventsForDate( const TQDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00165
00169 Event::List rawEventsForDate( const TQDateTime &qdt );
00174 Event::List rawEvents( const TQDate &start, const TQDate &end,
00175 bool inclusive = false );
00176
00180 KDE_DEPRECATED bool addTodo( Todo *todo );
00181 bool addTodo( Todo *todo, const TQString &subresource );
00182
00186 bool deleteTodo( Todo * );
00191 Todo *todo( const TQString &uid );
00195 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00199 Todo::List rawTodosForDate( const TQDate &date );
00203 KDE_DEPRECATED bool addJournal( Journal *journal );
00204 bool addJournal( Journal *journal, const TQString &subresource );
00205
00209 bool deleteJournal( Journal * );
00213 Journal *journal( const TQString &uid );
00217 Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted,SortDirection sortDirection = SortDirectionAscending );
00221 Journal::List rawJournalsForDate( const TQDate &date );
00222
00226 Alarm::List alarms( const TQDateTime &from, const TQDateTime &to );
00227
00231 Alarm::List alarmsTo( const TQDateTime &to );
00232
00236 void setTimeZoneId( const TQString &timeZoneId );
00237
00238 TQString timeZoneId() const;
00239
00243 const Person &getOwner() const;
00247 void setOwner( const Person &owner );
00248
00249 void enableChangeNotification();
00250 void disableChangeNotification();
00251
00252 void clearChange( Incidence * );
00253 void clearChange( const TQString &uid );
00254
00255 void clearChanges();
00256
00257 bool hasChanges() const;
00258
00259 Incidence::List allChanges() const;
00260
00261 Incidence::List addedIncidences() const;
00262 Incidence::List changedIncidences() const;
00263 Incidence::List deletedIncidences() const;
00264
00268 void loadCache();
00269
00273 void saveCache();
00274
00278 void clearCache();
00279
00283 void clearEventsCache();
00284
00288 void clearTodosCache();
00289
00293 void clearJournalsCache();
00294
00295 void cleanUpEventCache( const KCal::Event::List &eventList );
00296 void cleanUpTodoCache( const KCal::Todo::List &todoList );
00297
00301 KPIM::IdMapper& idMapper();
00302
00303 protected:
00304
00305 void calendarIncidenceAdded( KCal::Incidence *incidence );
00306 void calendarIncidenceChanged( KCal::Incidence *incidence );
00307 void calendarIncidenceDeleted( KCal::Incidence *incidence );
00308
00309 CalendarLocal mCalendar;
00310
00315 virtual void doClose();
00320 virtual bool doOpen();
00324 bool checkForReload();
00328 bool checkForSave();
00329
00330 void checkForAutomaticSave();
00331
00332 void addInfoText( TQString & ) const;
00333
00334 void setupSaveTimer();
00335 void setupReloadTimer();
00336
00341 virtual TQString cacheFile() const;
00342
00346 virtual TQString changesCacheFile( const TQString& ) const;
00347 void loadChangesCache( TQMap<Incidence*, bool>&, const TQString& );
00348 void loadChangesCache();
00349 void saveChangesCache( const TQMap<Incidence*, bool>&, const TQString& );
00350 void saveChangesCache();
00351
00352 protected slots:
00353 void slotReload();
00354 void slotSave();
00355
00356 void setIdMapperIdentifier();
00357
00358 private:
00359 int mReloadPolicy;
00360 int mReloadInterval;
00361 TQTimer mReloadTimer;
00362 bool mReloaded;
00363
00364 int mSavePolicy;
00365 int mSaveInterval;
00366 TQTimer mSaveTimer;
00367
00368 TQDateTime mLastLoad;
00369 TQDateTime mLastSave;
00370
00371 TQMap<KCal::Incidence *,bool> mAddedIncidences;
00372 TQMap<KCal::Incidence *,bool> mChangedIncidences;
00373 TQMap<KCal::Incidence *,bool> mDeletedIncidences;
00374
00375 KPIM::IdMapper mIdMapper;
00376
00377 class Private;
00378 Private *d;
00379 };
00380
00381 }
00382
00383 #endif