-rw-r--r-- | microkde/kconfig.cpp | 26 |
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 @@ -80,64 +80,83 @@ QValueList<int> KConfig::readIntListEntry( const QString & key) } if (ok2 == false) { qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); } return result; } int KConfig::readNumEntry( const QString & key, int def ) { QString res = readEntry(key, QString::number(def ) ); bool ok = false; int result = res.toInt(&ok); if ( ok ) return result; 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; } +QSize KConfig::readSizeEntry( const QString &key, QSize* def ) +{ + QValueList<int> intlist = readIntListEntry(key); + + if (intlist.count() < 2) + { + if (def) + return *def; + else + return QSize(); + } + + QSize ret; + ret.setWidth(intlist[0]); + ret.setHeight(intlist[1]); + + return ret; +} + QStringList KConfig::readListEntry( const QString &key ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return QStringList(); } return QStringList::split(":", *it ); } 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 & e, QColor *def ) { QStringList l; l = readListEntry( e ); if (l.count() != 3 ) { if ( def ) return *def; else return QColor(); @@ -193,64 +212,71 @@ void KConfig::writeEntry( const QString & key , int num ) } void KConfig::writeEntry( const QString &key, const QString &value ) { mStringMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString &key, const QStringList &value ) { mStringMap.insert( mGroup + key, value.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString &key, bool value) { mBoolMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString & e, const QColor & c ) { QStringList l; l.append( QString::number ( c.red() ) ); l.append( QString::number ( c.green() ) ); l.append( QString::number ( c.blue() ) ); writeEntry( e, l ); } +void KConfig::writeEntry( const QString & e, const QSize & s ) +{ + QValueList<int> intlist; + intlist << s.width() << s.height(); + writeEntry( e, intlist ); +} + void KConfig::writeEntry( const QString & e , const QFont & f ) { QStringList font; font.append( f.family()); font.append( (!f.bold ()?"nonbold":"bold") ); font.append( QString::number ( f.pointSize () ) ); font.append( !f.italic ()?"nonitalic":"italic" ); writeEntry( e, font ); } void KConfig::writeEntry( const QString &key, const QDateTime &dt ) { mDateTimeMap.insert( mGroup + key, dt ); } void KConfig::load() { QFile f( mFileName ); if ( !f.open( IO_ReadOnly ) ) { qDebug("KConfig: could not open file %s ",mFileName.latin1() ); return; } mBoolMap.clear(); mStringMap.clear(); QTextStream t( &f ); QString line = t.readLine(); |