From de1321a53998bc1d078f9492395c2a26392875ed Mon Sep 17 00:00:00 2001 From: kergoth Date: Tue, 28 Jan 2003 03:23:14 +0000 Subject: Added a Config derivative. --- (limited to 'noncore/apps/tinykate/libkate/microkde/kconfig.cpp') diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp b/noncore/apps/tinykate/libkate/microkde/kconfig.cpp deleted file mode 100644 index d88bda0..0000000 --- a/noncore/apps/tinykate/libkate/microkde/kconfig.cpp +++ b/dev/null @@ -1,181 +0,0 @@ -#include -#include - -#include "kdebug.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; - - load(); -} - - -KConfig::~KConfig() -{ - sync(); -} - -void KConfig::setGroup( const QString &group ) -{ - return; - -// kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; - - mGroup = group; - - if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; -} - - -QValueList KConfig::readIntListEntry( const QString & ) -{ - QValueList l; - return l; -} - -int KConfig::readNumEntry( const QString &, int def ) -{ - return def; -} - -QString KConfig::readEntry( const QString &key, const QString &def ) -{ - QMap::ConstIterator it = mStringMap.find( mGroup + key ); - - if ( it == mStringMap.end() ) { - return def; - } - - return *it; -} - -QStringList KConfig::readListEntry( const QString & ) -{ - return QStringList(); -} - -bool KConfig::readBoolEntry( const QString &key, bool def ) -{ - QMap::ConstIterator it = mBoolMap.find( mGroup + key ); - - if ( it == mBoolMap.end() ) { - return def; - } - - return *it; -} - -QColor KConfig::readColorEntry( const QString &, QColor *def ) -{ - if ( def ) return *def; - return QColor(); -} - -QFont KConfig::readFontEntry( const QString &, QFont *def ) -{ - if ( def ) return *def; - return QFont(); -} - - -void KConfig::writeEntry( const QString &, QValueList ) -{ -} - -void KConfig::writeEntry( const QString &, int ) -{ -} - -void KConfig::writeEntry( const QString &key, const QString &value ) -{ - mStringMap.insert( mGroup + key, value ); - - mDirty = true; -} - -void KConfig::writeEntry( const QString &, const QStringList & ) -{ -} - -void KConfig::writeEntry( const QString &key, bool value) -{ - mBoolMap.insert( mGroup + key, value ); - - mDirty = true; -} - -void KConfig::writeEntry( const QString &, const QColor & ) -{ -} - -void KConfig::writeEntry( const QString &, const QFont & ) -{ -} - -void KConfig::load() -{ - mBoolMap.clear(); - mStringMap.clear(); - - QFile f( mFileName ); - if ( !f.open( IO_ReadOnly ) ) { - kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'" - << endl; - return; - } - - - QTextStream t( &f ); - - QString line = t.readLine(); - - while ( !line.isNull() ) { - QStringList tokens = QStringList::split( ",", line ); - if ( tokens[0] == "bool" ) { - bool value = false; - if ( tokens[2] == "1" ) value = true; - - mBoolMap.insert( tokens[1], value ); - } else if ( tokens[0] == "QString" ) { - QString value = tokens[2]; - mStringMap.insert( tokens[1], value ); - } - - line = t.readLine(); - } -} - -void KConfig::sync() -{ - if ( !mDirty ) return; - - QFile f( mFileName ); - if ( !f.open( IO_WriteOnly ) ) { - kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'" - << endl; - return; - } - - QTextStream t( &f ); - - QMap::ConstIterator itBool; - for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { - t << "bool," << itBool.key() << "," << (*itBool ) << endl; - } - - QMap::ConstIterator itString; - for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { - t << "QString," << itString.key() << "," << (*itString ) << endl; - } - - f.close(); - - mDirty = false; -} -- cgit v0.9.0.2