author | zecke <zecke> | 2002-09-28 19:07:36 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 19:07:36 (UTC) |
commit | a52cf21d13cc26844adbce20b24287563a559d14 (patch) (side-by-side diff) | |
tree | 9b52103d853ec04661e1b813b202d471d0de8ad7 | |
parent | bc88219d0a9cf935d90c88fe75e238e86c675937 (diff) | |
download | opie-a52cf21d13cc26844adbce20b24287563a559d14.zip opie-a52cf21d13cc26844adbce20b24287563a559d14.tar.gz opie-a52cf21d13cc26844adbce20b24287563a559d14.tar.bz2 |
some more implementation of the Config stuff
-rw-r--r-- | noncore/apps/opie-console/profile.cpp | 47 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 1 |
2 files changed, 48 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp index b730218..cdf595e 100644 --- a/noncore/apps/opie-console/profile.cpp +++ b/noncore/apps/opie-console/profile.cpp @@ -1,59 +1,106 @@ #include "profile.h" Profile::Profile() { } Profile::Profile( const QString& name, const QString& iolayerName, int background, int foreground, int terminal ) : m_name( name ), m_ioLayer( iolayerName ), m_back( background ), m_fore( foreground ), m_terminal( terminal ) { } Profile::Profile( const Profile& prof ) { (*this) = prof; } +bool Profile::operator==( const Profile& prof ) { + if ( m_name == prof.m_name ) return true; + + return false; +} Profile &Profile::operator=( const Profile& prof ) { m_name = prof.m_name; m_ioLayer = prof.m_ioLayer; m_back = prof.m_back; m_fore = prof.m_fore; m_terminal = prof.m_terminal; + m_conf = prof.m_conf; return *this; } Profile::~Profile() { } QString Profile::name()const { return m_name; } QString Profile::ioLayerName()const { return m_ioLayer; } int Profile::foreground()const { return m_fore; } int Profile::background()const { return m_back; } int Profile::terminal()const { return m_terminal; } void Profile::setName( const QString& str ) { m_name = str; } void Profile::setIOLayer( const QString& name ) { m_ioLayer = name; } void Profile::setBackground( int back ) { m_back = back; } void Profile::setForeground( int fore ) { m_fore = fore; } void Profile::setTerminal( int term ) { m_terminal = term; } +/* config stuff */ +void Profile::clearConf() { + m_conf.clear(); +} +void Profile::writeEntry( const QString& key, const QString& value ) { + m_conf.replace( key, value ); +} +void Profile::writeEntry( const QString& key, int num ) { + writeEntry( key, QString::number( num ) ); +} +void Profile::writeEntry( const QString& key, bool b ) { + writeEntry( key, QString::number(b) ); +} +void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { + writeEntry( key, lis.join(sep) ); +} +QString Profile::readEntry( const QString& key, const QString& deflt )const { + QMap<QString, QString>::ConstIterator it; + it = m_conf.find( key ); + + if ( it != m_conf.end() ) + return it.data(); + + return deflt; +} +int Profile::readNumEntry( const QString& key, int def )const { + QMap<QString, QString>::ConstIterator it; + it = m_conf.find( key ); + + if ( it != m_conf.end() ) { + bool ok; + int val = it.data().toInt(&ok); + + if (ok) + return val; + } + return def; +} +bool Profile::readBoolEntry( const QString& key, bool def )const { + return readNumEntry( key, def ); +} diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 8adc0bd..eff2be1 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h @@ -7,48 +7,49 @@ #include <qvaluelist.h> /** * A session will be generated from a saved * profile. A profile contains the iolayername * a name. * We can generate a Session from a Profile * No configuration is contained here.... */ class Profile { public: typedef QValueList<Profile> ValueList; enum Color { Black = 0, White, Gray }; enum Terminal {VT102 = 0 }; enum Font { Micro = 0, Small, Medium }; Profile(); Profile( const QString& name, const QString& iolayerName, int background, int foreground, int terminal); Profile( const Profile& ); Profile &operator=( const Profile& ); + bool operator==( const Profile& prof ); ~Profile(); QString name()const; QString ioLayerName()const; int foreground()const; int background()const; int terminal()const; /* * config stuff */ QMap<QString, QString> conf(); void clearConf(); void writeEntry( const QString& key, const QString& value ); void writeEntry( const QString& key, int num ); void writeEntry( const QString& key, bool b ); void writeEntry( const QString& key, const QStringList&, const QChar& ); QString readEntry( const QString& key, const QString& deflt = QString::null)const; int readNumEntry( const QString& key, int = -1 )const; bool readBoolEntry( const QString& key, bool = FALSE )const; void setName( const QString& ); void setIOLayer( const QString& ); void setBackground( int back ); |