libkcal
resourcecached.hGo to the documentation of this file.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 <kconfig.h>
00031
00032 #include <qptrlist.h>
00033 #include <qstring.h>
00034 #include <qdatetime.h>
00035 #include <qtimer.h>
00036
00037 #include <kdepimmacros.h>
00038
00039 namespace KCal {
00040
00045 class KDE_EXPORT ResourceCached : public ResourceCalendar,
00046 public KCal::Calendar::Observer
00047 {
00048 Q_OBJECT
00049 public:
00055 enum { ReloadNever, ReloadOnStartup, ReloadInterval };
00061 enum { SaveNever, SaveOnExit, SaveInterval, SaveDelayed, SaveAlways };
00062
00063 ResourceCached( const KConfig * );
00064 virtual ~ResourceCached();
00065
00066 void readConfig( const KConfig *config );
00067 void writeConfig( KConfig *config );
00068
00076 void setReloadPolicy( int policy );
00082 int reloadPolicy() const;
00083
00088 void setReloadInterval( int minutes );
00089
00093 int reloadInterval() const;
00094
00104 void setSavePolicy( int policy );
00110 int savePolicy() const;
00111
00116 void setSaveInterval( int minutes );
00117
00121 int saveInterval() const;
00122
00126 QDateTime lastLoad() const;
00127
00131 QDateTime lastSave() const;
00132
00136 bool addEvent(Event *anEvent);
00140 bool deleteEvent(Event *);
00141
00145 Event *event(const QString &UniqueStr);
00149 Event::List events();
00153 Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00158 Event::List rawEventsForDate( const QDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00159
00163 Event::List rawEventsForDate( const QDateTime &qdt );
00168 Event::List rawEvents( const QDate &start, const QDate &end,
00169 bool inclusive = false );
00170
00174 bool addTodo( Todo *todo );
00178 bool deleteTodo( Todo * );
00183 Todo *todo( const QString &uid );
00187 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
00191 Todo::List rawTodosForDate( const QDate &date );
00195 virtual bool addJournal( Journal * );
00199 virtual bool deleteJournal( Journal * );
00203 virtual Journal *journal( const QString &uid );
00207 Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted,SortDirection sortDirection = SortDirectionAscending );
00211 Journal::List rawJournalsForDate( const QDate &date );
00212
00216 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
00217
00221 Alarm::List alarmsTo( const QDateTime &to );
00222
00226 void setTimeZoneId( const QString &timeZoneId );
00227
00228 QString timeZoneId() const;
00229
00233 const Person &getOwner() const;
00237 void setOwner( const Person &owner );
00238
00239 void enableChangeNotification();
00240 void disableChangeNotification();
00241
00242 void clearChange( Incidence * );
00243 void clearChange( const QString &uid );
00244
00245 void clearChanges();
00246
00247 bool hasChanges() const;
00248
00249 Incidence::List allChanges() const;
00250
00251 Incidence::List addedIncidences() const;
00252 Incidence::List changedIncidences() const;
00253 Incidence::List deletedIncidences() const;
00254
00258 void loadCache();
00259
00263 void saveCache();
00264
00268 void clearCache();
00269
00270 void cleanUpEventCache( const KCal::Event::List &eventList );
00271 void cleanUpTodoCache( const KCal::Todo::List &todoList );
00272
00276 KPIM::IdMapper& idMapper();
00277
00278 protected:
00279
00280 void calendarIncidenceAdded( KCal::Incidence *incidence );
00281 void calendarIncidenceChanged( KCal::Incidence *incidence );
00282 void calendarIncidenceDeleted( KCal::Incidence *incidence );
00283
00284 CalendarLocal mCalendar;
00285
00290 virtual void doClose();
00295 virtual bool doOpen();
00299 bool checkForReload();
00303 bool checkForSave();
00304
00305 void checkForAutomaticSave();
00306
00307 void addInfoText( QString & ) const;
00308
00309 void setupSaveTimer();
00310 void setupReloadTimer();
00311
00316 virtual QString cacheFile() const;
00317
00321 virtual QString changesCacheFile( const QString& ) const;
00322 void loadChangesCache( QMap<Incidence*, bool>&, const QString& );
00323 void loadChangesCache();
00324 void saveChangesCache( const QMap<Incidence*, bool>&, const QString& );
00325 void saveChangesCache();
00326
00327 protected slots:
00328 void slotReload();
00329 void slotSave();
00330
00331 void setIdMapperIdentifier();
00332
00333 private:
00334 int mReloadPolicy;
00335 int mReloadInterval;
00336 QTimer mReloadTimer;
00337 bool mReloaded;
00338
00339 int mSavePolicy;
00340 int mSaveInterval;
00341 QTimer mSaveTimer;
00342
00343 QDateTime mLastLoad;
00344 QDateTime mLastSave;
00345
00346 QMap<KCal::Incidence *,bool> mAddedIncidences;
00347 QMap<KCal::Incidence *,bool> mChangedIncidences;
00348 QMap<KCal::Incidence *,bool> mDeletedIncidences;
00349
00350 KPIM::IdMapper mIdMapper;
00351
00352 class Private;
00353 Private *d;
00354 };
00355
00356 }
00357
00358 #endif
|