-rw-r--r-- | microkde/kconfig.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 71db891..737b3f2 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -50,193 +50,193 @@ QValueList<int> KConfig::readIntListEntry( const QString & key) | |||
50 | QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); | 50 | QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); |
51 | 51 | ||
52 | if ( mit == mStringMap.end() ) { | 52 | if ( mit == mStringMap.end() ) { |
53 | return result; | 53 | return result; |
54 | } | 54 | } |
55 | 55 | ||
56 | QStringList valuesAsStrings = QStringList::split(":", *mit ); | 56 | QStringList valuesAsStrings = QStringList::split(":", *mit ); |
57 | bool ok = false; | 57 | bool ok = false; |
58 | bool ok2 = true; | 58 | bool ok2 = true; |
59 | int val; | 59 | int val; |
60 | 60 | ||
61 | for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { | 61 | for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { |
62 | val = (*sit).toInt(&ok); | 62 | val = (*sit).toInt(&ok); |
63 | result << val; | 63 | result << val; |
64 | if (ok == false) { | 64 | if (ok == false) { |
65 | qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); | 65 | qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); |
66 | ok2 = false; | 66 | ok2 = false; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | if (ok2 == false) | 70 | if (ok2 == false) |
71 | { | 71 | { |
72 | kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; | 72 | kdDebug() << "KConfig::readIntListEntry: error while reading one of the intvalues." << endl; |
73 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); | 73 | qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); |
74 | } | 74 | } |
75 | 75 | ||
76 | return result; | 76 | return result; |
77 | } | 77 | } |
78 | 78 | ||
79 | int KConfig::readNumEntry( const QString & key, int def ) | 79 | int KConfig::readNumEntry( const QString & key, int def ) |
80 | { | 80 | { |
81 | QString res = readEntry(key, QString::number(def ) ); | 81 | QString res = readEntry(key, QString::number(def ) ); |
82 | bool ok = false; | 82 | bool ok = false; |
83 | int result = res.toInt(&ok); | 83 | int result = res.toInt(&ok); |
84 | if ( ok ) | 84 | if ( ok ) |
85 | return result; | 85 | return result; |
86 | return def; | 86 | return def; |
87 | } | 87 | } |
88 | 88 | ||
89 | QString KConfig::readEntry( const QString &key, const QString &def ) | 89 | QString KConfig::readEntry( const QString &key, const QString &def ) |
90 | { | 90 | { |
91 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | 91 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); |
92 | 92 | ||
93 | if ( it == mStringMap.end() ) { | 93 | if ( it == mStringMap.end() ) { |
94 | return def; | 94 | return def; |
95 | } | 95 | } |
96 | 96 | ||
97 | return *it; | 97 | return *it; |
98 | } | 98 | } |
99 | 99 | ||
100 | QStringList KConfig::readListEntry( const QString &key ) | 100 | QStringList KConfig::readListEntry( const QString &key ) |
101 | { | 101 | { |
102 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); | 102 | QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); |
103 | 103 | ||
104 | if ( it == mStringMap.end() ) { | 104 | if ( it == mStringMap.end() ) { |
105 | return QStringList(); | 105 | return QStringList(); |
106 | } | 106 | } |
107 | return QStringList::split(":", *it ); | 107 | return QStringList::split(":", *it ); |
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | bool KConfig::readBoolEntry( const QString &key, bool def ) | 111 | bool KConfig::readBoolEntry( const QString &key, bool def ) |
112 | { | 112 | { |
113 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); | 113 | QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); |
114 | 114 | ||
115 | if ( it == mBoolMap.end() ) { | 115 | if ( it == mBoolMap.end() ) { |
116 | return def; | 116 | return def; |
117 | } | 117 | } |
118 | 118 | ||
119 | return *it; | 119 | return *it; |
120 | } | 120 | } |
121 | 121 | ||
122 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) | 122 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) |
123 | { | 123 | { |
124 | 124 | ||
125 | QStringList l; | 125 | QStringList l; |
126 | l = readListEntry( e ); | 126 | l = readListEntry( e ); |
127 | if (l.count() != 3 ) { | 127 | if (l.count() != 3 ) { |
128 | if ( def ) | 128 | if ( def ) |
129 | return *def; | 129 | return *def; |
130 | else | 130 | else |
131 | return QColor(); | 131 | return QColor(); |
132 | } | 132 | } |
133 | QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); | 133 | QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); |
134 | return c; | 134 | return c; |
135 | } | 135 | } |
136 | 136 | ||
137 | QFont KConfig::readFontEntry( const QString & e, QFont *def ) | 137 | QFont KConfig::readFontEntry( const QString & e, QFont *def ) |
138 | { | 138 | { |
139 | QStringList font = readListEntry( e ); | 139 | QStringList font = readListEntry( e ); |
140 | if ( font.isEmpty() ) | 140 | if ( font.isEmpty() ) |
141 | return *def; | 141 | return *def; |
142 | QFont f; | 142 | QFont f; |
143 | f.setFamily( font[0]); | 143 | f.setFamily( font[0]); |
144 | f.setBold ( font[1] == "bold"); | 144 | f.setBold ( font[1] == "bold"); |
145 | f.setPointSize ( font[2].toInt()); | 145 | f.setPointSize ( font[2].toInt()); |
146 | f.setItalic( font[1] == "italic" ); | 146 | f.setItalic( font[3] == "italic" ); |
147 | return f; | 147 | return f; |
148 | } | 148 | } |
149 | 149 | ||
150 | QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) | 150 | QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) |
151 | { | 151 | { |
152 | QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); | 152 | QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); |
153 | 153 | ||
154 | if ( it == mDateTimeMap.end() ) { | 154 | if ( it == mDateTimeMap.end() ) { |
155 | if ( def ) return *def; | 155 | if ( def ) return *def; |
156 | else return QDateTime(); | 156 | else return QDateTime(); |
157 | } | 157 | } |
158 | 158 | ||
159 | return *it; | 159 | return *it; |
160 | } | 160 | } |
161 | 161 | ||
162 | //US added method | 162 | //US added method |
163 | void KConfig::writeEntry( const QString &key, const QValueList<int> &value) | 163 | void KConfig::writeEntry( const QString &key, const QValueList<int> &value) |
164 | { | 164 | { |
165 | QStringList valuesAsStrings; | 165 | QStringList valuesAsStrings; |
166 | 166 | ||
167 | QValueList<int>::ConstIterator it; | 167 | QValueList<int>::ConstIterator it; |
168 | 168 | ||
169 | for( it = value.begin(); it != value.end(); ++it ) | 169 | for( it = value.begin(); it != value.end(); ++it ) |
170 | { | 170 | { |
171 | valuesAsStrings << QString::number(*it); | 171 | valuesAsStrings << QString::number(*it); |
172 | } | 172 | } |
173 | 173 | ||
174 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); | 174 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); |
175 | mDirty = true; | 175 | mDirty = true; |
176 | } | 176 | } |
177 | 177 | ||
178 | void KConfig::writeEntry( const QString & key , int num ) | 178 | void KConfig::writeEntry( const QString & key , int num ) |
179 | { | 179 | { |
180 | writeEntry( key, QString::number ( num ) ); | 180 | writeEntry( key, QString::number ( num ) ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void KConfig::writeEntry( const QString &key, const QString &value ) | 183 | void KConfig::writeEntry( const QString &key, const QString &value ) |
184 | { | 184 | { |
185 | mStringMap.insert( mGroup + key, value ); | 185 | mStringMap.insert( mGroup + key, value ); |
186 | 186 | ||
187 | mDirty = true; | 187 | mDirty = true; |
188 | } | 188 | } |
189 | 189 | ||
190 | void KConfig::writeEntry( const QString &key, const QStringList &value ) | 190 | void KConfig::writeEntry( const QString &key, const QStringList &value ) |
191 | { | 191 | { |
192 | mStringMap.insert( mGroup + key, value.join(":") ); | 192 | mStringMap.insert( mGroup + key, value.join(":") ); |
193 | 193 | ||
194 | mDirty = true; | 194 | mDirty = true; |
195 | } | 195 | } |
196 | 196 | ||
197 | void KConfig::writeEntry( const QString &key, bool value) | 197 | void KConfig::writeEntry( const QString &key, bool value) |
198 | { | 198 | { |
199 | mBoolMap.insert( mGroup + key, value ); | 199 | mBoolMap.insert( mGroup + key, value ); |
200 | 200 | ||
201 | mDirty = true; | 201 | mDirty = true; |
202 | } | 202 | } |
203 | 203 | ||
204 | void KConfig::writeEntry( const QString & e, const QColor & c ) | 204 | void KConfig::writeEntry( const QString & e, const QColor & c ) |
205 | { | 205 | { |
206 | QStringList l; | 206 | QStringList l; |
207 | l.append( QString::number ( c.red() ) ); | 207 | l.append( QString::number ( c.red() ) ); |
208 | l.append( QString::number ( c.green() ) ); | 208 | l.append( QString::number ( c.green() ) ); |
209 | l.append( QString::number ( c.blue() ) ); | 209 | l.append( QString::number ( c.blue() ) ); |
210 | writeEntry( e, l ); | 210 | writeEntry( e, l ); |
211 | } | 211 | } |
212 | 212 | ||
213 | void KConfig::writeEntry( const QString & e , const QFont & f ) | 213 | void KConfig::writeEntry( const QString & e , const QFont & f ) |
214 | { | 214 | { |
215 | QStringList font; | 215 | QStringList font; |
216 | font.append( f.family()); | 216 | font.append( f.family()); |
217 | font.append( (!f.bold ()?"nonbold":"bold") ); | 217 | font.append( (!f.bold ()?"nonbold":"bold") ); |
218 | font.append( QString::number ( f.pointSize () ) ); | 218 | font.append( QString::number ( f.pointSize () ) ); |
219 | font.append( !f.italic ()?"nonitalic":"italic" ); | 219 | font.append( !f.italic ()?"nonitalic":"italic" ); |
220 | writeEntry( e, font ); | 220 | writeEntry( e, font ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) | 223 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) |
224 | { | 224 | { |
225 | mDateTimeMap.insert( mGroup + key, dt ); | 225 | mDateTimeMap.insert( mGroup + key, dt ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void KConfig::load() | 228 | void KConfig::load() |
229 | { | 229 | { |
230 | kdDebug() << "KConfig::load(): " << mFileName << endl; | 230 | kdDebug() << "KConfig::load(): " << mFileName << endl; |
231 | 231 | ||
232 | QFile f( mFileName ); | 232 | QFile f( mFileName ); |
233 | if ( !f.open( IO_ReadOnly ) ) { | 233 | if ( !f.open( IO_ReadOnly ) ) { |
234 | qDebug("KConfig: could not open file %s ",mFileName.latin1() ); | 234 | qDebug("KConfig: could not open file %s ",mFileName.latin1() ); |
235 | return; | 235 | return; |
236 | } | 236 | } |
237 | 237 | ||
238 | mBoolMap.clear(); | 238 | mBoolMap.clear(); |
239 | mStringMap.clear(); | 239 | mStringMap.clear(); |
240 | 240 | ||
241 | QTextStream t( &f ); | 241 | QTextStream t( &f ); |
242 | 242 | ||