libkcal Library API Documentation

calendarresources.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 #ifndef KCAL_CALENDARRESOURCES_H
00022 #define KCAL_CALENDARRESOURCES_H
00023 
00024 #include <qintdict.h>
00025 #include <qmap.h>
00026 
00027 #include "calendar.h"
00028 #include "resourcecalendar.h"
00029 
00030 #include <kresources/manager.h>
00031 
00032 class QWidget;
00033 
00034 namespace KCal {
00035 
00036 class CalFormat;
00037 
00041 class CalendarResources : public Calendar,
00042                           public KRES::ManagerObserver<ResourceCalendar>
00043 {
00044     Q_OBJECT
00045   public:
00046     class DestinationPolicy
00047     {
00048       public:
00049         DestinationPolicy( CalendarResourceManager *manager )
00050           : mManager( manager ) {}
00051 
00052         virtual ResourceCalendar *destination( Incidence * ) = 0;
00053 
00054       protected:
00055         CalendarResourceManager *resourceManager() { return mManager; }
00056 
00057       private:
00058         CalendarResourceManager *mManager;
00059     };
00060 
00061     class StandardDestinationPolicy : public DestinationPolicy
00062     {
00063       public:
00064         StandardDestinationPolicy( CalendarResourceManager *manager )
00065           : DestinationPolicy( manager ) {}
00066 
00067         ResourceCalendar *destination( Incidence * );
00068 
00069       private:
00070         class Private;
00071         Private *d;
00072     };
00073 
00074     class AskDestinationPolicy : public DestinationPolicy
00075     {
00076       public:
00077         AskDestinationPolicy( CalendarResourceManager *manager,
00078                               QWidget *parent = 0 )
00079           : DestinationPolicy( manager ), mParent( parent ) {}
00080 
00081         ResourceCalendar *destination( Incidence * );
00082 
00083       private:
00084         QWidget *mParent;
00085 
00086         class Private;
00087         Private *d;
00088     };
00089 
00090     class Ticket
00091     {
00092         friend class CalendarResources;
00093       public:
00094         ResourceCalendar *resource() const { return mResource; }
00095         
00096       private:
00097         Ticket( ResourceCalendar *r ) : mResource( r ) {}
00098     
00099         ResourceCalendar *mResource;
00100 
00101         class Private;
00102         Private *d;
00103     };
00104 
00106     CalendarResources();
00108     CalendarResources( const QString &timeZoneId );
00109     ~CalendarResources();
00110 
00119     void readConfig( KConfig *config = 0 );
00120 
00125     void load();
00126 
00130     CalendarResourceManager *resourceManager() const
00131     {
00132       return mManager;
00133     }
00134 
00138     void setStandardDestinationPolicy();
00142     void setAskDestinationPolicy();
00143 
00145     void close();
00146 
00152     Ticket *requestSaveTicket( ResourceCalendar * );
00158     virtual bool save( Ticket * );
00162     virtual void releaseSaveTicket( Ticket *ticket );
00163 
00164     void save();
00165 
00166     bool isSaving();
00167 
00168     bool addIncidence( Incidence * );
00169 
00171     bool addEvent(Event *anEvent);
00173     bool addEvent(Event *anEvent, ResourceCalendar *resource);
00175     void deleteEvent(Event *);
00176 
00180     Event *event(const QString &UniqueStr);
00184 //    Event::List events();
00188     Event::List rawEvents();
00189 
00190     /*
00191       Returns a QString with the text of the holiday (if any) that falls
00192       on the specified date.
00193     */
00194     QString getHolidayForDate(const QDate &qd);
00195 
00199     bool addTodo( Todo *todo );
00201     bool addTodo(Todo *todo, ResourceCalendar *resource);
00205     void deleteTodo( Todo * );
00210     Todo *todo( const QString &uid );
00214     Todo::List rawTodos();
00218     Todo::List rawTodosForDate( const QDate &date );
00219 
00221     bool addJournal(Journal *);
00223     void deleteJournal( Journal * );
00225     bool addJournal(Journal *journal, ResourceCalendar *resource);
00227     Journal *journal(const QDate &);
00229     Journal *journal(const QString &UID);
00231     Journal::List journals();
00232 
00234     Alarm::List alarms( const QDateTime &from, const QDateTime &to );
00235 
00237     Alarm::List alarmsTo( const QDateTime &to );
00238 
00240     ResourceCalendar *resource(Incidence *);
00241 
00242     bool beginChange( Incidence * );
00243     bool endChange( Incidence * );
00244 
00245   signals:
00246     void signalResourceAdded( ResourceCalendar * );
00247     void signalResourceModified( ResourceCalendar * );
00248     void signalResourceDeleted( ResourceCalendar * );
00249 
00250     void signalErrorMessage( const QString & );
00251 
00252   protected:
00256     void incidenceUpdated( IncidenceBase * );
00257 
00258   public:
00263     Event::List rawEventsForDate( const QDate &date, bool sorted = false );
00267     Event::List rawEventsForDate( const QDateTime &qdt );
00272     Event::List rawEvents( const QDate &start, const QDate &end,
00273                            bool inclusive = false );
00274 
00275   protected:
00276     void connectResource( ResourceCalendar * );
00277 
00278     void resourceAdded( ResourceCalendar *resource );
00279     void resourceModified( ResourceCalendar *resource );
00280     void resourceDeleted( ResourceCalendar *resource );
00281 
00282     virtual void doSetTimeZoneId( const QString& tzid );
00283 
00284     int incrementChangeCount( ResourceCalendar * );
00285     int decrementChangeCount( ResourceCalendar * );
00286 
00287   protected slots:
00288     void slotLoadError( ResourceCalendar *r, const QString &err );
00289     void slotSaveError( ResourceCalendar *r, const QString &err );
00290 
00291   private:
00292     void init();
00293 
00294     bool mOpen;
00295 
00296     KRES::Manager<ResourceCalendar>* mManager;
00297     QMap <Incidence*, ResourceCalendar*> mResourceMap;
00298 
00299     DestinationPolicy *mDestinationPolicy;
00300     StandardDestinationPolicy *mStandardPolicy;
00301     AskDestinationPolicy *mAskPolicy;
00302 
00303     QMap<ResourceCalendar *, Ticket *> mTickets;
00304     QMap<ResourceCalendar *, int> mChangeCounts;
00305 
00306     class Private;
00307     Private *d;
00308 };
00309 
00310 }
00311 
00312 #endif
KDE Logo
This file is part of the documentation for libkcal Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:38:35 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003