Repository navigation
Expand file tree
/
Copy pathParameterEditor.h
More file actions
65 lines (54 loc) · 1.65 KB
/
Copy pathParameterEditor.h
File metadata and controls
65 lines (54 loc) · 1.65 KB
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
#ifndef PARAMETEREDITOR_H
#define PARAMETEREDITOR_H
#include "cppGUI_global.h"
#include "ParameterList.h"
#include <QPointer>
#include <QWidget>
class QLabel;
namespace Ui {
class ParameterEditor;
}
//Edits a referenced ParameterList. Loading captures the values used by Reset.
class CPPGUISHARED_EXPORT ParameterEditor : public QWidget
{
Q_OBJECT
public:
ParameterEditor(ParameterList& parameters, QWidget* parent = nullptr);
~ParameterEditor() override;
//Disable and hide auto-apply checkbox
void disableAutoApply();
//Sets the name of the parameter owner. An empty title hides it.
void setName(const QString& title);
//Binds the list and rebuilds the controls. Also called when its constraints change.
void load(ParameterList& parameters);
//Stores all fields if valid; returns false without changing the list otherwise.
bool store();
public slots:
//Restores the last loaded values. Auto-apply also writes valid restored values.
void reset();
signals:
//Emitted after one or more parameter values have been applied.
void settingsApplied();
private:
struct Field
{
Parameter parameter;
QWidget* editor;
QLabel* error;
QVariant loaded_value;
QVariant displayed_value;
QString displayed_text;
};
QPointer<ParameterList> parameters_;
QList<Field> fields_;
Ui::ParameterEditor* ui_;
bool updating_ = false;
bool applying_ = false;
QWidget* createEditor(const Parameter& parameter);
QVariant editorValue(const Field& field) const;
void setEditorValue(Field& field, const QVariant& value);
QHash<QByteArray, QVariant> validValues(bool& all_valid);
bool applyValues(bool require_all_valid);
void edited();
};
#endif // PARAMETEREDITOR_H