libkdepim

kabcresourcecached.h

00001 /*
00002     This file is part of libkdepim.
00003     Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KABC_RESOURCECACHED_H
00022 #define KABC_RESOURCECACHED_H
00023 
00024 #include <kabc/resource.h>
00025 #include <kdepimmacros.h>
00026 
00027 #include "libemailfunctions/idmapper.h"
00028 
00029 namespace KABC {
00030 
00031 class KDE_EXPORT ResourceCached : public Resource
00032 {
00033   Q_OBJECT
00034 
00035   public:
00036     ResourceCached( const KConfig* );
00037     ~ResourceCached();
00038 
00042     virtual void writeConfig( KConfig *config );
00043 
00047     virtual void insertAddressee( const Addressee& );
00048 
00052     virtual void removeAddressee( const Addressee& addr );
00053 
00054     void loadCache();
00055     void saveCache();
00056     void cleanUpCache( const KABC::Addressee::List &list );
00057 
00061     KPIM::IdMapper& idMapper();
00062 
00063     bool hasChanges() const;
00064     void clearChanges();
00065     void clearChange( const KABC::Addressee& );
00066     void clearChange( const QString& );
00067 
00068     KABC::Addressee::List addedAddressees() const;
00069     KABC::Addressee::List changedAddressees() const;
00070     KABC::Addressee::List deletedAddressees() const;
00071 
00072   protected:
00073     virtual QString cacheFile() const;
00074 
00078     virtual QString changesCacheFile( const QString& ) const;
00079     void loadChangesCache( QMap<QString, KABC::Addressee>&, const QString& );
00080     void loadChangesCache();
00081     void saveChangesCache( const QMap<QString, KABC::Addressee>&, const QString& );
00082     void saveChangesCache();
00083 
00084     void setIdMapperIdentifier();
00085 
00086   private:
00087     KPIM::IdMapper mIdMapper;
00088 
00089     QMap<QString, KABC::Addressee> mAddedAddressees;
00090     QMap<QString, KABC::Addressee> mChangedAddressees;
00091     QMap<QString, KABC::Addressee> mDeletedAddressees;
00092 
00093     class ResourceCachedPrivate;
00094     ResourceCachedPrivate *d;
00095 };
00096 
00097 }
00098 
00099 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys