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 <tqstring.h>
00029 #include <tqdatetime.h>
00030 #include <tqptrlist.h>
00031
00032 #include <kconfig.h>
00033
00034 #include "alarm.h"
00035 #include "todo.h"
00036 #include "event.h"
00037 #include "journal.h"
00038 #include "calendar.h"
00039 #include "exceptions.h"
00040
00041 #include <kresources/resource.h>
00042 #include <kresources/manager.h>
00043 #include <kabc/lock.h>
00044 #include <kdepimmacros.h>
00045
00046 namespace KCal {
00047
00048 class CalFormat;
00049
00057 class LIBKCAL_EXPORT ResourceCalendar : public KRES::Resource
00058 {
00059 Q_OBJECT
00060 TQ_OBJECT
00061 public:
00062 ResourceCalendar( const KConfig * );
00063 virtual ~ResourceCalendar();
00064
00068 void clearException();
00069
00074 void setException( ErrorFormat *error );
00075
00080 ErrorFormat *exception();
00081
00082 void setResolveConflict( bool b);
00083
00084 virtual void writeConfig( KConfig* config );
00085
00090 virtual TQString infoText() const;
00091
00111 bool load();
00112
00130 bool save( Incidence *incidence = 0 );
00131
00136 virtual bool isSaving() { return false; }
00137
00141 virtual KABC::Lock *lock() = 0;
00142
00147 virtual KDE_DEPRECATED bool addIncidence( Incidence * );
00148
00152 virtual bool addIncidence( Incidence *, const TQString &subresource );
00153
00157 virtual bool deleteIncidence( Incidence * );
00158
00163 Incidence *incidence( const TQString &uid );
00164
00169 virtual KDE_DEPRECATED bool addEvent( Event *event ) = 0;
00170 virtual bool addEvent( Event *event, const TQString &subresource ) = 0;
00171
00175 virtual bool deleteEvent( Event * ) = 0;
00176
00180 virtual Event *event( const TQString &uid ) = 0;
00181
00186 virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00187
00192 virtual Event::List rawEventsForDate( const TQDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00193
00197 virtual Event::List rawEventsForDate( const TQDateTime &qdt ) = 0;
00198
00203 virtual Event::List rawEvents( const TQDate &start, const TQDate &end,
00204 bool inclusive = false ) = 0;
00205
00225 virtual bool setValue( const TQString &key, const TQString &value );
00226
00227 signals:
00234 void resourceChanged( ResourceCalendar * );
00235
00240 void resourceLoaded( ResourceCalendar * );
00245 void resourceSaved( ResourceCalendar * );
00246
00250 void resourceLoadError( ResourceCalendar *, const TQString &error );
00254 void resourceSaveError( ResourceCalendar *, const TQString &error );
00255
00259 void signalSubresourceAdded( ResourceCalendar *, const TQString& type,
00260 const TQString& subresource, const TQString& label );
00261
00265 void signalSubresourceRemoved( ResourceCalendar *, const TQString &,
00266 const TQString & );
00267
00268 public:
00273 virtual KDE_DEPRECATED bool addTodo( Todo *todo ) = 0;
00274 virtual bool addTodo( Todo *todo, const TQString &subresource ) = 0;
00275
00279 virtual bool deleteTodo( Todo * ) = 0;
00285 virtual Todo *todo( const TQString &uid ) = 0;
00289 virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00293 virtual Todo::List rawTodosForDate( const TQDate &date ) = 0;
00294
00295
00300 virtual KDE_DEPRECATED bool addJournal( Journal * ) = 0;
00301 virtual bool addJournal( Journal *journal, const TQString &subresource ) = 0;
00302
00306 virtual bool deleteJournal( Journal * ) = 0;
00307
00311 virtual Journal *journal( const TQString &uid ) = 0;
00315 virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00319 virtual Journal::List rawJournalsForDate( const TQDate &date ) = 0;
00320
00324 virtual Alarm::List alarms( const TQDateTime &from,
00325 const TQDateTime &to ) = 0;
00326
00330 virtual Alarm::List alarmsTo( const TQDateTime &to ) = 0;
00331
00332
00334 Incidence::List rawIncidences();
00335
00339 virtual void setTimeZoneId( const TQString &timeZoneId ) = 0;
00340
00346 virtual TQStringList subresources() const { return TQStringList(); }
00347
00351 virtual bool canHaveSubresources() const { return false; }
00352
00356 virtual bool subresourceActive( const TQString& ) const { return true; }
00357
00361 virtual bool subresourceWritable( const TQString& ) const;
00362
00366 virtual const TQString labelForSubresource( const TQString& resource ) const
00367 {
00368
00369 return resource;
00370 };
00371
00378 virtual TQString subresourceIdentifier( Incidence *incidence )
00379 { Q_UNUSED( incidence ); return TQString(); }
00380
00381
00382
00386 virtual bool removeSubresource( const TQString& resource );
00387
00392 virtual bool addSubresource( const TQString& resource, const TQString& parent );
00393
00398 virtual TQString subresourceType( const TQString &resource );
00399
00404 virtual void beginAddingIncidences();
00405
00410 virtual void endAddingIncidences();
00411
00412 public slots:
00416 virtual void setSubresourceActive( const TQString &, bool active );
00417
00418 protected:
00419
00420 bool mResolveConflict;
00424 virtual bool doLoad() = 0;
00428 virtual bool doSave() = 0;
00429
00434 virtual bool doSave( Incidence * );
00435
00439 virtual void addInfoText( TQString & ) const {};
00440
00444 void loadError( const TQString &errorMessage = TQString() );
00448 void saveError( const TQString &errorMessage = TQString() );
00449
00450 private:
00451 bool mReceivedLoadError;
00452 bool mReceivedSaveError;
00453
00454 ErrorFormat *mException;
00455
00456 class Private;
00457 Private *d;
00458 };
00459
00460 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00461
00462 }
00463
00464 #endif