libkcal

resourcecalendar.h

00001 /*
00002     This file is part of libkcal.
00003 
00004     Copyright (c) 1998 Preston Brown <pbrown@kde.org>
00005     Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
00006     Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
00007     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022     Boston, MA 02110-1301, USA.
00023 */
00024 
00025 #ifndef KCAL_RESOURCECALENDAR_H
00026 #define KCAL_RESOURCECALENDAR_H
00027 
00028 #include <qstring.h>
00029 #include <qdatetime.h>
00030 #include <qptrlist.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 
00040 #include <kresources/resource.h>
00041 #include <kresources/manager.h>
00042 #include <kabc/lock.h>
00043 #include <kdepimmacros.h>
00044 
00045 namespace KCal {
00046 
00047 class CalFormat;
00048 
00056 class LIBKCAL_EXPORT ResourceCalendar : public KRES::Resource
00057 {
00058     Q_OBJECT
00059   public:
00060     ResourceCalendar( const KConfig * );
00061     virtual ~ResourceCalendar();
00062 
00063     void setResolveConflict( bool b);
00064 
00065     virtual void writeConfig( KConfig* config );
00066 
00071     virtual QString infoText() const;
00072 
00092     bool load();
00093 
00111     bool save( Incidence *incidence = 0 );
00112 
00117     virtual bool isSaving() { return false; }
00118 
00122     virtual KABC::Lock *lock() = 0;
00123 
00127     virtual bool addIncidence( Incidence * );
00128 
00132     virtual bool deleteIncidence( Incidence * );
00133 
00138     Incidence *incidence( const QString &uid );
00139 
00143     virtual bool addEvent( Event *event ) = 0;
00144 
00148     virtual bool deleteEvent( Event * ) = 0;
00149 
00153     virtual Event *event( const QString &uid ) = 0;
00154 
00159     virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00160 
00165     virtual Event::List rawEventsForDate( const QDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00166 
00170     virtual Event::List rawEventsForDate( const QDateTime &qdt ) = 0;
00171 
00176     virtual Event::List rawEvents( const QDate &start, const QDate &end,
00177                                    bool inclusive = false ) = 0;
00178 
00198     virtual bool setValue( const QString &key, const QString &value );
00199 
00200   signals:
00207     void resourceChanged( ResourceCalendar * );
00208 
00213     void resourceLoaded( ResourceCalendar * );
00218     void resourceSaved( ResourceCalendar * );
00219 
00223     void resourceLoadError( ResourceCalendar *, const QString &error );
00227     void resourceSaveError( ResourceCalendar *, const QString &error );
00228 
00232     void signalSubresourceAdded( ResourceCalendar *, const QString& type,
00233                                  const QString& subresource, const QString& label );
00234 
00238     void signalSubresourceRemoved( ResourceCalendar *, const QString &,
00239                                    const QString & );
00240 
00241   public:
00245     virtual bool addTodo( Todo *todo ) = 0;
00249     virtual bool deleteTodo( Todo * ) = 0;
00255     virtual Todo *todo( const QString &uid ) = 0;
00259     virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00263     virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00264 
00265 
00269     virtual bool addJournal( Journal * ) = 0;
00270 
00274     virtual bool deleteJournal( Journal * ) = 0;
00275 
00279     virtual Journal *journal( const QString &uid ) = 0;
00283     virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00287     virtual Journal::List rawJournalsForDate( const QDate &date ) = 0;
00288 
00292     virtual Alarm::List alarms( const QDateTime &from,
00293                                 const QDateTime &to ) = 0;
00294 
00298     virtual Alarm::List alarmsTo( const QDateTime &to ) = 0;
00299 
00300 
00302     Incidence::List rawIncidences();
00303 
00307     virtual void setTimeZoneId( const QString &timeZoneId ) = 0;
00308 
00314     virtual QStringList subresources() const { return QStringList(); }
00315 
00319     virtual bool subresourceActive( const QString& ) const { return true; }
00320 
00324     virtual const QString labelForSubresource( const QString& resource ) const
00325     {
00326        // the resource identifier is a sane fallback
00327        return resource;
00328     };
00329 
00336     virtual QString subresourceIdentifier( Incidence *incidence ) 
00337     { Q_UNUSED( incidence ); return QString(); }
00338 
00339   public slots:
00343     virtual void setSubresourceActive( const QString &, bool active );
00344 
00345   protected:
00346 
00347     bool mResolveConflict;
00351     virtual bool doLoad() = 0;
00355     virtual bool doSave() = 0;
00356 
00361     virtual bool doSave( Incidence * );
00362 
00366     virtual void addInfoText( QString & ) const {};
00367 
00371     void loadError( const QString &errorMessage = QString::null );
00375     void saveError( const QString &errorMessage = QString::null );
00376 
00377   private:
00378     bool mReceivedLoadError;
00379     bool mReceivedSaveError;
00380 
00381     class Private;
00382     Private *d;
00383 };
00384 
00385 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00386 
00387 }
00388 
00389 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys