libkcal Library API Documentation

resourcecalendar.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 1998 Preston Brown
00005     Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
00006     Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
00007 
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Library General Public
00010     License as published by the Free Software Foundation; either
00011     version 2 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Library General Public License for more details.
00017 
00018     You should have received a copy of the GNU Library General Public License
00019     along with this library; see the file COPYING.LIB.  If not, write to
00020     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021     Boston, MA 02111-1307, USA.
00022 */
00023 
00024 #ifndef KCAL_RESOURCECALENDAR_H
00025 #define KCAL_RESOURCECALENDAR_H
00026 
00027 #include <qstring.h>
00028 #include <qdatetime.h>
00029 #include <qptrlist.h>
00030 
00031 #include <kconfig.h>
00032 
00033 #include "alarm.h"
00034 #include "todo.h"
00035 #include "event.h"
00036 #include "journal.h"
00037 
00038 #include <kresources/resource.h>
00039 #include <kresources/manager.h>
00040 #include <kabc/lock.h>
00041 
00042 namespace KCal {
00043 
00044 class CalFormat;
00045 
00053 class ResourceCalendar : public KRES::Resource
00054 {
00055     Q_OBJECT
00056   public:
00057     ResourceCalendar( const KConfig * );
00058     virtual ~ResourceCalendar();
00059 
00060     void setResolveConflict( bool b);
00061 
00062     virtual void writeConfig( KConfig* config );
00063 
00068     virtual QString infoText() const;
00069 
00089     bool load();
00090 
00105     bool save();
00106 
00111     virtual bool isSaving() { return false; }
00112 
00116     virtual KABC::Lock *lock() = 0;
00117 
00121     virtual bool addIncidence( Incidence * );
00122 
00126     virtual bool addEvent( Event *event ) = 0;
00127 
00131     virtual void deleteEvent( Event * ) = 0;
00132 
00136     virtual Event *event( const QString &uid ) = 0;
00137 
00142     virtual Event::List rawEvents() = 0;
00143 
00148     virtual Event::List rawEventsForDate( const QDate &date,
00149                                           bool sorted = false ) = 0;
00150 
00154     virtual Event::List rawEventsForDate( const QDateTime &qdt ) = 0;
00155 
00160     virtual Event::List rawEvents( const QDate &start, const QDate &end,
00161                                    bool inclusive = false ) = 0;
00162 
00163   signals:
00170     void resourceChanged( ResourceCalendar * );
00171 
00176     void resourceLoaded( ResourceCalendar * );
00181     void resourceSaved( ResourceCalendar * );
00182 
00186     void resourceLoadError( ResourceCalendar *, const QString &error );
00190     void resourceSaveError( ResourceCalendar *, const QString &error );
00191 
00195     void signalSubresourceAdded( ResourceCalendar *, const QString& type,
00196                                  const QString& subresource, const QString& label );
00197 
00198     void signalSubresourceAdded( ResourceCalendar *, const QString& type,
00199                                  const QString& subresource );
00200 
00204     void signalSubresourceRemoved( ResourceCalendar *, const QString &,
00205                                    const QString & );
00206 
00207   public:
00211     virtual bool addTodo( Todo *todo ) = 0;
00215     virtual void deleteTodo( Todo * ) = 0;
00221     virtual Todo *todo( const QString &uid ) = 0;
00225     virtual Todo::List rawTodos() = 0;
00229     virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00230 
00231 
00235     virtual bool addJournal( Journal * ) = 0;
00236 
00240     virtual void deleteJournal( Journal * ) = 0;
00241 
00245     virtual Journal *journal( const QDate & ) = 0;
00246 
00250     virtual Journal *journal( const QString &uid ) = 0;
00251 
00255     virtual Journal::List journals() = 0;
00256 
00257 
00261     virtual Alarm::List alarms( const QDateTime &from,
00262                                 const QDateTime &to ) = 0;
00263 
00267     virtual Alarm::List alarmsTo( const QDateTime &to ) = 0;
00268 
00269 
00271     Incidence::List rawIncidences();
00272 
00276     virtual void setTimeZoneId( const QString &tzid ) = 0;
00277 
00283     virtual QStringList subresources() const { return QStringList(); }
00284 
00288     virtual bool canHaveSubresources() const { return false; }
00289 
00293     virtual bool subresourceActive( const QString& ) const { return true; }
00294     
00298     virtual const QString labelForSubresource( const QString& resource ) const
00299     {
00300        // the resource identifier is a sane fallback
00301        return resource;
00302     }
00303 
00310     virtual QString subresourceIdentifier( Incidence *incidence ) 
00311     { Q_UNUSED( incidence ); return QString(); }
00312 
00313 
00314 
00318     virtual bool removeSubresource( const QString& resource );
00319 
00324     virtual bool addSubresource( const QString& resource, const QString& parent );
00325 
00326   public slots:
00330     virtual void setSubresourceActive( const QString &, bool active );
00331 
00332   protected:
00333 
00334     bool mResolveConflict;
00338     virtual bool doLoad() = 0;
00342     virtual bool doSave() = 0;
00343 
00347     virtual void addInfoText( QString & ) const {};
00348 
00352     void loadError( const QString &errorMessage = QString::null );
00356     void saveError( const QString &errorMessage = QString::null );
00357 
00358   private:
00359     bool mReceivedLoadError;
00360     bool mReceivedSaveError;
00361 
00362     class Private;
00363     Private *d;
00364 };
00365 
00366 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00367 
00368 }
00369 
00370 #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 Oct 17 09:52:51 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003