Diffstat (limited to 'microkde/kresources/manager.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/manager.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h index 69062da..88705d4 100644 --- a/microkde/kresources/manager.h +++ b/microkde/kresources/manager.h | |||
@@ -3,66 +3,68 @@ | |||
3 | 3 | ||
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 | Copyright (c) 2004 Ulf Schenk |
8 | 8 | ||
9 | This library is free software; you can redistribute it and/or | 9 | This library is free software; you can redistribute it and/or |
10 | modify it under the terms of the GNU Library General Public | 10 | modify it under the terms of the GNU Library General Public |
11 | License as published by the Free Software Foundation; either | 11 | License as published by the Free Software Foundation; either |
12 | version 2 of the License, or (at your option) any later version. | 12 | version 2 of the License, or (at your option) any later version. |
13 | 13 | ||
14 | This library is distributed in the hope that it will be useful, | 14 | This library is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | Library General Public License for more details. | 17 | Library General Public License for more details. |
18 | 18 | ||
19 | You should have received a copy of the GNU Library General Public License | 19 | You should have received a copy of the GNU Library General Public License |
20 | along with this library; see the file COPYING.LIB. If not, write to | 20 | along with this library; see the file COPYING.LIB. If not, write to |
21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. | 22 | Boston, MA 02111-1307, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | /* | 25 | /* |
26 | Enhanced Version of the file for platform independent KDE tools. | 26 | Enhanced Version of the file for platform independent KDE tools. |
27 | Copyright (c) 2004 Ulf Schenk | 27 | Copyright (c) 2004 Ulf Schenk |
28 | 28 | ||
29 | $Id$ | 29 | $Id$ |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef KRESOURCES_MANAGER_H | 32 | #ifndef KRESOURCES_MANAGER_H |
33 | #define KRESOURCES_MANAGER_H | 33 | #define KRESOURCES_MANAGER_H |
34 | 34 | ||
35 | #include <qdict.h> | 35 | #include <q3dict.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | //Added by qt3to4: | ||
38 | #include <Q3PtrList> | ||
37 | 39 | ||
38 | #include "factory.h" | 40 | #include "factory.h" |
39 | #include "managerimpl.h" | 41 | #include "managerimpl.h" |
40 | 42 | ||
41 | namespace KRES { | 43 | namespace KRES { |
42 | 44 | ||
43 | class Resource; | 45 | class Resource; |
44 | 46 | ||
45 | template<class T> | 47 | template<class T> |
46 | class ManagerListener | 48 | class ManagerListener |
47 | { | 49 | { |
48 | public: | 50 | public: |
49 | virtual void resourceAdded( T *resource ) = 0; | 51 | virtual void resourceAdded( T *resource ) = 0; |
50 | virtual void resourceModified( T *resource ) = 0; | 52 | virtual void resourceModified( T *resource ) = 0; |
51 | virtual void resourceDeleted( T *resource ) = 0; | 53 | virtual void resourceDeleted( T *resource ) = 0; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | // TODO: | 56 | // TODO: |
55 | // The resource manager should provide some signals | 57 | // The resource manager should provide some signals |
56 | // to warn applications that resources have been added, | 58 | // to warn applications that resources have been added, |
57 | // removed or modified. | 59 | // removed or modified. |
58 | // | 60 | // |
59 | // The manager should also keep track of which (or at least | 61 | // The manager should also keep track of which (or at least |
60 | // how many) applications hve opened a resource, so that it | 62 | // how many) applications hve opened a resource, so that it |
61 | // is only closed if none of them is using it any more | 63 | // is only closed if none of them is using it any more |
62 | 64 | ||
63 | template<class T> | 65 | template<class T> |
64 | class Manager : private ManagerImplListener | 66 | class Manager : private ManagerImplListener |
65 | { | 67 | { |
66 | public: | 68 | public: |
67 | class Iterator | 69 | class Iterator |
68 | { | 70 | { |
@@ -146,65 +148,65 @@ class Manager : private ManagerImplListener | |||
146 | Resource::List *mList; | 148 | Resource::List *mList; |
147 | }; | 149 | }; |
148 | 150 | ||
149 | ActiveIterator activeBegin() | 151 | ActiveIterator activeBegin() |
150 | { | 152 | { |
151 | ActiveIterator it; | 153 | ActiveIterator it; |
152 | it.mIt = mImpl->resourceList()->begin(); | 154 | it.mIt = mImpl->resourceList()->begin(); |
153 | it.mList = mImpl->resourceList(); | 155 | it.mList = mImpl->resourceList(); |
154 | if ( it.mIt != mImpl->resourceList()->end() ) { | 156 | if ( it.mIt != mImpl->resourceList()->end() ) { |
155 | if ( !(*it)->isActive() ) it++; | 157 | if ( !(*it)->isActive() ) it++; |
156 | } | 158 | } |
157 | return it; | 159 | return it; |
158 | } | 160 | } |
159 | 161 | ||
160 | ActiveIterator activeEnd() | 162 | ActiveIterator activeEnd() |
161 | { | 163 | { |
162 | ActiveIterator it; | 164 | ActiveIterator it; |
163 | it.mIt = mImpl->resourceList()->end(); | 165 | it.mIt = mImpl->resourceList()->end(); |
164 | it.mList = mImpl->resourceList(); | 166 | it.mList = mImpl->resourceList(); |
165 | return it; | 167 | return it; |
166 | } | 168 | } |
167 | 169 | ||
168 | bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } | 170 | bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } |
169 | 171 | ||
170 | Manager( const QString &family ) | 172 | Manager( const QString &family ) |
171 | { | 173 | { |
172 | mFactory = Factory::self( family ); | 174 | mFactory = Factory::self( family ); |
173 | // The managerimpl will use the same Factory object as the manager | 175 | // The managerimpl will use the same Factory object as the manager |
174 | // because of the Factory::self() pattern | 176 | // because of the Factory::self() pattern |
175 | mImpl = new ManagerImpl( family ); | 177 | mImpl = new ManagerImpl( family ); |
176 | mImpl->setListener( this ); | 178 | mImpl->setListener( this ); |
177 | 179 | ||
178 | mListeners = new QPtrList<ManagerListener<T> >; | 180 | mListeners = new Q3PtrList<ManagerListener<T> >; |
179 | } | 181 | } |
180 | 182 | ||
181 | virtual ~Manager() | 183 | virtual ~Manager() |
182 | { | 184 | { |
183 | mImpl->setListener( 0 ); | 185 | mImpl->setListener( 0 ); |
184 | delete mListeners; | 186 | delete mListeners; |
185 | delete mImpl; | 187 | delete mImpl; |
186 | } | 188 | } |
187 | 189 | ||
188 | /** | 190 | /** |
189 | Recreate Resource objects from configuration file. If cfg is 0, read standard | 191 | Recreate Resource objects from configuration file. If cfg is 0, read standard |
190 | configuration file. | 192 | configuration file. |
191 | */ | 193 | */ |
192 | void readConfig( KConfig *cfg = 0 ) | 194 | void readConfig( KConfig *cfg = 0 ) |
193 | { | 195 | { |
194 | mImpl->readConfig( cfg ); | 196 | mImpl->readConfig( cfg ); |
195 | } | 197 | } |
196 | 198 | ||
197 | /** | 199 | /** |
198 | Write configuration of Resource objects to configuration file. If cfg is 0, write | 200 | Write configuration of Resource objects to configuration file. If cfg is 0, write |
199 | to standard configuration file. | 201 | to standard configuration file. |
200 | */ | 202 | */ |
201 | void writeConfig( KConfig *cfg = 0 ) | 203 | void writeConfig( KConfig *cfg = 0 ) |
202 | { | 204 | { |
203 | mImpl->writeConfig( cfg ); | 205 | mImpl->writeConfig( cfg ); |
204 | } | 206 | } |
205 | 207 | ||
206 | /** | 208 | /** |
207 | Add resource to manager. This passes ownership of the Resource object | 209 | Add resource to manager. This passes ownership of the Resource object |
208 | to the manager. | 210 | to the manager. |
209 | */ | 211 | */ |
210 | void add( Resource *resource ) | 212 | void add( Resource *resource ) |
@@ -301,38 +303,38 @@ class Manager : private ManagerImplListener | |||
301 | } | 303 | } |
302 | 304 | ||
303 | virtual void resourceAdded( Resource *res ) | 305 | virtual void resourceAdded( Resource *res ) |
304 | { | 306 | { |
305 | T* resource = (T *)( res ); | 307 | T* resource = (T *)( res ); |
306 | ManagerListener<T> *listener; | 308 | ManagerListener<T> *listener; |
307 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) | 309 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) |
308 | listener->resourceAdded( resource ); | 310 | listener->resourceAdded( resource ); |
309 | } | 311 | } |
310 | 312 | ||
311 | virtual void resourceModified( Resource *res ) | 313 | virtual void resourceModified( Resource *res ) |
312 | { | 314 | { |
313 | 315 | ||
314 | T* resource = (T *)( res ); | 316 | T* resource = (T *)( res ); |
315 | ManagerListener<T> *listener; | 317 | ManagerListener<T> *listener; |
316 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) | 318 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) |
317 | listener->resourceModified( resource ); | 319 | listener->resourceModified( resource ); |
318 | } | 320 | } |
319 | 321 | ||
320 | virtual void resourceDeleted( Resource *res ) | 322 | virtual void resourceDeleted( Resource *res ) |
321 | { | 323 | { |
322 | 324 | ||
323 | T* resource = (T *)( res ); | 325 | T* resource = (T *)( res ); |
324 | ManagerListener<T> *listener; | 326 | ManagerListener<T> *listener; |
325 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) { | 327 | for ( listener = mListeners->first(); listener; listener = mListeners->next() ) { |
326 | listener->resourceDeleted( resource ); | 328 | listener->resourceDeleted( resource ); |
327 | } | 329 | } |
328 | } | 330 | } |
329 | 331 | ||
330 | private: | 332 | private: |
331 | ManagerImpl *mImpl; | 333 | ManagerImpl *mImpl; |
332 | Factory *mFactory; | 334 | Factory *mFactory; |
333 | QPtrList<ManagerListener<T> > *mListeners; | 335 | Q3PtrList<ManagerListener<T> > *mListeners; |
334 | }; | 336 | }; |
335 | 337 | ||
336 | } | 338 | } |
337 | 339 | ||
338 | #endif | 340 | #endif |