summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/profilemanager.cpp
blob: c8a4db591f8890047765627547170fa234b730ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
     */
    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?
     * set colors + fonts
     */
    return session;
}
void ProfileManager::save(  ) {
    ProfileConfig conf("opie-console-profiles");
    conf.clearAll();
    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
}