summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-28 20:07:52 (UTC)
committer zecke <zecke>2002-09-28 20:07:52 (UTC)
commitb6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19 (patch) (side-by-side diff)
treea9cac491c119fb644ac75750cd715fce16c4c778
parentcb33923e1db6df3ead352f21c94b80a5785d70ca (diff)
downloadopie-b6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19.zip
opie-b6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19.tar.gz
opie-b6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19.tar.bz2
Profiles, loading and saving completed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/profile.cpp6
-rw-r--r--noncore/apps/opie-console/profile.h3
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp23
3 files changed, 26 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
index cdf595e..c8f5eb0 100644
--- a/noncore/apps/opie-console/profile.cpp
+++ b/noncore/apps/opie-console/profile.cpp
@@ -12,48 +12,51 @@ Profile::Profile( const QString& name,
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() {
}
+QMap<QString, QString> Profile::conf()const {
+ return m_conf;
+}
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;
}
@@ -83,24 +86,27 @@ 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 );
}
+void Profile::setConf( const QMap<QString, QString>& conf ) {
+ m_conf = conf;
+};
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h
index eff2be1..9956bdb 100644
--- a/noncore/apps/opie-console/profile.h
+++ b/noncore/apps/opie-console/profile.h
@@ -19,49 +19,50 @@ public:
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();
+ QMap<QString, QString> conf()const;
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 );
void setForeground( int fore );
void setTerminal( int term );
+ void setConf( const QMap<QString, QString>& );
private:
QMap<QString, QString> m_conf;
QString m_name;
QString m_ioLayer;
int m_back;
int m_fore;
int m_terminal;
};
#endif
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 54b184d..c8a4db5 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,65 +1,78 @@
#include <qpe/config.h>
#include "metafactory.h"
#include "profileconfig.h"
#include "profilemanager.h"
ProfileManager::ProfileManager( MetaFactory* fact )
: m_fact( fact )
{
}
ProfileManager::~ProfileManager() {
}
void ProfileManager::load() {
m_list.clear();
ProfileConfig conf("opie-console-profiles");
QStringList groups = conf.groups();
QStringList::Iterator it;
/*
* for each profile
*/
- /*
- * QAsciiDict Parsing FIXME
- */
for ( it = groups.begin(); it != groups.end(); ++it ) {
conf.setGroup( (*it) );
Profile prof;
prof.setName( conf.readEntry("name") );
prof.setIOLayer( conf.readEntry("iolayer") );
prof.setBackground( conf.readNumEntry("back") );
prof.setForeground( conf.readNumEntry("fore") );
prof.setTerminal( conf.readNumEntry("terminal") );
+ prof.setConf( conf.items( (*it) ) );
+ /* now add it */
m_list.append( prof );
}
}
void ProfileManager::clear() {
m_list.clear();
}
Profile::ValueList ProfileManager::all()const {
return m_list;
}
Session* ProfileManager::fromProfile( const Profile& prof) {
Session* session = new Session();
session->setName( prof.name() );
session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(),
prof) );
/*
* FIXME
* load emulation
- * load widget
+ * load widget?
* set colors + fonts
*/
return session;
}
void ProfileManager::save( ) {
ProfileConfig conf("opie-console-profiles");
conf.clearAll();
- Session* se= 0l;
+ Profile::ValueList::Iterator it;
+ for (it = m_list.begin(); it != m_list.end(); ++it ) {
+ conf.setGroup( (*it).name() );
+ conf.writeEntry( "name", (*it).name() );
+ conf.writeEntry( "ioplayer", (*it).ioLayerName() );
+ conf.writeEntry( "back", (*it).background() );
+ conf.writeEntry( "fore", (*it).foreground() );
+ conf.writeEntry( "terminal", (*it).terminal() );
+ /* now the config stuff */
+ QMap<QString, QString> map = (*it).conf();
+ QMap<QString, QString>::Iterator it;
+ for ( it = map.begin(); it != map.end(); ++it ) {
+ conf.writeEntry( it.key(), it.data() );
+ }
+ }
// FIXME save
}