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 
00128     KDE_DEPRECATED virtual bool addIncidence( Incidence * );
00129 
00133     virtual bool addIncidence( Incidence *, const QString &subresource );
00134 
00138     virtual bool deleteIncidence( Incidence * );
00139 
00144     Incidence *incidence( const QString &uid );
00145 
00150     KDE_DEPRECATED virtual bool addEvent( Event *event ) = 0;
00151     virtual bool addEvent( Event *event, const QString &subresource ) = 0;
00152 
00156     virtual bool deleteEvent( Event * ) = 0;
00157 
00161     virtual Event *event( const QString &uid ) = 0;
00162 
00167     virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00168 
00173     virtual Event::List rawEventsForDate( const QDate &date, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00174 
00178     virtual Event::List rawEventsForDate( const QDateTime &qdt ) = 0;
00179 
00184     virtual Event::List rawEvents( const QDate &start, const QDate &end,
00185                                    bool inclusive = false ) = 0;
00186 
00206     virtual bool setValue( const QString &key, const QString &value );
00207 
00208   signals:
00215     void resourceChanged( ResourceCalendar * );
00216 
00221     void resourceLoaded( ResourceCalendar * );
00226     void resourceSaved( ResourceCalendar * );
00227 
00231     void resourceLoadError( ResourceCalendar *, const QString &error );
00235     void resourceSaveError( ResourceCalendar *, const QString &error );
00236 
00240     void signalSubresourceAdded( ResourceCalendar *, const QString& type,
00241                                  const QString& subresource, const QString& label );
00242 
00246     void signalSubresourceRemoved( ResourceCalendar *, const QString &,
00247                                    const QString & );
00248 
00249   public:
00254     KDE_DEPRECATED virtual bool addTodo( Todo *todo ) = 0;
00255     virtual bool addTodo( Todo *todo,  const QString &subresource ) = 0;
00256 
00260     virtual bool deleteTodo( Todo * ) = 0;
00266     virtual Todo *todo( const QString &uid ) = 0;
00270     virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00274     virtual Todo::List rawTodosForDate( const QDate &date ) = 0;
00275 
00276 
00281     KDE_DEPRECATED virtual bool addJournal( Journal * ) = 0;
00282     virtual bool addJournal( Journal *journal, const QString &subresource ) = 0;
00283 
00287     virtual bool deleteJournal( Journal * ) = 0;
00288 
00292     virtual Journal *journal( const QString &uid ) = 0;
00296     virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending ) = 0;
00300     virtual Journal::List rawJournalsForDate( const QDate &date ) = 0;
00301 
00305     virtual Alarm::List alarms( const QDateTime &from,
00306                                 const QDateTime &to ) = 0;
00307 
00311     virtual Alarm::List alarmsTo( const QDateTime &to ) = 0;
00312 
00313 
00315     Incidence::List rawIncidences();
00316 
00320     virtual void setTimeZoneId( const QString &timeZoneId ) = 0;
00321 
00327     virtual QStringList subresources() const { return QStringList(); }
00328 
00332     virtual bool canHaveSubresources() const { return false; }
00333 
00337     virtual bool subresourceActive( const QString& ) const { return true; }
00338 
00342     virtual bool subresourceWritable( const QString& ) const;
00343 
00347     virtual const QString labelForSubresource( const QString& resource ) const
00348     {
00349        // the resource identifier is a sane fallback
00350        return resource;
00351     };
00352 
00359     virtual QString subresourceIdentifier( Incidence *incidence )
00360     { Q_UNUSED( incidence ); return QString(); }
00361 
00362 
00363 
00367     virtual bool removeSubresource( const QString& resource );
00368 
00373     virtual bool addSubresource( const QString& resource, const QString& parent );
00374 
00379     virtual QString subresourceType( const QString &resource );
00380 
00381   public slots:
00385     virtual void setSubresourceActive( const QString &, bool active );
00386 
00387   protected:
00388 
00389     bool mResolveConflict;
00393     virtual bool doLoad() = 0;
00397     virtual bool doSave() = 0;
00398 
00403     virtual bool doSave( Incidence * );
00404 
00408     virtual void addInfoText( QString & ) const {};
00409 
00413     void loadError( const QString &errorMessage = QString::null );
00417     void saveError( const QString &errorMessage = QString::null );
00418 
00419   private:
00420     bool mReceivedLoadError;
00421     bool mReceivedSaveError;
00422 
00423     class Private;
00424     Private *d;
00425 };
00426 
00427 typedef KRES::Manager<ResourceCalendar> CalendarResourceManager;
00428 
00429 }
00430 
00431 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys