author | ulf69 <ulf69> | 2004-08-02 18:12:49 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:12:49 (UTC) |
commit | b4203356adb6008a4b4e6782afdae7dd34178697 (patch) (side-by-side diff) | |
tree | 13ec830c5748106467c2d610d65db5d1a2cf9263 /microkde/kresources/manager.h | |
parent | 09e8e7e5d4c3cafcf2b05511e5c78717fb5380e7 (diff) | |
download | kdepimpi-b4203356adb6008a4b4e6782afdae7dd34178697.zip kdepimpi-b4203356adb6008a4b4e6782afdae7dd34178697.tar.gz kdepimpi-b4203356adb6008a4b4e6782afdae7dd34178697.tar.bz2 |
added support for syncing of resources
Diffstat (limited to 'microkde/kresources/manager.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/manager.h | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h index b5e97fc..7e9e19a 100644 --- a/microkde/kresources/manager.h +++ b/microkde/kresources/manager.h @@ -1,12 +1,13 @@ /* This file is part of libkresources. Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2004 Ulf Schenk This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -18,12 +19,19 @@ You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #ifndef KRESOURCES_MANAGER_H #define KRESOURCES_MANAGER_H #include <qdict.h> #include <qstringlist.h> @@ -45,13 +53,13 @@ class ManagerListener // TODO: // The resource manager should provide some signals // to warn applications that resources have been added, // removed or modified. // -// The manager should also keep track of which (or at least +// The manager should also keep track of which (or at least // how many) applications hve opened a resource, so that it // is only closed if none of them is using it any more template<class T> class Manager : private ManagerImplListener { @@ -68,23 +76,23 @@ class Manager : private ManagerImplListener Iterator &operator++(int) { mIt++; return *this; } Iterator &operator--() { mIt--; return *this; } Iterator &operator--(int) { mIt--; return *this; } bool operator==( const Iterator &it ) { return mIt == it.mIt; } bool operator!=( const Iterator &it ) { return mIt != it.mIt; } - private: + private: Resource::List::Iterator mIt; }; Iterator begin() { Iterator it; it.mIt = mImpl->resourceList()->begin(); return it; } - + Iterator end() { Iterator it; it.mIt = mImpl->resourceList()->end(); return it; } @@ -156,25 +164,30 @@ class Manager : private ManagerImplListener it.mList = mImpl->resourceList(); return it; } bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } - Manager( const QString &family ) + /** + Return true, if the manager manages syncable resources. + */ + bool manageSyncable() { return mImpl->manageSyncable(); } + + Manager( const QString &family, bool syncable ) { mFactory = Factory::self( family ); // The managerimpl will use the same Factory object as the manager // because of the Factory::self() pattern - mImpl = new ManagerImpl( family ); + mImpl = new ManagerImpl( family, syncable ); mImpl->setListener( this ); - + mListeners = new QPtrList<ManagerListener<T> >; } virtual ~Manager() - { + { mImpl->setListener( 0 ); delete mListeners; delete mImpl; } /** @@ -236,24 +249,25 @@ class Manager : private ManagerImplListener ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ) { return mFactory->resourceConfigWidget( type, parent ); } /** - Creates a new resource of type @param type, with default - settings. The resource is + Creates a new resource of type @param type, with default + settings. The resource is not added to the manager, the application has to do that. Returns a pointer to a resource object or a null pointer if resource type doesn't exist. - - @param type The type of the resource, one of those returned + + @param type The type of the resource, one of those returned by @ref resourceTypeNames() + * @param syncable If the resource should support syncing capabilities. */ T *createResource( const QString& type ) { - return (T *)( mFactory->resource( type, 0 ) ); + return (T *)( mFactory->resource( type, 0, mImpl->manageSyncable() ) ); } /** Returns a list of the names of all available resource types. */ QStringList resourceTypeNames() const @@ -275,14 +289,14 @@ class Manager : private ManagerImplListener } return typeDescs; } void resourceChanged( T *resource ) - { - mImpl->resourceChanged( resource ); + { + mImpl->resourceChanged( resource ); } void addListener( ManagerListener<T> *listener ) { mListeners->append( listener ); } @@ -306,13 +320,13 @@ class Manager : private ManagerImplListener kdDebug(5650) << "Manager::resourceModified " << res->resourceName() << endl; T* resource = (T *)( res ); ManagerListener<T> *listener; for ( listener = mListeners->first(); listener; listener = mListeners->next() ) listener->resourceModified( resource ); } - + virtual void resourceDeleted( Resource *res ) { kdDebug(5650) << "Manager::resourceDeleted " << res->resourceName() << endl; T* resource = (T *)( res ); ManagerListener<T> *listener; for ( listener = mListeners->first(); listener; listener = mListeners->next() ) { |