libkcal
calendarresources.hGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #ifndef KCAL_CALENDARRESOURCES_H
00030 #define KCAL_CALENDARRESOURCES_H
00031
00032 #include <qintdict.h>
00033 #include <qmap.h>
00034
00035 #include "calendar.h"
00036 #include "resourcecalendar.h"
00037
00038 #include "libkcal_export.h"
00039
00040 #include <kresources/manager.h>
00041
00042 class QWidget;
00043
00048 namespace KCal {
00049
00050 class CalFormat;
00051
00064 class LIBKCAL_EXPORT CalendarResources :
00065 public Calendar,
00066 public KRES::ManagerObserver<ResourceCalendar>
00067 {
00068 Q_OBJECT
00069 public:
00073 class DestinationPolicy
00074 {
00075 public:
00076 DestinationPolicy( CalendarResourceManager *manager,
00077 QWidget *parent = 0 ) :
00078 mManager( manager ), mParent( parent ) {}
00079
00080 virtual ResourceCalendar *destination( Incidence *incidence ) = 0;
00081 virtual QWidget *parent() { return mParent; }
00082 virtual void setParent( QWidget *newparent ) { mParent = newparent; }
00083 bool hasCalendarResources();
00084 protected:
00085 CalendarResourceManager *resourceManager()
00086 { return mManager; }
00087
00088 private:
00089 CalendarResourceManager *mManager;
00090 QWidget *mParent;
00091 };
00092
00096 class StandardDestinationPolicy : public DestinationPolicy
00097 {
00098 public:
00099 StandardDestinationPolicy( CalendarResourceManager *manager,
00100 QWidget *parent = 0 ) :
00101 DestinationPolicy( manager, parent ) {}
00102
00103 ResourceCalendar *destination( Incidence *incidence );
00104
00105 private:
00106 class Private;
00107 Private *d;
00108 };
00109
00113 class AskDestinationPolicy : public DestinationPolicy
00114 {
00115 public:
00116 AskDestinationPolicy( CalendarResourceManager *manager,
00117 QWidget *parent = 0 ) :
00118 DestinationPolicy( manager, parent ) {}
00119
00120 ResourceCalendar *destination( Incidence *incidence );
00121
00122 private:
00123 class Private;
00124 Private *d;
00125 };
00126
00130 class Ticket
00131 {
00132 friend class CalendarResources;
00133 public:
00134 ResourceCalendar *resource() const
00135 { return mResource; }
00136
00137 private:
00138 Ticket( ResourceCalendar *r ) : mResource( r ) {}
00139
00140 ResourceCalendar *mResource;
00141
00142 class Private;
00143 Private *d;
00144 };
00145
00162 CalendarResources(
00163 const QString &timeZoneId,
00164 const QString &family = QString::fromLatin1( "calendar" ) );
00165
00169 ~CalendarResources();
00170
00176 void load();
00177
00183 bool reload( const QString &tz );
00184
00188 void close();
00189
00203 virtual bool save( Ticket *ticket, Incidence *incidence = 0 );
00204
00208 void save();
00209
00215 bool isSaving();
00216
00222 CalendarResourceManager *resourceManager() const
00223 { return mManager; }
00224
00233 ResourceCalendar *resource( Incidence *incidence );
00234
00243 void readConfig( KConfig *config = 0 );
00244
00249 void setStandardDestinationPolicy();
00250
00255 void setAskDestinationPolicy();
00256
00265 QWidget *dialogParentWidget();
00272 void setDialogParentWidget( QWidget *parent );
00273
00284 Ticket *requestSaveTicket( ResourceCalendar *resource );
00285
00291 virtual void releaseSaveTicket( Ticket *ticket );
00292
00301 void resourceAdded( ResourceCalendar *resource );
00302
00303
00304
00312 bool addIncidence( Incidence *incidence );
00313
00324 KDE_DEPRECATED bool addIncidence( Incidence *incidence, ResourceCalendar *resource );
00325
00336 bool addIncidence( Incidence *incidence, ResourceCalendar *resource, const QString &subresource );
00337
00343 bool beginChange( Incidence *incidence );
00344
00350 bool endChange( Incidence *incidence );
00351
00352
00353
00364 bool addEvent( Event *event );
00365
00377 KDE_DEPRECATED bool addEvent( Event *event, ResourceCalendar *resource );
00378
00392 bool addEvent( Event *event, ResourceCalendar *resource, const QString &subresource );
00393
00404 bool deleteEvent( Event *event );
00405
00414 Event::List rawEvents(
00415 EventSortField sortField = EventSortUnsorted,
00416 SortDirection sortDirection = SortDirectionAscending );
00417
00427 Event::List rawEventsForDate( const QDateTime &qdt );
00428
00440 Event::List rawEvents( const QDate &start, const QDate &end,
00441 bool inclusive = false );
00442
00454 Event::List rawEventsForDate(
00455 const QDate &date,
00456 EventSortField sortField = EventSortUnsorted,
00457 SortDirection sortDirection = SortDirectionAscending );
00458
00467 Event *event( const QString &uid );
00468
00469
00470
00481 bool addTodo( Todo *todo );
00482
00494 KDE_DEPRECATED bool addTodo( Todo *todo, ResourceCalendar *resource );
00495
00509 bool addTodo( Todo *todo, ResourceCalendar *resource, const QString &subresource );
00510
00521 bool deleteTodo( Todo *todo );
00522
00531 Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted,
00532 SortDirection sortDirection = SortDirectionAscending );
00533
00542 Todo::List rawTodosForDate( const QDate &date );
00543
00552 Todo *todo( const QString &uid );
00553
00554
00555
00566 bool addJournal( Journal *journal );
00567
00579 KDE_DEPRECATED bool addJournal( Journal *journal, ResourceCalendar *resource );
00580
00594 bool addJournal( Journal *journal, ResourceCalendar *resource, const QString &subresource );
00595
00606 bool deleteJournal( Journal *journal );
00607
00616 Journal::List rawJournals(
00617 JournalSortField sortField = JournalSortUnsorted,
00618 SortDirection sortDirection = SortDirectionAscending );
00619
00627 Journal::List rawJournalsForDate( const QDate &date );
00628
00637 Journal *journal( const QString &uid );
00638
00639
00640
00649 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
00650
00658 Alarm::List alarmsTo( const QDateTime &to );
00659
00667 void setTimeZoneIdViewOnly( const QString& tz );
00668
00669
00670 bool hasCalendarResources();
00671 signals:
00675 void signalResourceModified( ResourceCalendar *resource );
00676
00680 void signalResourceAdded( ResourceCalendar *resource );
00681
00685 void signalResourceDeleted( ResourceCalendar *resource );
00686
00690 void signalErrorMessage( const QString &err );
00691
00692 protected:
00693 void connectResource( ResourceCalendar *resource );
00694 void resourceModified( ResourceCalendar *resource );
00695 void resourceDeleted( ResourceCalendar *resource );
00696
00709 virtual void doSetTimeZoneId( const QString &timeZoneId );
00710
00718 int incrementChangeCount( ResourceCalendar *resource );
00719
00727 int decrementChangeCount( ResourceCalendar *resource );
00728
00729 protected slots:
00730 void slotLoadError( ResourceCalendar *resource, const QString &err );
00731 void slotSaveError( ResourceCalendar *resource, const QString &err );
00732
00733 private:
00737 void init( const QString &family );
00738
00739 bool mOpen;
00740
00741 KRES::Manager<ResourceCalendar>* mManager;
00742 QMap <Incidence*, ResourceCalendar*> mResourceMap;
00743
00744 DestinationPolicy *mDestinationPolicy;
00745 StandardDestinationPolicy *mStandardPolicy;
00746 AskDestinationPolicy *mAskPolicy;
00747 bool mPendingDeleteFromResourceMap;
00748
00749 QMap<ResourceCalendar *, Ticket *> mTickets;
00750 QMap<ResourceCalendar *, int> mChangeCounts;
00751
00752 class Private;
00753 Private *d;
00754 };
00755
00756 }
00757
00758 #endif
|