author | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-08 11:20:17 (UTC) |
commit | 3f84322a2da502f95be386372da9f75ed17df574 (patch) (unidiff) | |
tree | 9a4ccd4568c38d60bb1efa7a6713f4d0914aae86 /microkde | |
parent | 40cf8102d2f38b5e952b889ffbd19cb1d428fc9b (diff) | |
download | kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.zip kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.gz kdepimpi-3f84322a2da502f95be386372da9f75ed17df574.tar.bz2 |
Fixes for resource plugin handling on wintendo
-rw-r--r-- | microkde/kconfig.cpp | 22 | ||||
-rw-r--r-- | microkde/kconfig.h | 4 | ||||
-rw-r--r-- | microkde/kresources/managerimpl.cpp | 11 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 7 |
4 files changed, 36 insertions, 8 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 737b3f2..4cbec94 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -9,31 +9,43 @@ | |||
9 | #include "kconfig.h" | 9 | #include "kconfig.h" |
10 | 10 | ||
11 | QString KConfig::mGroup = ""; | 11 | QString KConfig::mGroup = ""; |
12 | //QString KConfig::mGroup = "General"; | 12 | //QString KConfig::mGroup = "General"; |
13 | 13 | ||
14 | KConfig::KConfig( const QString &fileName ) | 14 | KConfig::KConfig( const QString &fileName ) |
15 | : mFileName( fileName ), mDirty( false ) | 15 | : mFileName( fileName ), mDirty( false ) |
16 | { | 16 | { |
17 | kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; | 17 | |
18 | 18 | mTempGroup = ""; | |
19 | load(); | 19 | load(); |
20 | 20 | ||
21 | } | 21 | } |
22 | 22 | ||
23 | 23 | ||
24 | KConfig::~KConfig() | 24 | KConfig::~KConfig() |
25 | { | 25 | { |
26 | sync(); | 26 | sync(); |
27 | } | 27 | } |
28 | // we need the temp group for plugins on windows | ||
29 | void KConfig::setTempGroup( const QString &group ) | ||
30 | { | ||
31 | mTempGroup = group; | ||
32 | |||
33 | if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; | ||
34 | } | ||
35 | |||
36 | |||
37 | QString KConfig::tempGroup() const { | ||
38 | return mTempGroup; | ||
39 | } | ||
28 | 40 | ||
29 | void KConfig::setGroup( const QString &group ) | 41 | void KConfig::setGroup( const QString &group ) |
30 | { | 42 | { |
31 | kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; | 43 | |
32 | 44 | ||
33 | mGroup = group; | 45 | mGroup = group; |
34 | 46 | ||
35 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; | 47 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; |
36 | } | 48 | } |
37 | 49 | ||
38 | //US | 50 | //US |
39 | QString KConfig::group() const { | 51 | QString KConfig::group() const { |
@@ -64,17 +76,17 @@ QValueList<int> KConfig::readIntListEntry( const QString & key) | |||
64 | if (ok == false) { | 76 | if (ok == false) { |
65 | qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); | 77 | qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); |
66 | ok2 = false; | 78 | ok2 = false; |
67 | } | 79 | } |
68 | } | 80 | } |
69 | 81 | ||
70 | if (ok2 == false) | 82 | if (ok2 == false) |
71 | { | 83 | { |
72 | kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; | 84 | |
73 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); | 85 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); |
74 | } | 86 | } |
75 | 87 | ||
76 | return result; | 88 | return result; |
77 | } | 89 | } |
78 | 90 | ||
79 | int KConfig::readNumEntry( const QString & key, int def ) | 91 | int KConfig::readNumEntry( const QString & key, int def ) |
80 | { | 92 | { |
@@ -222,17 +234,17 @@ void KConfig::writeEntry( const QString & e , const QFont & f ) | |||
222 | 234 | ||
223 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) | 235 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) |
224 | { | 236 | { |
225 | mDateTimeMap.insert( mGroup + key, dt ); | 237 | mDateTimeMap.insert( mGroup + key, dt ); |
226 | } | 238 | } |
227 | 239 | ||
228 | void KConfig::load() | 240 | void KConfig::load() |
229 | { | 241 | { |
230 | kdDebug() << "KConfig::load(): " << mFileName << endl; | 242 | |
231 | 243 | ||
232 | QFile f( mFileName ); | 244 | QFile f( mFileName ); |
233 | if ( !f.open( IO_ReadOnly ) ) { | 245 | if ( !f.open( IO_ReadOnly ) ) { |
234 | qDebug("KConfig: could not open file %s ",mFileName.latin1() ); | 246 | qDebug("KConfig: could not open file %s ",mFileName.latin1() ); |
235 | return; | 247 | return; |
236 | } | 248 | } |
237 | 249 | ||
238 | mBoolMap.clear(); | 250 | mBoolMap.clear(); |
diff --git a/microkde/kconfig.h b/microkde/kconfig.h index bfedf53..a01b1a5 100644 --- a/microkde/kconfig.h +++ b/microkde/kconfig.h | |||
@@ -10,16 +10,19 @@ | |||
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | 11 | ||
12 | class KConfig | 12 | class KConfig |
13 | { | 13 | { |
14 | public: | 14 | public: |
15 | KConfig( const QString & ); | 15 | KConfig( const QString & ); |
16 | ~KConfig(); | 16 | ~KConfig(); |
17 | 17 | ||
18 | void setTempGroup( const QString &group ); | ||
19 | QString tempGroup() const; | ||
20 | |||
18 | void setGroup( const QString & ); | 21 | void setGroup( const QString & ); |
19 | 22 | ||
20 | //US | 23 | //US |
21 | /** | 24 | /** |
22 | * Returns the name of the group in which we are | 25 | * Returns the name of the group in which we are |
23 | * searching for keys and from which we are retrieving entries. | 26 | * searching for keys and from which we are retrieving entries. |
24 | * | 27 | * |
25 | * @return The current group. | 28 | * @return The current group. |
@@ -82,16 +85,17 @@ class KConfig | |||
82 | 85 | ||
83 | void deleteEntry( const QString &); | 86 | void deleteEntry( const QString &); |
84 | 87 | ||
85 | void load(); | 88 | void load(); |
86 | void sync(); | 89 | void sync(); |
87 | 90 | ||
88 | private: | 91 | private: |
89 | static QString mGroup; | 92 | static QString mGroup; |
93 | QString mTempGroup; | ||
90 | 94 | ||
91 | QString mFileName; | 95 | QString mFileName; |
92 | 96 | ||
93 | QMap<QString,bool> mBoolMap; | 97 | QMap<QString,bool> mBoolMap; |
94 | QMap<QString,QString> mStringMap; | 98 | QMap<QString,QString> mStringMap; |
95 | QMap<QString,QDateTime> mDateTimeMap; | 99 | QMap<QString,QDateTime> mDateTimeMap; |
96 | 100 | ||
97 | bool mDirty; | 101 | bool mDirty; |
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp index 1baa6be..785b6b4 100644 --- a/microkde/kresources/managerimpl.cpp +++ b/microkde/kresources/managerimpl.cpp | |||
@@ -248,23 +248,28 @@ void ManagerImpl::setListener( ManagerImplListener *listener ) | |||
248 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, | 248 | Resource* ManagerImpl::readResourceConfig( const QString& identifier, |
249 | bool checkActive ) | 249 | bool checkActive ) |
250 | { | 250 | { |
251 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; | 251 | kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; |
252 | 252 | ||
253 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); | 253 | // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); |
254 | 254 | ||
255 | mConfig->setGroup( "Resource_" + identifier ); | 255 | mConfig->setGroup( "Resource_" + identifier ); |
256 | 256 | #ifdef _WIN32_ | |
257 | // we use plugins on win32. the group is stored in a static variable | ||
258 | // such that gourp info not avail on win32 plugins | ||
259 | // to fix that, it would be a looooot of work | ||
260 | mConfig->setTempGroup( "Resource_" + identifier ); | ||
261 | #endif | ||
257 | QString type = mConfig->readEntry( "ResourceType" ); | 262 | QString type = mConfig->readEntry( "ResourceType" ); |
258 | QString name = mConfig->readEntry( "ResourceName" ); | 263 | QString name = mConfig->readEntry( "ResourceName" ); |
259 | Resource *resource = mFactory->resource( type, mConfig ); | 264 | Resource *resource = mFactory->resource( type, mConfig ); |
260 | if ( !resource ) { | 265 | if ( !resource ) { |
261 | kdDebug(5650) << "Failed to create resource with id " << identifier << endl; | 266 | qDebug("Failed to create resource with id %s ",identifier.latin1() ); |
262 | return 0; | 267 | return 0; |
263 | } | 268 | } |
264 | 269 | ||
265 | if ( resource->identifier().isEmpty() ) | 270 | if ( resource->identifier().isEmpty() ) |
266 | resource->setIdentifier( identifier ); | 271 | resource->setIdentifier( identifier ); |
267 | 272 | ||
268 | mConfig->setGroup( "General" ); | 273 | mConfig->setGroup( "General" ); |
269 | 274 | ||
270 | QString standardKey = mConfig->readEntry( "Standard" ); | 275 | QString standardKey = mConfig->readEntry( "Standard" ); |
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 7827a67..991d53d 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp | |||
@@ -48,16 +48,23 @@ 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_ | ||
57 | // we use plugins on win32. the group is stored in a static variable | ||
58 | // such that group info not available on win32 plugins | ||
59 | // to fix that, it would be a looooot of work | ||
60 | if ( !cfg->tempGroup().isEmpty() ) | ||
61 | cfg->setGroup( cfg->tempGroup() ); | ||
62 | #endif | ||
56 | d->mType = cfg->readEntry( "ResourceType" ); | 63 | d->mType = cfg->readEntry( "ResourceType" ); |
57 | d->mName = cfg->readEntry( "ResourceName" ); | 64 | d->mName = cfg->readEntry( "ResourceName" ); |
58 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); | 65 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); |
59 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); | 66 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); |
60 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); | 67 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); |
61 | } else { | 68 | } else { |
62 | d->mType = "type"; | 69 | d->mType = "type"; |
63 | d->mName = "resource-name"; | 70 | d->mName = "resource-name"; |