KCal Library
resourcecalendar.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KCAL_RESOURCECALENDAR_H
00026 #define KCAL_RESOURCECALENDAR_H
00027
00028 #include "alarm.h"
00029 #include "todo.h"
00030 #include "event.h"
00031 #include "journal.h"
00032 #include "calendar.h"
00033
00034 #include "kresources/resource.h"
00035 #include "kresources/manager.h"
00036 #include "kabc/lock.h"
00037
00038 #include <kdatetime.h>
00039 #include <kconfig.h>
00040
00041 #include <QtCore/QString>
00042
00043 namespace KCal {
00044
00049 class KCAL_EXPORT ResourceCalendar : public KRES::Resource
00050 {
00051 Q_OBJECT
00052 public:
00053 ResourceCalendar();
00054 explicit ResourceCalendar( const KConfigGroup &group );
00055 virtual ~ResourceCalendar();
00056
00057 bool isResolveConflictSet() const;
00058 void setResolveConflict( bool b );
00059
00060 virtual void writeConfig( KConfigGroup &group );
00061
00066 virtual QString infoText() const;
00067
00087 virtual bool load();
00088
00106 bool save( Incidence *incidence = 0 );
00107
00117 bool save( QString &err, Incidence *incidence = 0 );
00118
00123 virtual bool isSaving();
00124
00132 void setInhibitSave( bool inhibit );
00133
00137 bool saveInhibited() const;
00138
00142 virtual KABC::Lock *lock() = 0;
00143
00147 virtual bool addIncidence( Incidence * );
00148
00152 virtual bool deleteIncidence( Incidence * );
00153
00160 Incidence *incidence( const QString &uid );
00161
00165 virtual bool addEvent( Event *event ) = 0;
00166
00170 virtual bool deleteEvent( Event * ) = 0;
00171
00175 virtual void deleteAllEvents() = 0;
00176
00180 virtual Event *event( const QString &uid ) = 0;
00181
00189 virtual Event::List rawEvents(
00190 EventSortField sortField = EventSortUnsorted,
00191 SortDirection sortDirection = SortDirectionAscending ) = 0;
00192
00202 virtual Event::List rawEventsForDate(
00203 const QDate &date,
00204 const KDateTime::Spec ×pec = KDateTime::Spec(),
00205 EventSortField sortField = EventSortUnsorted,
00206 SortDirection sortDirection = SortDirectionAscending ) = 0;
00207
00211 virtual Event::List rawEventsForDate( const KDateTime &dt ) = 0;
00212
00223 virtual Event::List rawEvents(
00224 const QDate &start, const QDate &end,
00225 const KDateTime::Spec ×pec = KDateTime::Spec(),
00226 bool inclusive = false ) = 0;
00227
00250 virtual bool setValue( const QString &key, const QString &value );
00251
00252 Q_SIGNALS:
00259 void resourceChanged( ResourceCalendar * );
00260
00265 void resourceLoaded( ResourceCalendar * );
00266
00271 void resourceSaved( ResourceCalendar * );
00272
00276 void resourceLoadError( ResourceCalendar *, const QString &error );
00277
00281 void resourceSaveError( ResourceCalendar *, const QString &error );
00282
00286 void signalSubresourceAdded( ResourceCalendar *, const QString &type,
00287 const QString &subresource, const QString &label );
00288
00292 void signalSubresourceRemoved( ResourceCalendar *, const QString &,
00293 const QString & );
00294
00295 public:
00299 virtual bool addTodo( Todo *todo ) = 0;
00300
00304 virtual bool deleteTodo( Todo * ) = 0;
00305
00309 virtual void deleteAllTodos() = 0;
00310
00317 virtual Todo *todo( const QString &uid ) = 0;
00318
00322 virtual Todo::List rawTodos(
00323 TodoSortField sortField = TodoSortUnsorted,
00324 SortDirection sortDirection = SortDirectionAscending ) = 0;
00325
00329 virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00330
00334 virtual bool addJournal( Journal * ) = 0;
00335
00339 virtual bool deleteJournal( Journal * ) = 0;
00340
00344 virtual void deleteAllJournals() = 0;
00345
00349 virtual Journal *journal( const QString &uid ) = 0;
00350
00354 virtual Journal::List rawJournals(
00355 JournalSortField sortField = JournalSortUnsorted,
00356 SortDirection sortDirection = SortDirectionAscending ) = 0;
00357
00361 virtual Journal::List rawJournalsForDate( const QDate &date ) = 0;
00362
00366 virtual Alarm::List alarms( const KDateTime &from,
00367 const KDateTime &to ) = 0;
00368
00372 virtual Alarm::List alarmsTo( const KDateTime &to ) = 0;
00373
00375 Incidence::List rawIncidences();
00376
00383 virtual void setTimeSpec( const KDateTime::Spec &timeSpec ) = 0;
00384
00390 virtual KDateTime::Spec timeSpec() const = 0;
00391
00401 virtual void setTimeZoneId( const QString &timeZoneId ) = 0;
00402
00410 virtual QString timeZoneId() const = 0;
00411
00426 virtual void shiftTimes( const KDateTime::Spec &oldSpec,
00427 const KDateTime::Spec &newSpec ) = 0;
00428
00434 virtual QStringList subresources() const;
00435
00439 virtual bool canHaveSubresources() const;
00440
00444 virtual bool subresourceActive( const QString &resource ) const;
00445
00449 virtual QString labelForSubresource( const QString &resource ) const;
00450
00459 virtual QString subresourceIdentifier( Incidence *incidence );
00460
00461 public Q_SLOTS:
00465 virtual void setSubresourceActive( const QString &resource, bool active );
00466
00470 virtual bool removeSubresource( const QString &resource );
00471
00476 virtual bool addSubresource( const QString &resource, const QString &parent );
00477
00482 virtual QString subresourceType( const QString &resource );
00483
00484 protected:
00488 virtual bool doLoad( bool syncCache ) = 0;
00489
00493 virtual bool doSave( bool syncCache ) = 0;
00494
00500 virtual bool doSave( bool syncCache, Incidence * );
00501
00505 virtual void addInfoText( QString & ) const {}
00506
00510 void loadError( const QString &errorMessage = QString() );
00511
00515 void saveError( const QString &errorMessage = QString() );
00516
00517 bool receivedLoadError() const;
00518 void setReceivedLoadError( bool b );
00519 bool receivedSaveError() const;
00520 void setReceivedSaveError( bool b );
00521
00528 void setNoReadOnlyOnLoad( bool noReadOnly );
00529
00534 bool noReadOnlyOnLoad() const;
00535
00536 using QObject::event;
00537
00538 private:
00539
00540 Q_DISABLE_COPY( ResourceCalendar )
00541 class Private;
00542 Private *const d;
00543
00544 };
00545
00547 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00548
00549 }
00550
00551 #endif