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         virtual ~DestinationPolicy() { }
00052 
00053         virtual ResourceCalendar *destination( Incidence * ) = 0;
00054 
00055       protected:
00056         CalendarResourceManager *resourceManager() { return mManager; }
00057 
00058       private:
00059         CalendarResourceManager *mManager;
00060     };
00061 
00062     class StandardDestinationPolicy : public DestinationPolicy
00063     {
00064       public:
00065         StandardDestinationPolicy( CalendarResourceManager *manager )
00066           : DestinationPolicy( manager ) {}
00067 
00068         ResourceCalendar *destination( Incidence * );
00069 
00070       private:
00071         class Private;
00072         Private *d;
00073     };
00074 
00075     class AskDestinationPolicy : public DestinationPolicy
00076     {
00077       public:
00078         AskDestinationPolicy( CalendarResourceManager *manager,
00079                               QWidget *parent = 0 )
00080           : DestinationPolicy( manager ), mParent( parent ) {}
00081 
00082         ResourceCalendar *destination( Incidence * );
00083 
00084       private:
00085         QWidget *mParent;
00086 
00087         class Private;
00088         Private *d;
00089     };
00090 
00091     class Ticket
00092     {
00093         friend class CalendarResources;
00094       public:
00095         ResourceCalendar *resource() const { return mResource; }
00096         
00097       private:
00098         Ticket( ResourceCalendar *r ) : mResource( r ) {}
00099     
00100         ResourceCalendar *mResource;
00101 
00102         class Private;
00103         Private *d;
00104     };
00105 
00107     CalendarResources();
00109     CalendarResources( const QString &timeZoneId );
00110     ~CalendarResources();
00111 
00120     void readConfig( KConfig *config = 0 );
00121 
00126     void load();
00127 
00131     CalendarResourceManager *resourceManager() const
00132     {
00133       return mManager;
00134     }
00135 
00139     void setStandardDestinationPolicy();
00143     void setAskDestinationPolicy();
00144 
00146     void close();
00147 
00153     Ticket *requestSaveTicket( ResourceCalendar * );
00159     virtual bool save( Ticket * );
00163     virtual void releaseSaveTicket( Ticket *ticket );
00164 
00165     void save();
00166 
00167     bool isSaving();
00168 
00169     bool addIncidence( Incidence * );
00170 
00172     bool addEvent(Event *anEvent);
00174     bool addEvent(Event *anEvent, ResourceCalendar *resource);
00176     void deleteEvent(Event *);
00177 
00181     Event *event(const QString &UniqueStr);
00185 //    Event::List events();
00189     Event::List rawEvents();
00190 
00191     /*
00192       Returns a QString with the text of the holiday (if any) that falls
00193       on the specified date.
00194     */
00195     QString getHolidayForDate(const QDate &qd);
00196 
00200     bool addTodo( Todo *todo );
00202     bool addTodo(Todo *todo, ResourceCalendar *resource);
00206     void deleteTodo( Todo * );
00211     Todo *todo( const QString &uid );
00215     Todo::List rawTodos();
00219     Todo::List rawTodosForDate( const QDate &date );
00220 
00222     bool addJournal(Journal *);
00224     void deleteJournal( Journal * );
00226     bool addJournal(Journal *journal, ResourceCalendar *resource);
00228     Journal *journal(const QDate &);
00230     Journal *journal(const QString &UID);
00232     Journal::List journals();
00233 
00235     Alarm::List alarms( const QDateTime &from, const QDateTime &to );
00236 
00238     Alarm::List alarmsTo( const QDateTime &to );
00239 
00241     ResourceCalendar *resource(Incidence *);
00242 
00243     bool beginChange( Incidence * );
00244     bool endChange( Incidence * );
00245 
00246   signals:
00247     void signalResourceAdded( ResourceCalendar * );
00248     void signalResourceModified( ResourceCalendar * );
00249     void signalResourceDeleted( ResourceCalendar * );
00250 
00251     void signalErrorMessage( const QString & );
00252 
00253   protected:
00257     void incidenceUpdated( IncidenceBase * );
00258 
00259   public:
00264     Event::List rawEventsForDate( const QDate &date, bool sorted = false );
00268     Event::List rawEventsForDate( const QDateTime &qdt );
00273     Event::List rawEvents( const QDate &start, const QDate &end,
00274                            bool inclusive = false );
00275 
00276   protected:
00277     void connectResource( ResourceCalendar * );
00278 
00279     void resourceAdded( ResourceCalendar *resource );
00280     void resourceModified( ResourceCalendar *resource );
00281     void resourceDeleted( ResourceCalendar *resource );
00282 
00283     virtual void doSetTimeZoneId( const QString& tzid );
00284 
00285     int incrementChangeCount( ResourceCalendar * );
00286     int decrementChangeCount( ResourceCalendar * );
00287 
00288   protected slots:
00289     void slotLoadError( ResourceCalendar *r, const QString &err );
00290     void slotSaveError( ResourceCalendar *r, const QString &err );
00291 
00292   private:
00293     void init();
00294 
00295     bool mOpen;
00296 
00297     KRES::Manager<ResourceCalendar>* mManager;
00298     QMap <Incidence*, ResourceCalendar*> mResourceMap;
00299 
00300     DestinationPolicy *mDestinationPolicy;
00301     StandardDestinationPolicy *mStandardPolicy;
00302     AskDestinationPolicy *mAskPolicy;
00303 
00304     QMap<ResourceCalendar *, Ticket *> mTickets;
00305     QMap<ResourceCalendar *, int> mChangeCounts;
00306 
00307     class Private;
00308     Private *d;
00309 };
00310 
00311 }
00312 
00313 #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 Thu Aug 2 09:52:29 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003