• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

KCal Library

  • kcal
resourcecached.h
1/*
2 This file is part of the kcal library.
3
4 Copyright (c) 2006 David Jarvie <djarvie@kde.org>
5 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22#ifndef KCAL_RESOURCECACHED_H
23#define KCAL_RESOURCECACHED_H
24
25#include "resourcecalendar.h"
26#include "incidence.h"
27
28#include <kdatetime.h>
29
30#include <QtCore/QString>
31
32class KConfigGroup;
33namespace KRES { class IdMapper; }
34
35namespace KCal {
36
37class CalendarLocal;
38
43class KCAL_DEPRECATED_EXPORT ResourceCached : public ResourceCalendar,
44 public KCal::Calendar::CalendarObserver
45{
46 Q_OBJECT
47 public:
52 enum {
53 ReloadNever,
54 ReloadOnStartup,
55 ReloadInterval
56 };
57
62 enum {
63 SaveNever,
64 SaveOnExit,
65 SaveInterval,
66 SaveDelayed,
67 SaveAlways
68 };
69
75 enum CacheAction {
76 DefaultCache,
77 NoSyncCache,
78 SyncCache
79 };
80
81 ResourceCached();
82 explicit ResourceCached( const KConfigGroup &group );
83 virtual ~ResourceCached();
84
85 void readConfig( const KConfigGroup &group );
86 void writeConfig( KConfigGroup &group );
87
95 void setReloadPolicy( int policy );
101 int reloadPolicy() const;
102
107 void setReloadInterval( int minutes );
108
112 int reloadInterval() const;
113
122 bool inhibitDefaultReload( bool inhibit );
123 bool defaultReloadInhibited() const;
124
128 bool reloaded() const;
129
139 void setSavePolicy( int policy );
145 int savePolicy() const;
146
151 void setSaveInterval( int minutes );
152
156 int saveInterval() const;
157
161 KDateTime lastLoad() const;
162
166 KDateTime lastSave() const;
167
174 bool load( CacheAction action );
175
179 virtual bool load();
180
191 bool save( CacheAction action, Incidence *incidence = 0 );
192
196 virtual bool save( Incidence *incidence = 0 );
197
203 bool addEvent( Event *event );
204
208 bool deleteEvent( Event *event );
209
213 void deleteAllEvents();
214
218 Event *event( const QString &UniqueStr );
219
223 Event::List events();
224
228 Event::List rawEvents( EventSortField sortField = EventSortUnsorted,
229 SortDirection sortDirection = SortDirectionAscending );
230
240 Event::List rawEventsForDate( const QDate &date,
241 const KDateTime::Spec &timeSpec = KDateTime::Spec(),
242 EventSortField sortField = EventSortUnsorted,
243 SortDirection sortDirection = SortDirectionAscending );
244
248 Event::List rawEventsForDate( const KDateTime &dt );
249
260 Event::List rawEvents( const QDate &start, const QDate &end,
261 const KDateTime::Spec &timeSpec = KDateTime::Spec(),
262 bool inclusive = false );
263
269 bool addTodo( Todo *todo );
270
274 bool deleteTodo( Todo * );
275
279 void deleteAllTodos();
280
285 Todo *todo( const QString &uid );
286
290 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted,
291 SortDirection sortDirection = SortDirectionAscending );
292
296 Todo::List rawTodosForDate( const QDate &date );
297
303 virtual KCAL_DEPRECATED bool addJournal( Journal *journal );
304
308 virtual bool deleteJournal( Journal * );
309
313 virtual void deleteAllJournals();
314
318 virtual Journal *journal( const QString &uid );
319
323 Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted,
324 SortDirection sortDirection = SortDirectionAscending );
325
329 Journal::List rawJournalsForDate( const QDate &date );
330
334 Alarm::List alarms( const KDateTime &from, const KDateTime &to );
335
339 Alarm::List alarmsTo( const KDateTime &to );
340
347 void setTimeSpec( const KDateTime::Spec &timeSpec );
348
354 KDateTime::Spec timeSpec() const;
355
362 void setTimeZoneId( const QString &timeZoneId );
363
370 QString timeZoneId() const;
371
376 virtual void shiftTimes( const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec );
377
381 Person owner() const;
382
387 void setOwner( const Person &owner );
388
389 void enableChangeNotification();
390 void disableChangeNotification();
391
392 void clearChange( Incidence *incidence );
393 void clearChange( const QString &uid );
394
395 void clearChanges();
396
397 bool hasChanges() const;
398
399 Incidence::List allChanges() const;
400
401 Incidence::List addedIncidences() const;
402 Incidence::List changedIncidences() const;
403 Incidence::List deletedIncidences() const;
404
409 bool loadFromCache();
410
414 void saveToCache();
415
419 void clearCache();
420
421 void cleanUpEventCache( const KCal::Event::List &eventList );
422 void cleanUpTodoCache( const KCal::Todo::List &todoList );
423
427 KRES::IdMapper &idMapper();
428
429 using QObject::event; // prevent warning about hidden virtual method
430
431 protected:
432 CalendarLocal *calendar() const;
433
434 // From Calendar::CalendarObserver
435 void calendarIncidenceAdded( KCal::Incidence *incidence );
436 void calendarIncidenceChanged( KCal::Incidence *incidence );
437 void calendarIncidenceDeleted( KCal::Incidence *incidence );
438
443 virtual void doClose();
444
450 virtual bool doOpen();
451
455 virtual bool doLoad( bool syncCache ) = 0;
456
463 void setReloaded( bool done );
464
473 virtual bool doSave( bool syncCache ) = 0;
474
484 virtual bool doSave( bool syncCache, Incidence *incidence );
485
489 bool checkForReload();
490
494 bool checkForSave();
495
496 void checkForAutomaticSave();
497
498 void addInfoText( QString & ) const;
499
500 void setupSaveTimer();
501 void setupReloadTimer();
502
507 virtual QString cacheFile() const;
508
512 virtual QString changesCacheFile( const QString &type ) const;
513 void loadChangesCache( QMap<Incidence *, bool> &map, const QString &type );
514 void loadChangesCache();
515 void saveChangesCache( const QMap<Incidence *, bool> &map, const QString &type );
516 void saveChangesCache();
517
518 protected Q_SLOTS:
519 void slotReload();
520 void slotSave();
521
522 void setIdMapperIdentifier();
523
524 private:
525 //@cond PRIVATE
526 Q_DISABLE_COPY( ResourceCached )
527 class Private;
528 Private *const d;
529 //@endcond
530};
531
532}
533
534#endif
KCal::TodoSortField
TodoSortField
Calendar Todo sort keys.
Definition calendar.h:79
KCal::TodoSortUnsorted
@ TodoSortUnsorted
Do not sort Todos.
Definition calendar.h:80
KCal::JournalSortField
JournalSortField
Calendar Journal sort keys.
Definition calendar.h:91
KCal::JournalSortUnsorted
@ JournalSortUnsorted
Do not sort Journals.
Definition calendar.h:92
KCal::EventSortField
EventSortField
Calendar Event sort keys.
Definition calendar.h:69
KCal::EventSortUnsorted
@ EventSortUnsorted
Do not sort Events.
Definition calendar.h:70
KCal::SortDirection
SortDirection
Calendar Incidence sort directions.
Definition calendar.h:61
KCal::SortDirectionAscending
@ SortDirectionAscending
Sort in ascending order (first to last)
Definition calendar.h:62
KCal::Alarm::List
ListBase< Alarm > List
List of alarms.
Definition alarm.h:83
KCal::CalendarLocal
This class provides a calendar stored as a local file.
Definition calendarlocal.h:44
KCal::Calendar::CalendarObserver
The CalendarObserver class.
Definition calendar.h:967
KCal::Event
This class provides an Event in the sense of RFC2445.
Definition event.h:42
KCal::Event::List
ListBase< Event > List
List of events.
Definition event.h:55
KCal::Incidence
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition incidence.h:70
KCal::Incidence::List
ListBase< Incidence > List
List of incidences.
Definition incidence.h:171
KCal::Journal
Provides a Journal in the sense of RFC2445.
Definition journal.h:44
KCal::Journal::List
ListBase< Journal > List
List of journals.
Definition journal.h:49
KCal::Person
Represents a person, by name ane email address.
Definition person.h:49
KCal::ResourceCached
This class provides a calendar resource using a local CalendarLocal object to cache the calendar data...
Definition resourcecached.h:45
KCal::ResourceCached::setTimeZoneId
void setTimeZoneId(const QString &timeZoneId)
Set id of timezone, e.g.
Definition resourcecached.cpp:360
KCal::ResourceCached::lastSave
KDateTime lastSave() const
Return time of last save.
KCal::ResourceCached::changesCacheFile
virtual QString changesCacheFile(const QString &type) const
Functions for keeping the changes persistent.
Definition resourcecached.cpp:605
KCal::ResourceCached::setTimeSpec
void setTimeSpec(const KDateTime::Spec &timeSpec)
Set the time specification (time zone, etc.).
Definition resourcecached.cpp:350
KCal::ResourceCached::doOpen
virtual bool doOpen()
Opens the resource.
Definition resourcecached.cpp:878
KCal::ResourceCached::addInfoText
void addInfoText(QString &) const
Add info text for concrete resources.
Definition resourcecached.cpp:853
KCal::ResourceCached::deleteJournal
virtual bool deleteJournal(Journal *)
Remove a Journal from the calendar.
Definition resourcecached.cpp:295
KCal::ResourceCached::owner
Person owner() const
Return the owner of the calendar's full name.
Definition resourcecached.cpp:889
KCal::ResourceCached::ReloadInterval
@ ReloadInterval
reload at regular intervals set by setReloadInterval()
Definition resourcecached.h:55
KCal::ResourceCached::ReloadNever
@ ReloadNever
never reload the resource automatically
Definition resourcecached.h:53
KCal::ResourceCached::ReloadOnStartup
@ ReloadOnStartup
reload when the resource is opened
Definition resourcecached.h:54
KCal::ResourceCached::setReloaded
void setReloaded(bool done)
Set the cache-reloaded status.
Definition resourcecached.cpp:124
KCal::ResourceCached::lastLoad
KDateTime lastLoad() const
Return time of last load.
KCal::ResourceCached::deleteAllTodos
void deleteAllTodos()
Removes all todos from this calendar.
Definition resourcecached.cpp:290
KCal::ResourceCached::rawEventsForDate
Event::List rawEventsForDate(const QDate &date, const KDateTime::Spec &timeSpec=KDateTime::Spec(), EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Builds and then returns a list of all events that match for the date specified.
Definition resourcecached.cpp:255
KCal::ResourceCached::calendarIncidenceChanged
void calendarIncidenceChanged(KCal::Incidence *incidence)
Notify the Observer that an Incidence has been modified.
Definition resourcecached.cpp:677
KCal::ResourceCached::CacheAction
CacheAction
Whether to update the cache file when loading a resource, or whether to upload the cache file after s...
Definition resourcecached.h:75
KCal::ResourceCached::DefaultCache
@ DefaultCache
use the default action set by setReloadPolicy() or setSavePolicy()
Definition resourcecached.h:76
KCal::ResourceCached::SyncCache
@ SyncCache
update the cache file before loading, or upload cache after saving
Definition resourcecached.h:78
KCal::ResourceCached::NoSyncCache
@ NoSyncCache
perform a cache-only operation, without downloading or uploading
Definition resourcecached.h:77
KCal::ResourceCached::setOwner
void setOwner(const Person &owner)
Set the owner of the calendar.
Definition resourcecached.cpp:884
KCal::ResourceCached::calendarIncidenceAdded
void calendarIncidenceAdded(KCal::Incidence *incidence)
Notify the Observer that an Incidence has been inserted.
Definition resourcecached.cpp:664
KCal::ResourceCached::deleteAllJournals
virtual void deleteAllJournals()
Removes all Journals from this calendar.
Definition resourcecached.cpp:300
KCal::ResourceCached::loadFromCache
bool loadFromCache()
Load the resource from the cache.
Definition resourcecached.cpp:437
KCal::ResourceCached::alarms
Alarm::List alarms(const KDateTime &from, const KDateTime &to)
Return all alarms, which occur in the given time interval.
Definition resourcecached.cpp:345
KCal::ResourceCached::journal
virtual Journal * journal(const QString &uid)
Return Journal with given unique id.
Definition resourcecached.cpp:325
KCal::ResourceCached::rawEvents
Event::List rawEvents(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return unfiltered list of all events in calendar.
Definition resourcecached.cpp:275
KCal::ResourceCached::rawJournals
Journal::List rawJournals(JournalSortField sortField=JournalSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return list of all journals.
Definition resourcecached.cpp:330
KCal::ResourceCached::events
Event::List events()
Return filtered list of all events in calendar.
KCal::ResourceCached::timeSpec
KDateTime::Spec timeSpec() const
Get the viewing time specification (time zone etc.) for the calendar.
Definition resourcecached.cpp:355
KCal::ResourceCached::doLoad
virtual bool doLoad(bool syncCache)=0
Do the actual loading of the resource data.
KCal::ResourceCached::doClose
virtual void doClose()
Virtual method from KRES::Resource, called when the last instace of the resource is closed.
Definition resourcecached.cpp:867
KCal::ResourceCached::alarmsTo
Alarm::List alarmsTo(const KDateTime &to)
Return all alarms, which occur before given date.
Definition resourcecached.cpp:340
KCal::ResourceCached::deleteEvent
bool deleteEvent(Event *event)
Deletes an event from this calendar.
Definition resourcecached.cpp:238
KCal::ResourceCached::deleteTodo
bool deleteTodo(Todo *)
Remove a todo from the todolist.
Definition resourcecached.cpp:285
KCal::ResourceCached::event
Event * event(const QString &UniqueStr)
Retrieves an event on the basis of the unique string ID.
Definition resourcecached.cpp:250
KCal::ResourceCached::rawJournalsForDate
Journal::List rawJournalsForDate(const QDate &date)
Return list of journals for the given date.
Definition resourcecached.cpp:335
KCal::ResourceCached::calendarIncidenceDeleted
void calendarIncidenceDeleted(KCal::Incidence *incidence)
Notify the Observer that an Incidence has been removed.
Definition resourcecached.cpp:691
KCal::ResourceCached::doSave
virtual bool doSave(bool syncCache)=0
Do the actual saving of the resource data.
KCal::ResourceCached::saveToCache
void saveToCache()
Save the resource back to the cache.
Definition resourcecached.cpp:509
KCal::ResourceCached::SaveAlways
@ SaveAlways
save after every change, after a 1 second delay
Definition resourcecached.h:67
KCal::ResourceCached::SaveNever
@ SaveNever
never save the resource automatically
Definition resourcecached.h:63
KCal::ResourceCached::SaveDelayed
@ SaveDelayed
save after every change, after a 15 second delay
Definition resourcecached.h:66
KCal::ResourceCached::SaveOnExit
@ SaveOnExit
save when the resource is closed
Definition resourcecached.h:64
KCal::ResourceCached::SaveInterval
@ SaveInterval
save at regular intervals set by setSaveInterval()
Definition resourcecached.h:65
KCal::ResourceCached::shiftTimes
virtual void shiftTimes(const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec)
Definition resourcecached.cpp:370
KCal::ResourceCached::addJournal
virtual KCAL_DEPRECATED bool addJournal(Journal *journal)
Add a Journal entry to calendar.
Definition resourcecached.cpp:320
KCal::ResourceCached::rawTodosForDate
Todo::List rawTodosForDate(const QDate &date)
Returns list of todos due on the specified date.
Definition resourcecached.cpp:315
KCal::ResourceCached::addEvent
bool addEvent(Event *event)
Add event to calendar.
Definition resourcecached.cpp:232
KCal::ResourceCached::load
bool load(CacheAction action)
Load resource data, specifying whether to refresh the cache file first.
Definition resourcecached.cpp:382
KCal::ResourceCached::deleteAllEvents
void deleteAllEvents()
Removes all Events from this calendar.
Definition resourcecached.cpp:245
KCal::ResourceCached::todo
Todo * todo(const QString &uid)
Searches todolist for an event with this unique string identifier, returns a pointer or null.
Definition resourcecached.cpp:310
KCal::ResourceCached::save
bool save(CacheAction action, Incidence *incidence=0)
Save the resource data to cache, and optionally upload the cache file afterwards.
Definition resourcecached.cpp:456
KCal::ResourceCached::checkForSave
bool checkForSave()
Check if save required according to save policy.
Definition resourcecached.cpp:845
KCal::ResourceCached::idMapper
KRES::IdMapper & idMapper()
Returns a reference to the id mapper.
Definition resourcecached.cpp:595
KCal::ResourceCached::checkForReload
bool checkForReload()
Check if reload required according to reload policy.
Definition resourcecached.cpp:834
KCal::ResourceCached::cacheFile
virtual QString cacheFile() const
This method is used by loadFromCache() and saveToCache(), reimplement it to change the location of th...
Definition resourcecached.cpp:600
KCal::ResourceCached::addTodo
bool addTodo(Todo *todo)
Add a todo to the todolist.
Definition resourcecached.cpp:280
KCal::ResourceCached::rawTodos
Todo::List rawTodos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return list of all todos.
Definition resourcecached.cpp:305
KCal::ResourceCached::timeZoneId
QString timeZoneId() const
Returns the viewing time zone ID for the resource.
Definition resourcecached.cpp:365
KCal::ResourceCached::clearCache
void clearCache()
Clear cache.
Definition resourcecached.cpp:524
KCal::ResourceCalendar::incidence
Incidence * incidence(const QString &uid)
Return incidence with given unique id.
Definition resourcecalendar.cpp:99
KCal::Todo
Provides a To-do in the sense of RFC2445.
Definition todo.h:45
KCal::Todo::List
ListBase< Todo > List
List of to-dos.
Definition todo.h:50
KRES::IdMapper
KRES::Resource::type
QString type() const
incidence.h
This file is part of the API for handling calendar data and defines the Incidence class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal