libkcal
resourcecalendar.h00001
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 public:
00061 ResourceCalendar( const KConfig * );
00062 virtual ~ResourceCalendar();
00063
00067 void clearException();
00068
00073 void setException( ErrorFormat *error );
00074
00079 ErrorFormat *exception();
00080
00081 void setResolveConflict( bool b);
00082
00083 virtual void writeConfig( KConfig* config );
00084
00089 virtual TQString infoText() const;
00090
00110 bool load();
00111
00129 bool save( Incidence *incidence = 0 );
00130
00135 virtual bool isSaving() { return false; }
00136
00140 virtual KABC::Lock *lock() = 0;
00141
00146 virtual KDE_DEPRECATED bool addIncidence( Incidence * );
00147
00151 virtual bool addIncidence( Incidence *, const TQString &subresource );
00152
00156 virtual bool deleteIncidence( Incidence * );
00157
00162 Incidence *incidence( const TQString &uid );
00163
00168 virtual KDE_DEPRECATED bool addEvent( Event *event ) = 0;
00169 virtual bool addEvent( Event *event, const TQString &subresource ) = 0;
00170
00174 virtual bool deleteEvent( Event * ) = 0;
00175
00179 virtual Event *event( const TQString &uid ) = 0;
00180
00185 virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00186
00191 virtual Event::List rawEventsForDate( const TQDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00192
00196 virtual Event::List rawEventsForDate( const TQDateTime &qdt ) = 0;
00197
00202 virtual Event::List rawEvents( const TQDate &start, const TQDate &end,
00203 bool inclusive = false ) = 0;
00204
00224 virtual bool setValue( const TQString &key, const TQString &value );
00225
00226 signals:
00233 void resourceChanged( ResourceCalendar * );
00234
00239 void resourceLoaded( ResourceCalendar * );
00244 void resourceSaved( ResourceCalendar * );
00245
00249 void resourceLoadError( ResourceCalendar *, const TQString &error );
00253 void resourceSaveError( ResourceCalendar *, const TQString &error );
00254
00258 void signalSubresourceAdded( ResourceCalendar *, const TQString& type,
00259 const TQString& subresource, const TQString& label );
00260
00264 void signalSubresourceRemoved( ResourceCalendar *, const TQString &,
00265 const TQString & );
00266
00267 public:
00272 virtual KDE_DEPRECATED bool addTodo( Todo *todo ) = 0;
00273 virtual bool addTodo( Todo *todo, const TQString &subresource ) = 0;
00274
00278 virtual bool deleteTodo( Todo * ) = 0;
00284 virtual Todo *todo( const TQString &uid ) = 0;
00288 virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00292 virtual Todo::List rawTodosForDate( const TQDate &date ) = 0;
00293
00294
00299 virtual KDE_DEPRECATED bool addJournal( Journal * ) = 0;
00300 virtual bool addJournal( Journal *journal, const TQString &subresource ) = 0;
00301
00305 virtual bool deleteJournal( Journal * ) = 0;
00306
00310 virtual Journal *journal( const TQString &uid ) = 0;
00314 virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00318 virtual Journal::List rawJournalsForDate( const TQDate &date ) = 0;
00319
00323 virtual Alarm::List alarms( const TQDateTime &from,
00324 const TQDateTime &to ) = 0;
00325
00329 virtual Alarm::List alarmsTo( const TQDateTime &to ) = 0;
00330
00331
00333 Incidence::List rawIncidences();
00334
00338 virtual void setTimeZoneId( const TQString &timeZoneId ) = 0;
00339
00345 virtual TQStringList subresources() const { return TQStringList(); }
00346
00350 virtual bool canHaveSubresources() const { return false; }
00351
00355 virtual bool subresourceActive( const TQString& ) const { return true; }
00356
00360 virtual bool subresourceWritable( const TQString& ) const;
00361
00365 virtual const TQString labelForSubresource( const TQString& resource ) const
00366 {
00367
00368 return resource;
00369 };
00370
00377 virtual TQString subresourceIdentifier( Incidence *incidence )
00378 { Q_UNUSED( incidence ); return TQString(); }
00379
00380
00381
00385 virtual bool removeSubresource( const TQString& resource );
00386
00391 virtual bool addSubresource( const TQString& resource, const TQString& parent );
00392
00397 virtual TQString subresourceType( const TQString &resource );
00398
00403 virtual void beginAddingIncidences();
00404
00409 virtual void endAddingIncidences();
00410
00411 public slots:
00415 virtual void setSubresourceActive( const TQString &, bool active );
00416
00417 protected:
00418
00419 bool mResolveConflict;
00423 virtual bool doLoad() = 0;
00427 virtual bool doSave() = 0;
00428
00433 virtual bool doSave( Incidence * );
00434
00438 virtual void addInfoText( TQString & ) const {};
00439
00443 void loadError( const TQString &errorMessage = TQString::null );
00447 void saveError( const TQString &errorMessage = TQString::null );
00448
00449 private:
00450 bool mReceivedLoadError;
00451 bool mReceivedSaveError;
00452
00453 ErrorFormat *mException;
00454
00455 class Private;
00456 Private *d;
00457 };
00458
00459 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00460
00461 }
00462
00463 #endif
|