summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/metafactory.h
blob: bcc40db5bb41cbc68d9881750ea7e3c3afffd936 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef OPIE_META_FACTORY_H
#define OPIE_META_FACTORY_H

/**
 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
 * and to instantiate these implementations on demand
 */

#include <qwidget.h>
#include <qmap.h>

#include <qpe/config.h>

#include "io_layer.h"
#include "file_layer.h"
#include "receive_layer.h"
#include "profile.h"
#include "profiledialogwidget.h"

class WidgetLayer;
class MetaFactory {
public:
    typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
    typedef IOLayer* (*iolayer)(const Profile& );
    typedef FileTransferLayer* (*filelayer)(IOLayer*);
    typedef ReceiveLayer* (*receivelayer)(IOLayer*);

    MetaFactory();
    ~MetaFactory();

    /**
     *  add a ProfileDialogWidget to the factory
     * name is the name shown to the user
     */
    void addConnectionWidgetFactory( const QCString& internalName,
                                     const QString& uiString,
                                     configWidget );
    void addTerminalWidgetFactory  ( const QCString& internalName,
                                     const QString& name,
                                     configWidget );
    void addKeyboardWidgetFactory  ( const QCString& internalName,
                                     const QString& name,
                                     configWidget );

    /**
     *  adds an IOLayer factory
     */
    void addIOLayerFactory( const QCString&,
                            const QString&,
                            iolayer );

    /**
     * adds a FileTransfer Layer
     */
    void addFileTransferLayer( const QCString& name,
                               const QString&,
                               filelayer );
    void addReceiveLayer( const QCString& name,
                          const QString&,
                          receivelayer);


    /* translated UI Strings */
    QStringList ioLayers()const;
    QStringList connectionWidgets()const;

    /**
     * Terminal Configuration widgets
     */
    QStringList terminalWidgets()const;
    QStringList fileTransferLayers()const;
    QStringList receiveLayers()const;

    /**
     * the generation...
     */
    IOLayer* newIOLayer( const QString&,const Profile& );
    ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
    ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
    ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* );
    FileTransferLayer* newFileTransfer(const QString&, IOLayer* );
    ReceiveLayer* newReceive(const QString&, IOLayer* );

    /*
     * internal takes the maybe translated
     * public QString and maps it to the internal
     * not translatable QCString
     */
    QCString internal( const QString& )const;

    /*
     * external takes the internal name
     * it returns a translated name
     */
    QString external( const QCString& )const;


private:
    QMap<QString, QCString> m_strings;
    QMap<QString, configWidget> m_conFact;
    QMap<QString, configWidget> m_termFact;
    QMap<QString, configWidget> m_keyFact;
    QMap<QString, iolayer> m_layerFact;
    QMap<QString, filelayer> m_fileFact;
    QMap<QString, receivelayer> m_receiveFact;
};


#endif