author | ulf69 <ulf69> | 2004-08-02 18:12:49 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:12:49 (UTC) |
commit | b4203356adb6008a4b4e6782afdae7dd34178697 (patch) (unidiff) | |
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 | |||
@@ -4,6 +4,7 @@ | |||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | Copyright (c) 2004 Ulf Schenk | ||
7 | 8 | ||
8 | This library is free software; you can redistribute it and/or | 9 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 10 | modify it under the terms of the GNU Library General Public |
@@ -21,6 +22,13 @@ | |||
21 | Boston, MA 02111-1307, USA. | 22 | Boston, MA 02111-1307, USA. |
22 | */ | 23 | */ |
23 | 24 | ||
25 | /* | ||
26 | Enhanced Version of the file for platform independent KDE tools. | ||
27 | Copyright (c) 2004 Ulf Schenk | ||
28 | |||
29 | $Id$ | ||
30 | */ | ||
31 | |||
24 | #ifndef KRESOURCES_MANAGER_H | 32 | #ifndef KRESOURCES_MANAGER_H |
25 | #define KRESOURCES_MANAGER_H | 33 | #define KRESOURCES_MANAGER_H |
26 | 34 | ||
@@ -48,7 +56,7 @@ class ManagerListener | |||
48 | // to warn applications that resources have been added, | 56 | // to warn applications that resources have been added, |
49 | // removed or modified. | 57 | // removed or modified. |
50 | // | 58 | // |
51 | // The manager should also keep track of which (or at least | 59 | // The manager should also keep track of which (or at least |
52 | // how many) applications hve opened a resource, so that it | 60 | // how many) applications hve opened a resource, so that it |
53 | // is only closed if none of them is using it any more | 61 | // is only closed if none of them is using it any more |
54 | 62 | ||
@@ -71,7 +79,7 @@ class Manager : private ManagerImplListener | |||
71 | bool operator==( const Iterator &it ) { return mIt == it.mIt; } | 79 | bool operator==( const Iterator &it ) { return mIt == it.mIt; } |
72 | bool operator!=( const Iterator &it ) { return mIt != it.mIt; } | 80 | bool operator!=( const Iterator &it ) { return mIt != it.mIt; } |
73 | 81 | ||
74 | private: | 82 | private: |
75 | Resource::List::Iterator mIt; | 83 | Resource::List::Iterator mIt; |
76 | }; | 84 | }; |
77 | 85 | ||
@@ -81,7 +89,7 @@ class Manager : private ManagerImplListener | |||
81 | it.mIt = mImpl->resourceList()->begin(); | 89 | it.mIt = mImpl->resourceList()->begin(); |
82 | return it; | 90 | return it; |
83 | } | 91 | } |
84 | 92 | ||
85 | Iterator end() | 93 | Iterator end() |
86 | { | 94 | { |
87 | Iterator it; | 95 | Iterator it; |
@@ -159,19 +167,24 @@ class Manager : private ManagerImplListener | |||
159 | 167 | ||
160 | bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } | 168 | bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } |
161 | 169 | ||
162 | Manager( const QString &family ) | 170 | /** |
171 | Return true, if the manager manages syncable resources. | ||
172 | */ | ||
173 | bool manageSyncable() { return mImpl->manageSyncable(); } | ||
174 | |||
175 | Manager( const QString &family, bool syncable ) | ||
163 | { | 176 | { |
164 | mFactory = Factory::self( family ); | 177 | mFactory = Factory::self( family ); |
165 | // The managerimpl will use the same Factory object as the manager | 178 | // The managerimpl will use the same Factory object as the manager |
166 | // because of the Factory::self() pattern | 179 | // because of the Factory::self() pattern |
167 | mImpl = new ManagerImpl( family ); | 180 | mImpl = new ManagerImpl( family, syncable ); |
168 | mImpl->setListener( this ); | 181 | mImpl->setListener( this ); |
169 | 182 | ||
170 | mListeners = new QPtrList<ManagerListener<T> >; | 183 | mListeners = new QPtrList<ManagerListener<T> >; |
171 | } | 184 | } |
172 | 185 | ||
173 | virtual ~Manager() | 186 | virtual ~Manager() |
174 | { | 187 | { |
175 | mImpl->setListener( 0 ); | 188 | mImpl->setListener( 0 ); |
176 | delete mListeners; | 189 | delete mListeners; |
177 | delete mImpl; | 190 | delete mImpl; |
@@ -239,18 +252,19 @@ class Manager : private ManagerImplListener | |||
239 | } | 252 | } |
240 | 253 | ||
241 | /** | 254 | /** |
242 | Creates a new resource of type @param type, with default | 255 | Creates a new resource of type @param type, with default |
243 | settings. The resource is | 256 | settings. The resource is |
244 | not added to the manager, the application has to do that. | 257 | not added to the manager, the application has to do that. |
245 | Returns a pointer to a resource object or a null pointer | 258 | Returns a pointer to a resource object or a null pointer |
246 | if resource type doesn't exist. | 259 | if resource type doesn't exist. |
247 | 260 | ||
248 | @param type The type of the resource, one of those returned | 261 | @param type The type of the resource, one of those returned |
249 | by @ref resourceTypeNames() | 262 | by @ref resourceTypeNames() |
263 | * @param syncable If the resource should support syncing capabilities. | ||
250 | */ | 264 | */ |
251 | T *createResource( const QString& type ) | 265 | T *createResource( const QString& type ) |
252 | { | 266 | { |
253 | return (T *)( mFactory->resource( type, 0 ) ); | 267 | return (T *)( mFactory->resource( type, 0, mImpl->manageSyncable() ) ); |
254 | } | 268 | } |
255 | 269 | ||
256 | /** | 270 | /** |
@@ -278,8 +292,8 @@ class Manager : private ManagerImplListener | |||
278 | } | 292 | } |
279 | 293 | ||
280 | void resourceChanged( T *resource ) | 294 | void resourceChanged( T *resource ) |
281 | { | 295 | { |
282 | mImpl->resourceChanged( resource ); | 296 | mImpl->resourceChanged( resource ); |
283 | } | 297 | } |
284 | 298 | ||
285 | void addListener( ManagerListener<T> *listener ) | 299 | void addListener( ManagerListener<T> *listener ) |
@@ -309,7 +323,7 @@ class Manager : private ManagerImplListener | |||
309 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) | 323 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) |
310 | listener->resourceModified( resource ); | 324 | listener->resourceModified( resource ); |
311 | } | 325 | } |
312 | 326 | ||
313 | virtual void resourceDeleted( Resource *res ) | 327 | virtual void resourceDeleted( Resource *res ) |
314 | { | 328 | { |
315 | kdDebug(5650) << "Manager::resourceDeleted " << res->resourceName() << endl; | 329 | kdDebug(5650) << "Manager::resourceDeleted " << res->resourceName() << endl; |