summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/metafactory.cpp
blob: ea7f739c7ade1a9a712d5d8e07d49e3b5e8f1760 (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
#include <qpe/config.h>
#include "metafactory.h"

MetaFactory::MetaFactory() {
}
MetaFactory::~MetaFactory() {

}
void MetaFactory::addConfigWidgetFactory( const QString& str,
                                          const QString& name,
                                          configWidget wid) {
    m_namemap.insert ( str, name );
    m_confFact.insert( str, wid );
}
void MetaFactory::addIOLayerFactory( const QString& str,
                                     iolayer lay) {
    m_layerFact.insert( str, lay );
}
void MetaFactory::addFileTransferLayer( const QString& str,
                                        filelayer lay) {
    m_fileFact.insert( str, lay );
}
QStringList MetaFactory::ioLayers()const {
    QStringList list;
    QMap<QString, iolayer>::ConstIterator it;
    for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
        list << it.key();
    }
    return list;
}
QStringList MetaFactory::configWidgets()const {
    QStringList list;
    QMap<QString,  configWidget>::ConstIterator it;
    for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) {
        list << it.key();
    }
    return list;
}
QStringList MetaFactory::fileTransferLayers()const {
    QStringList list;
    QMap<QString, filelayer>::ConstIterator it;
    for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
        list << it.key();
    }
    return list;
}

IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
    IOLayer* lay = 0l;

    QMap<QString, iolayer>::Iterator it;
    it = m_layerFact.find( str );
    if ( it != m_layerFact.end() ) {
        lay = (*(it.data()))(prof);
        /*
        iolayer laye = it.data();
        lay = (*laye )(conf);*/
    }

    return lay;
}

QWidget *MetaFactory::newConfigWidget ( const QString& str, QWidget* parent) {
    QWidget *w = NULL;
    configWidget c;

    c = m_confFact[str];
    if(c) w = c(parent);

    return w;
}

QString MetaFactory::name( const QString& str ) {
    return m_namemap[str];
}