summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/microkde
authorkergoth <kergoth>2003-01-28 03:23:14 (UTC)
committer kergoth <kergoth>2003-01-28 03:23:14 (UTC)
commitde1321a53998bc1d078f9492395c2a26392875ed (patch) (side-by-side diff)
treeb36d59612da5bbafeaddd28cb88a222b699d2645 /noncore/apps/tinykate/libkate/microkde
parent728a7a4966c342be32c80c045cbae500160fc17b (diff)
downloadopie-de1321a53998bc1d078f9492395c2a26392875ed.zip
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.gz
opie-de1321a53998bc1d078f9492395c2a26392875ed.tar.bz2
Added a Config derivative.
Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.cpp181
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kconfig.h51
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.cpp6
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kglobal.h6
4 files changed, 6 insertions, 238 deletions
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 <qfile.h>
-#include <qtextstream.h>
-
-#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<int> KConfig::readIntListEntry( const QString & )
-{
- QValueList<int> l;
- return l;
-}
-
-int KConfig::readNumEntry( const QString &, int def )
-{
- return def;
-}
-
-QString KConfig::readEntry( const QString &key, const QString &def )
-{
- QMap<QString,QString>::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<QString,bool>::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<int> )
-{
-}
-
-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<QString,bool>::ConstIterator itBool;
- for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
- t << "bool," << itBool.key() << "," << (*itBool ) << endl;
- }
-
- QMap<QString,QString>::ConstIterator itString;
- for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
- t << "QString," << itString.key() << "," << (*itString ) << endl;
- }
-
- f.close();
-
- mDirty = false;
-}
diff --git a/noncore/apps/tinykate/libkate/microkde/kconfig.h b/noncore/apps/tinykate/libkate/microkde/kconfig.h
deleted file mode 100644
index 8bd768a..0000000
--- a/noncore/apps/tinykate/libkate/microkde/kconfig.h
+++ b/dev/null
@@ -1,51 +0,0 @@
-#ifndef MINIKDE_KCONFIG_H
-#define MINIKDE_KCONFIG_H
-
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qvaluelist.h>
-#include <qcolor.h>
-#include <qfont.h>
-#include <qmap.h>
-
-class KConfig
-{
- public:
- KConfig( const QString & );
- ~KConfig();
-
- void setGroup( const QString & );
-
- bool hasGroup( const QString &) {return false;}
-
- QValueList<int> readIntListEntry( const QString & );
- int readNumEntry( const QString &, int def=0 );
- QString readEntry( const QString &, const QString &def=QString::null );
- QStringList readListEntry( const QString & );
- bool readBoolEntry( const QString &, bool def=false );
- QColor readColorEntry( const QString &, QColor * );
- QFont readFontEntry( const QString &, QFont * );
-
- void writeEntry( const QString &, QValueList<int> );
- void writeEntry( const QString &, int );
- void writeEntry( const QString &, const QString & );
- void writeEntry( const QString &, const QStringList & );
- void writeEntry( const QString &, bool );
- void writeEntry( const QString &, const QColor & );
- void writeEntry( const QString &, const QFont & );
-
- void load();
- void sync();
-
- private:
- static QString mGroup;
-
- QString mFileName;
-
- QMap<QString,bool> mBoolMap;
- QMap<QString,QString> mStringMap;
-
- bool mDirty;
-};
-
-#endif
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
index 572768d..9b5c4d3 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.cpp
@@ -1,7 +1,7 @@
#include "kglobal.h"
KLocale *KGlobal::mLocale = 0;
-KConfig *KGlobal::mConfig = 0;
+KateConfig *KGlobal::mConfig = 0;
KIconLoader *KGlobal::mIconLoader = 0;
KStandardDirs *KGlobal::mDirs = 0;
@@ -16,10 +16,10 @@ KLocale *KGlobal::locale()
return mLocale;
}
-KConfig *KGlobal::config()
+KateConfig *KGlobal::config()
{
if ( !mConfig ) {
- mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" );
+ mConfig = new KateConfig( mAppName );
}
return mConfig;
diff --git a/noncore/apps/tinykate/libkate/microkde/kglobal.h b/noncore/apps/tinykate/libkate/microkde/kglobal.h
index 8985bd4..e4e2c79 100644
--- a/noncore/apps/tinykate/libkate/microkde/kglobal.h
+++ b/noncore/apps/tinykate/libkate/microkde/kglobal.h
@@ -4,12 +4,12 @@
#include "klocale.h"
#include "kiconloader.h"
#include "kstandarddirs.h"
-#include "kconfig.h"
+#include <kateconfig.h>
class KGlobal {
public:
static KLocale *locale();
- static KConfig *config();
+ static KateConfig *config();
static KIconLoader *iconLoader();
static KStandardDirs *dirs();
@@ -17,7 +17,7 @@ class KGlobal {
private:
static KLocale *mLocale;
- static KConfig *mConfig;
+ static KateConfig *mConfig;
static KIconLoader *mIconLoader;
static KStandardDirs *mDirs;