summaryrefslogtreecommitdiffabout
path: root/microkde/kresources
Unidiff
Diffstat (limited to 'microkde/kresources') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kresources/managerimpl.h19
-rw-r--r--microkde/kresources/resource.cpp5
-rw-r--r--microkde/kresources/resource.h25
3 files changed, 39 insertions, 10 deletions
diff --git a/microkde/kresources/managerimpl.h b/microkde/kresources/managerimpl.h
index a049bcc..0425279 100644
--- a/microkde/kresources/managerimpl.h
+++ b/microkde/kresources/managerimpl.h
@@ -18,12 +18,19 @@
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/*
25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk
27
28$Id$
29*/
30
24#ifndef KRESOURCES_MANAGERIMPL_H 31#ifndef KRESOURCES_MANAGERIMPL_H
25#define KRESOURCES_MANAGERIMPL_H 32#define KRESOURCES_MANAGERIMPL_H
26 33
27#include <qstring.h> 34#include <qstring.h>
28#include <qptrlist.h> 35#include <qptrlist.h>
29#include <qdict.h> 36#include <qdict.h>
@@ -55,13 +62,13 @@ class ManagerImplListener
55 Do not use this class directly. Use ResourceManager instead 62 Do not use this class directly. Use ResourceManager instead
56*/ 63*/
57class ManagerImpl : public QObject 64class ManagerImpl : public QObject
58{ 65{
59 Q_OBJECT 66 Q_OBJECT
60 public: 67 public:
61 ManagerImpl( const QString &family ); 68 ManagerImpl( const QString &family, bool syncable);
62 ~ManagerImpl(); 69 ~ManagerImpl();
63 70
64 void readConfig( KConfig * ); 71 void readConfig( KConfig * );
65 void writeConfig( KConfig * ); 72 void writeConfig( KConfig * );
66 73
67 void add( Resource *resource, bool useDCOP = true ); 74 void add( Resource *resource, bool useDCOP = true );
@@ -80,29 +87,35 @@ class ManagerImpl : public QObject
80 QPtrList<Resource> resources( bool active ); 87 QPtrList<Resource> resources( bool active );
81 88
82 QStringList resourceNames(); 89 QStringList resourceNames();
83 90
84 void setListener( ManagerImplListener *listener ); 91 void setListener( ManagerImplListener *listener );
85 92
93 /**
94 Return true, if the manager manages syncable resources.
95 */
96 bool manageSyncable() const;
97
86 public slots: 98 public slots:
87 void resourceChanged( Resource *resource ); 99 void resourceChanged( Resource *resource );
88 100
89 private: 101 private:
90 // dcop calls 102 // dcop calls
91 103
92 private: 104 private:
93 void createStandardConfig(); 105 void createStandardConfig();
94 106
95 Resource *readResourceConfig( const QString& identifier, bool checkActive ); 107 Resource *readResourceConfig( const QString& identifier, bool checkActive );
96 void writeResourceConfig( Resource *resource, bool checkActive ); 108 void writeResourceConfig( Resource *resource, bool checkActive );
97 109
98 void removeResource( Resource *resource ); 110 void removeResource( Resource *resource );
99 Resource *getResource( Resource *resource ); 111 Resource *getResource( Resource *resource );
100 Resource *getResource( const QString& identifier ); 112 Resource *getResource( const QString& identifier );
101 113
102 QString mFamily; 114 QString mFamily;
115 bool mSyncable;
103 KConfig *mConfig; 116 KConfig *mConfig;
104 KConfig *mStdConfig; 117 KConfig *mStdConfig;
105 Resource *mStandard; 118 Resource *mStandard;
106 Factory *mFactory; 119 Factory *mFactory;
107 Resource::List mResources; 120 Resource::List mResources;
108 ManagerImplListener *mListener; 121 ManagerImplListener *mListener;
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp
index 991d53d..4f69540 100644
--- a/microkde/kresources/resource.cpp
+++ b/microkde/kresources/resource.cpp
@@ -48,13 +48,13 @@ Resource::Resource( const KConfig* config )
48 : QObject( 0, "" ), d( new ResourcePrivate ) 48 : QObject( 0, "" ), d( new ResourcePrivate )
49{ 49{
50 d->mOpenCount = 0; 50 d->mOpenCount = 0;
51 d->mIsOpen = false; 51 d->mIsOpen = false;
52 52
53 //US compiler claimed that const discards qualifier 53 //US compiler claimed that const discards qualifier
54 KConfig* cfg = (KConfig*)config; 54 KConfig* cfg = (KConfig*)config;
55 if ( cfg ) { 55 if ( cfg ) {
56#ifdef _WIN32_ 56#ifdef _WIN32_
57 // we use plugins on win32. the group is stored in a static variable 57 // we use plugins on win32. the group is stored in a static variable
58 // such that group info not available on win32 plugins 58 // such that group info not available on win32 plugins
59 // to fix that, it would be a looooot of work 59 // to fix that, it would be a looooot of work
60 if ( !cfg->tempGroup().isEmpty() ) 60 if ( !cfg->tempGroup().isEmpty() )
@@ -79,13 +79,13 @@ Resource::~Resource()
79 delete d; 79 delete d;
80 d = 0; 80 d = 0;
81} 81}
82 82
83void Resource::writeConfig( KConfig* config ) 83void Resource::writeConfig( KConfig* config )
84{ 84{
85 85
86 86
87 config->writeEntry( "ResourceType", d->mType ); 87 config->writeEntry( "ResourceType", d->mType );
88 config->writeEntry( "ResourceName", d->mName ); 88 config->writeEntry( "ResourceName", d->mName );
89 config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); 89 config->writeEntry( "ResourceIsReadOnly", d->mReadOnly );
90 config->writeEntry( "ResourceIsActive", d->mActive ); 90 config->writeEntry( "ResourceIsActive", d->mActive );
91 config->writeEntry( "ResourceIdentifier", d->mIdentifier ); 91 config->writeEntry( "ResourceIdentifier", d->mIdentifier );
@@ -188,6 +188,7 @@ void Resource::dump() const
188 kdDebug(5650) << " Type: " << d->mType << endl; 188 kdDebug(5650) << " Type: " << d->mType << endl;
189 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; 189 kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl;
190 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; 190 kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl;
191 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; 191 kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl;
192 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; 192 kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl;
193} 193}
194
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index 64e7424..c9202c9 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -37,12 +37,13 @@
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43class SyncWidget;
43 44
44/** 45/**
45 * @internal 46 * @internal
46 * @libdoc The KDE Resource library 47 * @libdoc The KDE Resource library
47 * 48 *
48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 49 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
@@ -317,12 +318,17 @@ class Resource : public QObject
317 318
318 /** 319 /**
319 * Returns the name of resource. 320 * Returns the name of resource.
320 */ 321 */
321 virtual QString resourceName() const; 322 virtual QString resourceName() const;
322 323
324
325
326 virtual bool isSyncable() const = 0;
327
328
323 /** 329 /**
324 Sets, if the resource is active. 330 Sets, if the resource is active.
325 */ 331 */
326 void setActive( bool active ); 332 void setActive( bool active );
327 333
328 /** 334 /**
@@ -335,12 +341,13 @@ class Resource : public QObject
335 341
336 /** 342 /**
337 Print resource information as debug output. 343 Print resource information as debug output.
338 */ 344 */
339 virtual void dump() const; 345 virtual void dump() const;
340 346
347
341 protected: 348 protected:
342 /** 349 /**
343 * Open this resource. When called, the resource must be in 350 * Open this resource. When called, the resource must be in
344 * a closed state. 351 * a closed state.
345 * 352 *
346 * Returns true if the resource was opened successfully; 353 * Returns true if the resource was opened successfully;
@@ -364,37 +371,45 @@ class Resource : public QObject
364 ResourcePrivate *d; 371 ResourcePrivate *d;
365}; 372};
366 373
367class PluginFactoryBase : public KLibFactory 374class PluginFactoryBase : public KLibFactory
368{ 375{
369 public: 376 public:
370 virtual Resource *resource( const KConfig *config ) = 0; 377 virtual Resource *resource( const KConfig *config, bool syncable ) = 0;
371 378
372 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 379 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
373 380
381 virtual SyncWidget *syncWidget( QWidget *parent ) = 0;
382
374 protected: 383 protected:
375 virtual QObject* createObject( QObject*, const char*, const char*, 384 virtual QObject* createObject( QObject*, const char*, const char*,
376 const QStringList & ) 385 const QStringList & )
377 { 386 {
378 return 0; 387 return 0;
379 } 388 }
380}; 389};
381 390
382template<class TR,class TC> 391template<class TR,class TC, class TS>
383class PluginFactory : public PluginFactoryBase 392class PluginFactory : public PluginFactoryBase
384{ 393{
385 public: 394 public:
386 Resource *resource( const KConfig *config ) 395 Resource *resource( const KConfig *config, bool syncable )
387 { 396 {
388 return new TR( config ); 397 return new TR( config, syncable );
389 } 398 }
390 399
391 ConfigWidget *configWidget( QWidget *parent ) 400 ConfigWidget *configWidget( QWidget *parent )
392 { 401 {
393 return new TC( parent ); 402 return new TC( parent );
394 } 403 }
404
405 virtual SyncWidget *syncWidget( QWidget *parent )
406 {
407 return new TS( parent );
408 }
409
395}; 410};
396 411
397 412
398 413
399} 414}
400 415