summaryrefslogtreecommitdiffabout
path: root/microkde/kresources/manager.h
Unidiff
Diffstat (limited to 'microkde/kresources/manager.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/manager.h8
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
@@ -11,50 +11,52 @@
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/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (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
41namespace KRES { 43namespace KRES {
42 44
43class Resource; 45class Resource;
44 46
45template<class T> 47template<class T>
46class ManagerListener 48class 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
@@ -154,49 +156,49 @@ class Manager : private ManagerImplListener
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 {
@@ -309,30 +311,30 @@ class Manager : private ManagerImplListener
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