author | zecke <zecke> | 2002-09-28 19:07:36 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 19:07:36 (UTC) |
commit | a52cf21d13cc26844adbce20b24287563a559d14 (patch) (unidiff) | |
tree | 9b52103d853ec04661e1b813b202d471d0de8ad7 /noncore/apps | |
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 | |||
@@ -13,18 +13,24 @@ Profile::Profile( const QString& name, | |||
13 | { | 13 | { |
14 | } | 14 | } |
15 | Profile::Profile( const Profile& prof ) | 15 | Profile::Profile( const Profile& prof ) |
16 | { | 16 | { |
17 | (*this) = prof; | 17 | (*this) = prof; |
18 | } | 18 | } |
19 | bool Profile::operator==( const Profile& prof ) { | ||
20 | if ( m_name == prof.m_name ) return true; | ||
21 | |||
22 | return false; | ||
23 | } | ||
19 | Profile &Profile::operator=( const Profile& prof ) { | 24 | Profile &Profile::operator=( const Profile& prof ) { |
20 | m_name = prof.m_name; | 25 | m_name = prof.m_name; |
21 | m_ioLayer = prof.m_ioLayer; | 26 | m_ioLayer = prof.m_ioLayer; |
22 | m_back = prof.m_back; | 27 | m_back = prof.m_back; |
23 | m_fore = prof.m_fore; | 28 | m_fore = prof.m_fore; |
24 | m_terminal = prof.m_terminal; | 29 | m_terminal = prof.m_terminal; |
30 | m_conf = prof.m_conf; | ||
25 | 31 | ||
26 | return *this; | 32 | return *this; |
27 | } | 33 | } |
28 | Profile::~Profile() { | 34 | Profile::~Profile() { |
29 | } | 35 | } |
30 | QString Profile::name()const { | 36 | QString Profile::name()const { |
@@ -54,6 +60,47 @@ void Profile::setBackground( int back ) { | |||
54 | void Profile::setForeground( int fore ) { | 60 | void Profile::setForeground( int fore ) { |
55 | m_fore = fore; | 61 | m_fore = fore; |
56 | } | 62 | } |
57 | void Profile::setTerminal( int term ) { | 63 | void Profile::setTerminal( int term ) { |
58 | m_terminal = term; | 64 | m_terminal = term; |
59 | } | 65 | } |
66 | /* config stuff */ | ||
67 | void Profile::clearConf() { | ||
68 | m_conf.clear(); | ||
69 | } | ||
70 | void Profile::writeEntry( const QString& key, const QString& value ) { | ||
71 | m_conf.replace( key, value ); | ||
72 | } | ||
73 | void Profile::writeEntry( const QString& key, int num ) { | ||
74 | writeEntry( key, QString::number( num ) ); | ||
75 | } | ||
76 | void Profile::writeEntry( const QString& key, bool b ) { | ||
77 | writeEntry( key, QString::number(b) ); | ||
78 | } | ||
79 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { | ||
80 | writeEntry( key, lis.join(sep) ); | ||
81 | } | ||
82 | QString Profile::readEntry( const QString& key, const QString& deflt )const { | ||
83 | QMap<QString, QString>::ConstIterator it; | ||
84 | it = m_conf.find( key ); | ||
85 | |||
86 | if ( it != m_conf.end() ) | ||
87 | return it.data(); | ||
88 | |||
89 | return deflt; | ||
90 | } | ||
91 | int Profile::readNumEntry( const QString& key, int def )const { | ||
92 | QMap<QString, QString>::ConstIterator it; | ||
93 | it = m_conf.find( key ); | ||
94 | |||
95 | if ( it != m_conf.end() ) { | ||
96 | bool ok; | ||
97 | int val = it.data().toInt(&ok); | ||
98 | |||
99 | if (ok) | ||
100 | return val; | ||
101 | } | ||
102 | return def; | ||
103 | } | ||
104 | bool Profile::readBoolEntry( const QString& key, bool def )const { | ||
105 | return readNumEntry( key, def ); | ||
106 | } | ||
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 | |||
@@ -25,12 +25,13 @@ public: | |||
25 | const QString& iolayerName, | 25 | const QString& iolayerName, |
26 | int background, | 26 | int background, |
27 | int foreground, | 27 | int foreground, |
28 | int terminal); | 28 | int terminal); |
29 | Profile( const Profile& ); | 29 | Profile( const Profile& ); |
30 | Profile &operator=( const Profile& ); | 30 | Profile &operator=( const Profile& ); |
31 | bool operator==( const Profile& prof ); | ||
31 | 32 | ||
32 | ~Profile(); | 33 | ~Profile(); |
33 | QString name()const; | 34 | QString name()const; |
34 | QString ioLayerName()const; | 35 | QString ioLayerName()const; |
35 | int foreground()const; | 36 | int foreground()const; |
36 | int background()const; | 37 | int background()const; |