libkcal

resourcecached.h
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef KCAL_RESOURCECACHED_H
22#define KCAL_RESOURCECACHED_H
23
24#include "resourcecalendar.h"
25
26#include "libemailfunctions/idmapper.h"
27#include "incidence.h"
28#include "calendarlocal.h"
29
30#include <tdeconfig.h>
31
32#include <tqptrlist.h>
33#include <tqstring.h>
34#include <tqdatetime.h>
35#include <tqtimer.h>
36
37#include <tdemacros.h>
38
39namespace KCal {
40
45class TDE_EXPORT ResourceCached : public ResourceCalendar,
47{
48 TQ_OBJECT
49
50 public:
56 enum { ReloadNever, ReloadOnStartup, ReloadInterval };
62 enum { SaveNever, SaveOnExit, SaveInterval, SaveDelayed, SaveAlways };
63
64 ResourceCached( const TDEConfig * );
65 virtual ~ResourceCached();
66
67 void readConfig( const TDEConfig *config );
68 void writeConfig( TDEConfig *config );
69
70 static bool editorWindowOpen();
71 static void setEditorWindowOpen(bool open);
72
80 void setReloadPolicy( int policy );
86 int reloadPolicy() const;
87
92 void setReloadInterval( int minutes );
93
97 int reloadInterval() const;
98
108 void setSavePolicy( int policy );
114 int savePolicy() const;
115
120 void setSaveInterval( int minutes );
121
125 int saveInterval() const;
126
130 TQDateTime lastLoad() const;
131
135 TQDateTime lastSave() const;
136
140 TDE_DEPRECATED bool addEvent( Event *event );
141 bool addEvent( Event *event, const TQString &subresource );
142
146 bool deleteEvent(Event *);
147
151 Event *event(const TQString &UniqueStr);
159 Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
164 Event::List rawEventsForDate( const TQDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
165
169 Event::List rawEventsForDate( const TQDateTime &qdt );
174 Event::List rawEvents( const TQDate &start, const TQDate &end,
175 bool inclusive = false );
176
180 TDE_DEPRECATED bool addTodo( Todo *todo );
181 bool addTodo( Todo *todo, const TQString &subresource );
182
186 bool deleteTodo( Todo * );
191 Todo *todo( const TQString &uid );
195 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending );
199 Todo::List rawTodosForDate( const TQDate &date );
203 TDE_DEPRECATED bool addJournal( Journal *journal );
204 bool addJournal( Journal *journal, const TQString &subresource );
205
209 bool deleteJournal( Journal * );
213 Journal *journal( const TQString &uid );
221 Journal::List rawJournalsForDate( const TQDate &date );
222
226 Alarm::List alarms( const TQDateTime &from, const TQDateTime &to );
227
231 Alarm::List alarmsTo( const TQDateTime &to );
232
236 void setTimeZoneId( const TQString &timeZoneId );
237
238 TQString timeZoneId() const;
239
243 const Person &getOwner() const;
247 void setOwner( const Person &owner );
248
249 void enableChangeNotification();
250 void disableChangeNotification();
251
252 void clearChange( Incidence * );
253 void clearChange( const TQString &uid );
254
255 void clearChanges();
256
257 bool hasChanges() const;
258
259 Incidence::List allChanges() const;
260
261 Incidence::List addedIncidences() const;
262 Incidence::List changedIncidences() const;
263 Incidence::List deletedIncidences() const;
264
268 void loadCache();
269
273 void saveCache();
274
278 void clearCache();
279
283 void clearEventsCache();
284
288 void clearTodosCache();
289
293 void clearJournalsCache();
294
295 void cleanUpEventCache( const KCal::Event::List &eventList );
296 void cleanUpTodoCache( const KCal::Todo::List &todoList );
297
301 KPIM::IdMapper& idMapper();
302
303 protected:
304 // From Calendar::Observer
305 void calendarIncidenceAdded( KCal::Incidence *incidence );
306 void calendarIncidenceChanged( KCal::Incidence *incidence );
307 void calendarIncidenceDeleted( KCal::Incidence *incidence );
308
309 CalendarLocal mCalendar;
310
315 virtual void doClose();
320 virtual bool doOpen();
324 bool checkForReload();
328 bool checkForSave();
329
330 void checkForAutomaticSave();
331
332 void addInfoText( TQString & ) const;
333
334 void setupSaveTimer();
335 void setupReloadTimer();
336
341 virtual TQString cacheFile() const;
342
346 virtual TQString changesCacheFile( const TQString& ) const;
347 void loadChangesCache( TQMap<Incidence*, bool>&, const TQString& );
348 void loadChangesCache();
349 void saveChangesCache( const TQMap<Incidence*, bool>&, const TQString& );
350 void saveChangesCache();
351
352 protected slots:
353 void slotReload();
354 void slotSave();
355
356 void setIdMapperIdentifier();
357
358 private:
359 int mReloadPolicy;
360 int mReloadInterval;
361 TQTimer mReloadTimer;
362 bool mReloaded;
363
364 int mSavePolicy;
365 int mSaveInterval;
366 TQTimer mSaveTimer;
367
368 TQDateTime mLastLoad;
369 TQDateTime mLastSave;
370
371 TQMap<KCal::Incidence *,bool> mAddedIncidences;
372 TQMap<KCal::Incidence *,bool> mChangedIncidences;
373 TQMap<KCal::Incidence *,bool> mDeletedIncidences;
374
375 KPIM::IdMapper mIdMapper;
376
377 class Private;
378 Private *d;
379};
380
381}
382
383#endif
This class provides a calendar stored as a local file.
Definition: calendarlocal.h:37
The Observer class.
Definition: calendar.h:869
This class provides an Event in the sense of RFC2445.
Definition: event.h:33
This class provides the base class common to all calendar components.
Definition: incidence.h:48
This class provides a Journal in the sense of RFC2445.
Definition: journal.h:34
This class represents a person.
Definition: person.h:35
This class provides a calendar resource using a local CalendarLocal object to cache the calendar data...
TQDateTime lastLoad() const
Return time of last load.
Event::List events()
Return filtered list of all events in calendar.
TQDateTime lastSave() const
Return time of last save.
This class provides the interfaces for a calendar resource.
This class provides a Todo in the sense of RFC2445.
Definition: todo.h:32
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38
TodoSortField
How Todos are to be sorted.
Definition: calendar.h:91
@ TodoSortUnsorted
Todos are to be unsorted.
Definition: calendar.h:93
JournalSortField
How Journals are to be sorted.
Definition: calendar.h:111
@ JournalSortUnsorted
Journals are to be unsorted.
Definition: calendar.h:113
EventSortField
How Events are to be sorted.
Definition: calendar.h:75
@ EventSortUnsorted
Events are to be unsorted.
Definition: calendar.h:77
SortDirection
Sort direction.
Definition: calendar.h:63
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition: calendar.h:65