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 #include "exceptions.h"
00034
00035 #include "kresources/resource.h"
00036 #include "kresources/manager.h"
00037 #include "kabc/lock.h"
00038
00039 #include <kdatetime.h>
00040 #include <kconfig.h>
00041
00042 #include <QtCore/QString>
00043
00044 namespace KCal {
00045
00050 class KCAL_EXPORT_DEPRECATED ResourceCalendar : public KRES::Resource
00051 {
00052 Q_OBJECT
00053 public:
00054 ResourceCalendar();
00055 explicit ResourceCalendar( const KConfigGroup &group );
00056 virtual ~ResourceCalendar();
00057
00058 bool isResolveConflictSet() const;
00059 void setResolveConflict( bool b );
00060
00061 virtual void writeConfig( KConfigGroup &group );
00062
00067 virtual QString infoText() const;
00068
00088 virtual bool load();
00089
00107 bool save( Incidence *incidence = 0 );
00108
00118 bool save( QString &err, Incidence *incidence = 0 );
00119
00124 virtual bool isSaving();
00125
00133 void setInhibitSave( bool inhibit );
00134
00138 bool saveInhibited() const;
00139
00143 virtual KABC::Lock *lock() = 0;
00144
00148 virtual bool addIncidence( Incidence * );
00149
00153 virtual bool deleteIncidence( Incidence * );
00154
00161 Incidence *incidence( const QString &uid );
00162
00166 virtual bool addEvent( Event *event ) = 0;
00167
00171 virtual bool deleteEvent( Event * ) = 0;
00172
00176 virtual void deleteAllEvents() = 0;
00177
00181 virtual Event *event( const QString &uid ) = 0;
00182
00190 virtual Event::List rawEvents(
00191 EventSortField sortField = EventSortUnsorted,
00192 SortDirection sortDirection = SortDirectionAscending ) = 0;
00193
00203 virtual Event::List rawEventsForDate(
00204 const QDate &date,
00205 const KDateTime::Spec &timeSpec = KDateTime::Spec(),
00206 EventSortField sortField = EventSortUnsorted,
00207 SortDirection sortDirection = SortDirectionAscending ) = 0;
00208
00212 virtual Event::List rawEventsForDate( const KDateTime &dt ) = 0;
00213
00224 virtual Event::List rawEvents(
00225 const QDate &start, const QDate &end,
00226 const KDateTime::Spec &timeSpec = KDateTime::Spec(),
00227 bool inclusive = false ) = 0;
00228
00251 virtual bool setValue( const QString &key, const QString &value );
00252
00253 Q_SIGNALS:
00260 void resourceChanged( ResourceCalendar * );
00261
00266 void resourceLoaded( ResourceCalendar * );
00267
00272 void resourceSaved( ResourceCalendar * );
00273
00277 void resourceLoadError( ResourceCalendar *, const QString &error );
00278
00282 void resourceSaveError( ResourceCalendar *, const QString &error );
00283
00287 void signalSubresourceAdded( ResourceCalendar *, const QString &type,
00288 const QString &subresource, const QString &label );
00289
00293 void signalSubresourceRemoved( ResourceCalendar *, const QString &,
00294 const QString & );
00295
00296 public:
00300 virtual bool addTodo( Todo *todo ) = 0;
00301
00305 virtual bool deleteTodo( Todo * ) = 0;
00306
00310 virtual void deleteAllTodos() = 0;
00311
00318 virtual Todo *todo( const QString &uid ) = 0;
00319
00323 virtual Todo::List rawTodos(
00324 TodoSortField sortField = TodoSortUnsorted,
00325 SortDirection sortDirection = SortDirectionAscending ) = 0;
00326
00330 virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00331
00335 virtual bool addJournal( Journal * ) = 0;
00336
00340 virtual bool deleteJournal( Journal * ) = 0;
00341
00345 virtual void deleteAllJournals() = 0;
00346
00350 virtual Journal *journal( const QString &uid ) = 0;
00351
00355 virtual Journal::List rawJournals(
00356 JournalSortField sortField = JournalSortUnsorted,
00357 SortDirection sortDirection = SortDirectionAscending ) = 0;
00358
00362 virtual Journal::List rawJournalsForDate( const QDate &date ) = 0;
00363
00367 virtual Alarm::List alarms( const KDateTime &from,
00368 const KDateTime &to ) = 0;
00369
00373 virtual Alarm::List alarmsTo( const KDateTime &to ) = 0;
00374
00376 Incidence::List rawIncidences();
00377
00384 virtual void setTimeSpec( const KDateTime::Spec &timeSpec ) = 0;
00385
00391 virtual KDateTime::Spec timeSpec() const = 0;
00392
00402 virtual void setTimeZoneId( const QString &timeZoneId ) = 0;
00403
00411 virtual QString timeZoneId() const = 0;
00412
00427 virtual void shiftTimes( const KDateTime::Spec &oldSpec,
00428 const KDateTime::Spec &newSpec ) = 0;
00429
00435 virtual QStringList subresources() const;
00436
00440 virtual bool canHaveSubresources() const;
00441
00445 virtual bool subresourceActive( const QString &resource ) const;
00446
00450 virtual QString labelForSubresource( const QString &resource ) const;
00451
00460 virtual QString subresourceIdentifier( Incidence *incidence );
00461
00462 public Q_SLOTS:
00466 virtual void setSubresourceActive( const QString &resource, bool active );
00467
00471 virtual bool removeSubresource( const QString &resource );
00472
00477 virtual bool addSubresource( const QString &resource, const QString &parent );
00478
00483 virtual QString subresourceType( const QString &resource );
00484
00485 protected:
00489 virtual bool doLoad( bool syncCache ) = 0;
00490
00494 virtual bool doSave( bool syncCache ) = 0;
00495
00501 virtual bool doSave( bool syncCache, Incidence * );
00502
00506 virtual void addInfoText( QString & ) const {}
00507
00511 void loadError( const QString &errorMessage = QString() );
00512
00516 void saveError( const QString &errorMessage = QString() );
00517
00518 bool receivedLoadError() const;
00519 void setReceivedLoadError( bool b );
00520 bool receivedSaveError() const;
00521 void setReceivedSaveError( bool b );
00522
00529 void setNoReadOnlyOnLoad( bool noReadOnly );
00530
00535 bool noReadOnlyOnLoad() const;
00536
00537 using QObject::event;
00538
00539 private:
00540
00541 Q_DISABLE_COPY( ResourceCalendar )
00542
00543 class Private;
00544 Private *const d;
00545
00546 };
00547
00549 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00550
00551 }
00552
00553 #endif