Switch to unified view

a/src/qtgui/confgui/confgui.h b/src/qtgui/confgui/confgui.h
1
#ifndef _confgui_h_included_
1
#ifndef _confgui_h_included_
2
#define _confgui_h_included_
2
#define _confgui_h_included_
3
/* @(#$Id: confgui.h,v 1.5 2007-10-09 11:08:17 dockes Exp $  (C) 2007 J.F.Dockes */
3
/* @(#$Id: confgui.h,v 1.6 2007-10-19 14:31:40 dockes Exp $  (C) 2007 J.F.Dockes */
4
4
/**
5
 * This file defines a number of simple classes (virtual base: ConfParamW) 
6
 * which let the user input configuration parameters. 
7
 *
8
 * Subclasses are defined for entering different kind of data, ie a string, 
9
 * a file name, an integer, etc.
10
 *
11
 * Each configuration gui object is linked to the configuration data through
12
 * a "link" object which knows the details of interacting with the actual
13
 * configuration data, like the parameter name, the actual config object, 
14
 * the method to call etc.
15
 * 
16
 * The link object is set when the input widget is created and cannot be 
17
 * changed.
18
 *
19
 * The widgets are typically linked to a temporary configuration object, which
20
 * is then copied to the actual configuration if the data is accepted, or
21
 * destroyed and recreated as a copy if Cancel is pressed (you have to 
22
 * delete/recreate the widgets in this case as the links are no longer valid).
23
 */
5
#include <string>
24
#include <string>
6
25
7
#include <qglobal.h>
26
#include <qglobal.h>
8
#include <qstring.h>
27
#include <qstring.h>
9
#include <qwidget.h>
28
#include <qwidget.h>
...
...
35
    virtual bool set(const string& val) = 0;
54
    virtual bool set(const string& val) = 0;
36
    virtual bool get(string& val) = 0;
55
    virtual bool get(string& val) = 0;
37
    };
56
    };
38
    typedef RefCntr<ConfLinkRep> ConfLink;
57
    typedef RefCntr<ConfLinkRep> ConfLink;
39
58
59
    // Useful to store/manage data which has no direct representation in
60
    // the config, ie list of subkey directories
40
    class ConfLinkNullRep : public ConfLinkRep {
61
    class ConfLinkNullRep : public ConfLinkRep {
41
    public:
62
    public:
42
    virtual ~ConfLinkNullRep() {}
63
    virtual ~ConfLinkNullRep() {}
43
    virtual bool set(const string&)
64
    virtual bool set(const string&)
44
    {
65
    {
45
      //fprintf(stderr, "Setting value to [%s]\n", val.c_str());
46
        return true;
66
        return true;
47
    }
67
    }
48
    virtual bool get(string& val) {val = ""; return true;}
68
    virtual bool get(string& val) {val = ""; return true;}
49
    };
69
    };
50
70
51
    // A widget to let the user change one configuration
71
    // A widget to let the user change one configuration
52
    // parameter. Subclassed for specific parameter types
72
    // parameter. Subclassed for specific parameter types. Basically
73
    // has a label and some kind of entry widget
53
    class ConfParamW : public QWidget {
74
    class ConfParamW : public QWidget {
54
    Q_OBJECT
75
    Q_OBJECT
55
    public:
76
    public:
56
    ConfParamW(QWidget *parent, ConfLink cflink)
77
    ConfParamW(QWidget *parent, ConfLink cflink)
57
        : QWidget(parent), m_cflink(cflink)
78
        : QWidget(parent), m_cflink(cflink)