• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KCal Library

resourcecached.h

00001 /*
00002   This file is part of the kcal library.
00003 
00004   Copyright (c) 2006 David Jarvie <djarvie@kde.org>
00005   Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Library General Public License for more details.
00016 
00017   You should have received a copy of the GNU Library General Public License
00018   along with this library; see the file COPYING.LIB.  If not, write to
00019   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020   Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef KCAL_RESOURCECACHED_H
00023 #define KCAL_RESOURCECACHED_H
00024 
00025 #include "resourcecalendar.h"
00026 #include "incidence.h"
00027 
00028 #include <kdatetime.h>
00029 
00030 #include <QtCore/QString>
00031 
00032 class KConfigGroup;
00033 namespace KRES { class IdMapper; }
00034 
00035 namespace KCal {
00036 
00037 class CalendarLocal;
00038 
00043 class KCAL_EXPORT ResourceCached : public ResourceCalendar,
00044                                    public KCal::Calendar::CalendarObserver
00045 {
00046   Q_OBJECT
00047   public:
00052     enum {
00053       ReloadNever,     
00054       ReloadOnStartup, 
00055       ReloadInterval   
00056     };
00057 
00062     enum {
00063       SaveNever,    
00064       SaveOnExit,   
00065       SaveInterval, 
00066       SaveDelayed,  
00067       SaveAlways    
00068     };
00069 
00075     enum CacheAction {
00076       DefaultCache,
00077       NoSyncCache, 
00078       SyncCache    
00079     };
00080 
00081     ResourceCached();
00082     explicit ResourceCached( const KConfigGroup &group );
00083     virtual ~ResourceCached();
00084 
00085     void readConfig( const KConfigGroup &group );
00086     void writeConfig( KConfigGroup &group );
00087 
00095     void setReloadPolicy( int policy );
00101     int reloadPolicy() const;
00102 
00107     void setReloadInterval( int minutes );
00108 
00112     int reloadInterval() const;
00113 
00122     bool inhibitDefaultReload( bool inhibit );
00123     bool defaultReloadInhibited() const;
00124 
00128     bool reloaded() const;
00129 
00139     void setSavePolicy( int policy );
00145     int savePolicy() const;
00146 
00151     void setSaveInterval( int minutes );
00152 
00156     int saveInterval() const;
00157 
00161     KDateTime lastLoad() const;
00162 
00166     KDateTime lastSave() const;
00167 
00174     bool load( CacheAction action );
00175 
00179     virtual bool load();
00180 
00191     bool save( CacheAction action, Incidence *incidence = 0 );
00192 
00196     virtual bool save( Incidence *incidence = 0 );
00197 
00201     bool addEvent( Event *event );
00202 
00206     bool deleteEvent( Event *event );
00207 
00211     void deleteAllEvents();
00212 
00216     Event *event( const QString &UniqueStr );
00217 
00221     Event::List events();
00222 
00226     Event::List rawEvents( EventSortField sortField = EventSortUnsorted,
00227                            SortDirection sortDirection = SortDirectionAscending );
00228 
00238     Event::List rawEventsForDate( const QDate &date,
00239                                   const KDateTime::Spec &timeSpec = KDateTime::Spec(),
00240                                   EventSortField sortField = EventSortUnsorted,
00241                                   SortDirection sortDirection = SortDirectionAscending );
00242 
00246     Event::List rawEventsForDate( const KDateTime &dt );
00247 
00258     Event::List rawEvents( const QDate &start, const QDate &end,
00259                            const KDateTime::Spec &timeSpec = KDateTime::Spec(),
00260                            bool inclusive = false );
00261 
00265     bool addTodo( Todo *todo );
00269     bool deleteTodo( Todo * );
00270 
00274     void deleteAllTodos();
00275 
00280     Todo *todo( const QString &uid );
00281 
00285     Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted,
00286                          SortDirection sortDirection = SortDirectionAscending );
00287 
00291     Todo::List rawTodosForDate( const QDate &date );
00292 
00296     virtual bool addJournal( Journal * );
00297 
00301     virtual bool deleteJournal( Journal * );
00302 
00306     virtual void deleteAllJournals();
00307 
00311     virtual Journal *journal( const QString &uid );
00312 
00316     Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted,
00317                                SortDirection sortDirection = SortDirectionAscending );
00318 
00322     Journal::List rawJournalsForDate( const QDate &date );
00323 
00327     Alarm::List alarms( const KDateTime &from, const KDateTime &to );
00328 
00332     Alarm::List alarmsTo( const KDateTime &to );
00333 
00340     void setTimeSpec( const KDateTime::Spec &timeSpec );
00341 
00347     KDateTime::Spec timeSpec() const;
00348 
00355     void setTimeZoneId( const QString &timeZoneId );
00356 
00363     QString timeZoneId() const;
00364 
00369     virtual void shiftTimes( const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec );
00370 
00374     Person owner() const;
00375 
00380     void setOwner( const Person &owner );
00381 
00382     void enableChangeNotification();
00383     void disableChangeNotification();
00384 
00385     void clearChange( Incidence *incidence );
00386     void clearChange( const QString &uid );
00387 
00388     void clearChanges();
00389 
00390     bool hasChanges() const;
00391 
00392     Incidence::List allChanges() const;
00393 
00394     Incidence::List addedIncidences() const;
00395     Incidence::List changedIncidences() const;
00396     Incidence::List deletedIncidences() const;
00397 
00402     bool loadFromCache();
00403 
00407     void saveToCache();
00408 
00412     void clearCache();
00413 
00414     void cleanUpEventCache( const KCal::Event::List &eventList );
00415     void cleanUpTodoCache( const KCal::Todo::List &todoList );
00416 
00420     KRES::IdMapper &idMapper();
00421 
00422     using QObject::event;   // prevent warning about hidden virtual method
00423 
00424   protected:
00425     CalendarLocal *calendar() const;
00426 
00427     // From Calendar::CalendarObserver
00428     void calendarIncidenceAdded( KCal::Incidence *incidence );
00429     void calendarIncidenceChanged( KCal::Incidence *incidence );
00430     void calendarIncidenceDeleted( KCal::Incidence *incidence );
00431 
00436     virtual void doClose();
00437 
00443     virtual bool doOpen();
00444 
00448     virtual bool doLoad( bool syncCache ) = 0;
00449 
00456     void setReloaded( bool done );
00457 
00466     virtual bool doSave( bool syncCache ) = 0;
00467 
00477     virtual bool doSave( bool syncCache, Incidence *incidence );
00478 
00482     bool checkForReload();
00483 
00487     bool checkForSave();
00488 
00489     void checkForAutomaticSave();
00490 
00491     void addInfoText( QString & ) const;
00492 
00493     void setupSaveTimer();
00494     void setupReloadTimer();
00495 
00500     virtual QString cacheFile() const;
00501 
00505     virtual QString changesCacheFile( const QString &type ) const;
00506     void loadChangesCache( QMap<Incidence *, bool> &map, const QString &type );
00507     void loadChangesCache();
00508     void saveChangesCache( const QMap<Incidence *, bool> &map, const QString &type );
00509     void saveChangesCache();
00510 
00511   protected Q_SLOTS:
00512     void slotReload();
00513     void slotSave();
00514 
00515     void setIdMapperIdentifier();
00516 
00517   private:
00518     //@cond PRIVATE
00519     Q_DISABLE_COPY( ResourceCached )
00520     class Private;
00521     Private *const d;
00522     //@endcond
00523 };
00524 
00525 }
00526 
00527 #endif

KCal Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal