summaryrefslogtreecommitdiffabout
path: root/microkde/kconfig.cpp
Unidiff
Diffstat (limited to 'microkde/kconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kconfig.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index 4cbec94..ba41f6c 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -88,48 +88,67 @@ QValueList<int> KConfig::readIntListEntry( const QString & key)
88 return result; 88 return result;
89} 89}
90 90
91int KConfig::readNumEntry( const QString & key, int def ) 91int KConfig::readNumEntry( const QString & key, int def )
92{ 92{
93 QString res = readEntry(key, QString::number(def ) ); 93 QString res = readEntry(key, QString::number(def ) );
94 bool ok = false; 94 bool ok = false;
95 int result = res.toInt(&ok); 95 int result = res.toInt(&ok);
96 if ( ok ) 96 if ( ok )
97 return result; 97 return result;
98 return def; 98 return def;
99} 99}
100 100
101QString KConfig::readEntry( const QString &key, const QString &def ) 101QString KConfig::readEntry( const QString &key, const QString &def )
102{ 102{
103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
104 104
105 if ( it == mStringMap.end() ) { 105 if ( it == mStringMap.end() ) {
106 return def; 106 return def;
107 } 107 }
108 108
109 return *it; 109 return *it;
110} 110}
111 111
112QSize KConfig::readSizeEntry( const QString &key, QSize* def )
113{
114 QValueList<int> intlist = readIntListEntry(key);
115
116 if (intlist.count() < 2)
117 {
118 if (def)
119 return *def;
120 else
121 return QSize();
122 }
123
124 QSize ret;
125 ret.setWidth(intlist[0]);
126 ret.setHeight(intlist[1]);
127
128 return ret;
129}
130
112QStringList KConfig::readListEntry( const QString &key ) 131QStringList KConfig::readListEntry( const QString &key )
113{ 132{
114 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
115 134
116 if ( it == mStringMap.end() ) { 135 if ( it == mStringMap.end() ) {
117 return QStringList(); 136 return QStringList();
118 } 137 }
119 return QStringList::split(":", *it ); 138 return QStringList::split(":", *it );
120 139
121} 140}
122 141
123bool KConfig::readBoolEntry( const QString &key, bool def ) 142bool KConfig::readBoolEntry( const QString &key, bool def )
124{ 143{
125 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
126 145
127 if ( it == mBoolMap.end() ) { 146 if ( it == mBoolMap.end() ) {
128 return def; 147 return def;
129 } 148 }
130 149
131 return *it; 150 return *it;
132} 151}
133 152
134QColor KConfig::readColorEntry( const QString & e, QColor *def ) 153QColor KConfig::readColorEntry( const QString & e, QColor *def )
135{ 154{
@@ -201,48 +220,55 @@ void KConfig::writeEntry( const QString &key, const QString &value )
201 220
202void KConfig::writeEntry( const QString &key, const QStringList &value ) 221void KConfig::writeEntry( const QString &key, const QStringList &value )
203{ 222{
204 mStringMap.insert( mGroup + key, value.join(":") ); 223 mStringMap.insert( mGroup + key, value.join(":") );
205 224
206 mDirty = true; 225 mDirty = true;
207} 226}
208 227
209void KConfig::writeEntry( const QString &key, bool value) 228void KConfig::writeEntry( const QString &key, bool value)
210{ 229{
211 mBoolMap.insert( mGroup + key, value ); 230 mBoolMap.insert( mGroup + key, value );
212 231
213 mDirty = true; 232 mDirty = true;
214} 233}
215 234
216void KConfig::writeEntry( const QString & e, const QColor & c ) 235void KConfig::writeEntry( const QString & e, const QColor & c )
217{ 236{
218 QStringList l; 237 QStringList l;
219 l.append( QString::number ( c.red() ) ); 238 l.append( QString::number ( c.red() ) );
220 l.append( QString::number ( c.green() ) ); 239 l.append( QString::number ( c.green() ) );
221 l.append( QString::number ( c.blue() ) ); 240 l.append( QString::number ( c.blue() ) );
222 writeEntry( e, l ); 241 writeEntry( e, l );
223} 242}
224 243
244void KConfig::writeEntry( const QString & e, const QSize & s )
245{
246 QValueList<int> intlist;
247 intlist << s.width() << s.height();
248 writeEntry( e, intlist );
249}
250
225void KConfig::writeEntry( const QString & e , const QFont & f ) 251void KConfig::writeEntry( const QString & e , const QFont & f )
226{ 252{
227 QStringList font; 253 QStringList font;
228 font.append( f.family()); 254 font.append( f.family());
229 font.append( (!f.bold ()?"nonbold":"bold") ); 255 font.append( (!f.bold ()?"nonbold":"bold") );
230 font.append( QString::number ( f.pointSize () ) ); 256 font.append( QString::number ( f.pointSize () ) );
231 font.append( !f.italic ()?"nonitalic":"italic" ); 257 font.append( !f.italic ()?"nonitalic":"italic" );
232 writeEntry( e, font ); 258 writeEntry( e, font );
233} 259}
234 260
235void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 261void KConfig::writeEntry( const QString &key, const QDateTime &dt )
236{ 262{
237 mDateTimeMap.insert( mGroup + key, dt ); 263 mDateTimeMap.insert( mGroup + key, dt );
238} 264}
239 265
240void KConfig::load() 266void KConfig::load()
241{ 267{
242 268
243 269
244 QFile f( mFileName ); 270 QFile f( mFileName );
245 if ( !f.open( IO_ReadOnly ) ) { 271 if ( !f.open( IO_ReadOnly ) ) {
246 qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 272 qDebug("KConfig: could not open file %s ",mFileName.latin1() );
247 return; 273 return;
248 } 274 }