Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/kconfig.cpp | 181 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/kconfig.h | 51 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/kglobal.cpp | 6 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/microkde/kglobal.h | 6 |
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 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qtextstream.h> | ||
3 | |||
4 | #include "kdebug.h" | ||
5 | |||
6 | #include "kconfig.h" | ||
7 | |||
8 | QString KConfig::mGroup = ""; | ||
9 | //QString KConfig::mGroup = "General"; | ||
10 | |||
11 | KConfig::KConfig( const QString &fileName ) | ||
12 | : mFileName( fileName ), mDirty( false ) | ||
13 | { | ||
14 | kdDebug() << "KConfig::KConfig(): '" << fileName << "'" << endl; | ||
15 | |||
16 | load(); | ||
17 | } | ||
18 | |||
19 | |||
20 | KConfig::~KConfig() | ||
21 | { | ||
22 | sync(); | ||
23 | } | ||
24 | |||
25 | void KConfig::setGroup( const QString &group ) | ||
26 | { | ||
27 | return; | ||
28 | |||
29 | // kdDebug() << "KConfig::setGroup(): '" << group << "'" << endl; | ||
30 | |||
31 | mGroup = group; | ||
32 | |||
33 | if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; | ||
34 | } | ||
35 | |||
36 | |||
37 | QValueList<int> KConfig::readIntListEntry( const QString & ) | ||
38 | { | ||
39 | QValueList<int> l; | ||
40 | return l; | ||
41 | } | ||
42 | |||
43 | int KConfig::readNumEntry( const QString &, int def ) | ||
44 | { | ||
45 | return def; | ||
46 | } | ||
47 | |||
48 | QString KConfig::readEntry( const QString &key, const QString &def ) | ||
49 | { | ||
50 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | ||
51 | |||
52 | if ( it == mStringMap.end() ) { | ||
53 | return def; | ||
54 | } | ||
55 | |||
56 | return *it; | ||
57 | } | ||
58 | |||
59 | QStringList KConfig::readListEntry( const QString & ) | ||
60 | { | ||
61 | return QStringList(); | ||
62 | } | ||
63 | |||
64 | bool KConfig::readBoolEntry( const QString &key, bool def ) | ||
65 | { | ||
66 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); | ||
67 | |||
68 | if ( it == mBoolMap.end() ) { | ||
69 | return def; | ||
70 | } | ||
71 | |||
72 | return *it; | ||
73 | } | ||
74 | |||
75 | QColor KConfig::readColorEntry( const QString &, QColor *def ) | ||
76 | { | ||
77 | if ( def ) return *def; | ||
78 | return QColor(); | ||
79 | } | ||
80 | |||
81 | QFont KConfig::readFontEntry( const QString &, QFont *def ) | ||
82 | { | ||
83 | if ( def ) return *def; | ||
84 | return QFont(); | ||
85 | } | ||
86 | |||
87 | |||
88 | void KConfig::writeEntry( const QString &, QValueList<int> ) | ||
89 | { | ||
90 | } | ||
91 | |||
92 | void KConfig::writeEntry( const QString &, int ) | ||
93 | { | ||
94 | } | ||
95 | |||
96 | void KConfig::writeEntry( const QString &key, const QString &value ) | ||
97 | { | ||
98 | mStringMap.insert( mGroup + key, value ); | ||
99 | |||
100 | mDirty = true; | ||
101 | } | ||
102 | |||
103 | void KConfig::writeEntry( const QString &, const QStringList & ) | ||
104 | { | ||
105 | } | ||
106 | |||
107 | void KConfig::writeEntry( const QString &key, bool value) | ||
108 | { | ||
109 | mBoolMap.insert( mGroup + key, value ); | ||
110 | |||
111 | mDirty = true; | ||
112 | } | ||
113 | |||
114 | void KConfig::writeEntry( const QString &, const QColor & ) | ||
115 | { | ||
116 | } | ||
117 | |||
118 | void KConfig::writeEntry( const QString &, const QFont & ) | ||
119 | { | ||
120 | } | ||
121 | |||
122 | void KConfig::load() | ||
123 | { | ||
124 | mBoolMap.clear(); | ||
125 | mStringMap.clear(); | ||
126 | |||
127 | QFile f( mFileName ); | ||
128 | if ( !f.open( IO_ReadOnly ) ) { | ||
129 | kdDebug() << "KConfig::load(): Can't open file '" << mFileName << "'" | ||
130 | << endl; | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | |||
135 | QTextStream t( &f ); | ||
136 | |||
137 | QString line = t.readLine(); | ||
138 | |||
139 | while ( !line.isNull() ) { | ||
140 | QStringList tokens = QStringList::split( ",", line ); | ||
141 | if ( tokens[0] == "bool" ) { | ||
142 | bool value = false; | ||
143 | if ( tokens[2] == "1" ) value = true; | ||
144 | |||
145 | mBoolMap.insert( tokens[1], value ); | ||
146 | } else if ( tokens[0] == "QString" ) { | ||
147 | QString value = tokens[2]; | ||
148 | mStringMap.insert( tokens[1], value ); | ||
149 | } | ||
150 | |||
151 | line = t.readLine(); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | void KConfig::sync() | ||
156 | { | ||
157 | if ( !mDirty ) return; | ||
158 | |||
159 | QFile f( mFileName ); | ||
160 | if ( !f.open( IO_WriteOnly ) ) { | ||
161 | kdDebug() << "KConfig::sync(): Can't open file '" << mFileName << "'" | ||
162 | << endl; | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | QTextStream t( &f ); | ||
167 | |||
168 | QMap<QString,bool>::ConstIterator itBool; | ||
169 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { | ||
170 | t << "bool," << itBool.key() << "," << (*itBool ) << endl; | ||
171 | } | ||
172 | |||
173 | QMap<QString,QString>::ConstIterator itString; | ||
174 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { | ||
175 | t << "QString," << itString.key() << "," << (*itString ) << endl; | ||
176 | } | ||
177 | |||
178 | f.close(); | ||
179 | |||
180 | mDirty = false; | ||
181 | } | ||
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 @@ | |||
1 | #ifndef MINIKDE_KCONFIG_H | ||
2 | #define MINIKDE_KCONFIG_H | ||
3 | |||
4 | #include <qstring.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qvaluelist.h> | ||
7 | #include <qcolor.h> | ||
8 | #include <qfont.h> | ||
9 | #include <qmap.h> | ||
10 | |||
11 | class KConfig | ||
12 | { | ||
13 | public: | ||
14 | KConfig( const QString & ); | ||
15 | ~KConfig(); | ||
16 | |||
17 | void setGroup( const QString & ); | ||
18 | |||
19 | bool hasGroup( const QString &) {return false;} | ||
20 | |||
21 | QValueList<int> readIntListEntry( const QString & ); | ||
22 | int readNumEntry( const QString &, int def=0 ); | ||
23 | QString readEntry( const QString &, const QString &def=QString::null ); | ||
24 | QStringList readListEntry( const QString & ); | ||
25 | bool readBoolEntry( const QString &, bool def=false ); | ||
26 | QColor readColorEntry( const QString &, QColor * ); | ||
27 | QFont readFontEntry( const QString &, QFont * ); | ||
28 | |||
29 | void writeEntry( const QString &, QValueList<int> ); | ||
30 | void writeEntry( const QString &, int ); | ||
31 | void writeEntry( const QString &, const QString & ); | ||
32 | void writeEntry( const QString &, const QStringList & ); | ||
33 | void writeEntry( const QString &, bool ); | ||
34 | void writeEntry( const QString &, const QColor & ); | ||
35 | void writeEntry( const QString &, const QFont & ); | ||
36 | |||
37 | void load(); | ||
38 | void sync(); | ||
39 | |||
40 | private: | ||
41 | static QString mGroup; | ||
42 | |||
43 | QString mFileName; | ||
44 | |||
45 | QMap<QString,bool> mBoolMap; | ||
46 | QMap<QString,QString> mStringMap; | ||
47 | |||
48 | bool mDirty; | ||
49 | }; | ||
50 | |||
51 | #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 | |||
@@ -3,3 +3,3 @@ | |||
3 | KLocale *KGlobal::mLocale = 0; | 3 | KLocale *KGlobal::mLocale = 0; |
4 | KConfig *KGlobal::mConfig = 0; | 4 | KateConfig *KGlobal::mConfig = 0; |
5 | KIconLoader *KGlobal::mIconLoader = 0; | 5 | KIconLoader *KGlobal::mIconLoader = 0; |
@@ -18,6 +18,6 @@ KLocale *KGlobal::locale() | |||
18 | 18 | ||
19 | KConfig *KGlobal::config() | 19 | KateConfig *KGlobal::config() |
20 | { | 20 | { |
21 | if ( !mConfig ) { | 21 | if ( !mConfig ) { |
22 | mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); | 22 | mConfig = new KateConfig( mAppName ); |
23 | } | 23 | } |
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 | |||
@@ -6,3 +6,3 @@ | |||
6 | #include "kstandarddirs.h" | 6 | #include "kstandarddirs.h" |
7 | #include "kconfig.h" | 7 | #include <kateconfig.h> |
8 | 8 | ||
@@ -11,3 +11,3 @@ class KGlobal { | |||
11 | static KLocale *locale(); | 11 | static KLocale *locale(); |
12 | static KConfig *config(); | 12 | static KateConfig *config(); |
13 | static KIconLoader *iconLoader(); | 13 | static KIconLoader *iconLoader(); |
@@ -19,3 +19,3 @@ class KGlobal { | |||
19 | static KLocale *mLocale; | 19 | static KLocale *mLocale; |
20 | static KConfig *mConfig; | 20 | static KateConfig *mConfig; |
21 | static KIconLoader *mIconLoader; | 21 | static KIconLoader *mIconLoader; |