-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 @@ -5,39 +5,51 @@ #include "kdebug.h" #include "kurl.h" #include "kstandarddirs.h" #include "kconfig.h" QString KConfig::mGroup = ""; //QString KConfig::mGroup = "General"; KConfig::KConfig( const QString &fileName ) : mFileName( fileName ), mDirty( false ) { - kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; - + + mTempGroup = ""; load(); } KConfig::~KConfig() { sync(); } +// we need the temp group for plugins on windows +void KConfig::setTempGroup( const QString &group ) +{ + mTempGroup = group; + + if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; +} + + +QString KConfig::tempGroup() const { + return mTempGroup; +} void KConfig::setGroup( const QString &group ) { - kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; + mGroup = group; if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; } //US QString KConfig::group() const { return mGroup; } //US added method @@ -60,25 +72,25 @@ QValueList<int> KConfig::readIntListEntry( const QString & key) for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { val = (*sit).toInt(&ok); result << val; if (ok == false) { qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); ok2 = false; } } if (ok2 == false) { - kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; + qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); } return result; } int KConfig::readNumEntry( const QString & key, int def ) { QString res = readEntry(key, QString::number(def ) ); bool ok = false; int result = res.toInt(&ok); if ( ok ) @@ -218,25 +230,25 @@ void KConfig::writeEntry( const QString & e , const QFont & f ) font.append( QString::number ( f.pointSize () ) ); font.append( !f.italic ()?"nonitalic":"italic" ); writeEntry( e, font ); } void KConfig::writeEntry( const QString &key, const QDateTime &dt ) { mDateTimeMap.insert( mGroup + key, dt ); } void KConfig::load() { - kdDebug() << "KConfig::load(): " << mFileName << endl; + QFile f( mFileName ); if ( !f.open( IO_ReadOnly ) ) { qDebug("KConfig: could not open file %s ",mFileName.latin1() ); return; } mBoolMap.clear(); mStringMap.clear(); QTextStream t( &f ); diff --git a/microkde/kconfig.h b/microkde/kconfig.h index bfedf53..a01b1a5 100644 --- a/microkde/kconfig.h +++ b/microkde/kconfig.h @@ -6,24 +6,27 @@ #include <qvaluelist.h> #include <qcolor.h> #include <qfont.h> #include <qmap.h> #include <qdatetime.h> class KConfig { public: KConfig( const QString & ); ~KConfig(); + void setTempGroup( const QString &group ); + QString tempGroup() const; + void setGroup( const QString & ); //US /** * Returns the name of the group in which we are * searching for keys and from which we are retrieving entries. * * @return The current group. */ QString group() const; //US I took the following deleteGroup method from a newer version from KDE. @@ -78,23 +81,24 @@ class KConfig void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); } void writeEntry( const QString &, const QColor & ); void writeEntry( const QString &, const QFont & ); void writeEntry( const QString &, const QDateTime & ); void deleteEntry( const QString &); void load(); void sync(); private: static QString mGroup; + QString mTempGroup; QString mFileName; QMap<QString,bool> mBoolMap; QMap<QString,QString> mStringMap; QMap<QString,QDateTime> mDateTimeMap; bool mDirty; }; #endif 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 @@ -244,31 +244,36 @@ void ManagerImpl::setListener( ManagerImplListener *listener ) { mListener = listener; } Resource* ManagerImpl::readResourceConfig( const QString& identifier, bool checkActive ) { kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; // qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); mConfig->setGroup( "Resource_" + identifier ); - +#ifdef _WIN32_ + // we use plugins on win32. the group is stored in a static variable + // such that gourp info not avail on win32 plugins + // to fix that, it would be a looooot of work + mConfig->setTempGroup( "Resource_" + identifier ); +#endif QString type = mConfig->readEntry( "ResourceType" ); QString name = mConfig->readEntry( "ResourceName" ); Resource *resource = mFactory->resource( type, mConfig ); if ( !resource ) { - kdDebug(5650) << "Failed to create resource with id " << identifier << endl; - return 0; + qDebug("Failed to create resource with id %s ",identifier.latin1() ); + return 0; } if ( resource->identifier().isEmpty() ) resource->setIdentifier( identifier ); mConfig->setGroup( "General" ); QString standardKey = mConfig->readEntry( "Standard" ); if ( standardKey == identifier ) { mStandard = resource; } 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 @@ -44,24 +44,31 @@ class Resource::ResourcePrivate bool mIsOpen; }; Resource::Resource( const KConfig* config ) : QObject( 0, "" ), d( new ResourcePrivate ) { d->mOpenCount = 0; d->mIsOpen = false; //US compiler claimed that const discards qualifier KConfig* cfg = (KConfig*)config; if ( cfg ) { +#ifdef _WIN32_ + // we use plugins on win32. the group is stored in a static variable + // such that group info not available on win32 plugins + // to fix that, it would be a looooot of work + if ( !cfg->tempGroup().isEmpty() ) + cfg->setGroup( cfg->tempGroup() ); +#endif d->mType = cfg->readEntry( "ResourceType" ); d->mName = cfg->readEntry( "ResourceName" ); d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); } else { d->mType = "type"; d->mName = "resource-name"; d->mReadOnly = false; d->mActive = true; d->mIdentifier = KApplication::randomString( 10 ); } |