OGS
VtkAlgorithmPropertyVectorEdit.cpp
Go to the documentation of this file.
1
15// ** INCLUDES **
17
18#include <QDoubleValidator>
19#include <QHBoxLayout>
20#include <QIntValidator>
21#include <QLineEdit>
22#include <QSize>
23#include <utility>
24
26
28 const QList<QString> contents,
29 QString name,
30 QVariant::Type type,
31 VtkAlgorithmProperties* algProps,
32 QWidget* parent /*= 0*/)
33 : QWidget(parent), _name(std::move(name)), _algProps(algProps), _type(type)
34{
35 auto* layout = new QHBoxLayout;
36 layout->setSpacing(3);
37 layout->setContentsMargins(0, 0, 0, 0);
38
39 foreach (QString content, contents)
40 {
41 auto* lineEdit = new QLineEdit(content, this);
42 layout->addWidget(lineEdit);
43
44 switch (_type)
45 {
46 case QVariant::Double:
47 lineEdit->setValidator(new QDoubleValidator(this));
48 break;
49
50 case QVariant::Int:
51 lineEdit->setValidator(new QIntValidator(this));
52 break;
53
54 default:
55 break;
56 }
57
58 connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(setNewValue()));
59 }
60
61 this->setLayout(layout);
62 this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
63}
64
66
68{
69 QLayout* layout = this->layout();
70 QList<QVariant> list;
71 for (int i = 0; i < layout->count(); ++i)
72 {
73 auto* lineEdit = static_cast<QLineEdit*>(layout->itemAt(i)->widget());
74 list.push_back(QVariant(lineEdit->text()));
75 }
76
78
79 emit editingFinished();
80}
Definition of the VtkAlgorithmProperties class.
Definition of the VtkAlgorithmPropertyVectorEdit class.
Contains properties for the visualization of objects as VtkVisPipelineItems.
virtual void SetUserVectorProperty(QString name, QList< QVariant > values)
Sets a vector user property. This should be implemented by subclasses.
void editingFinished()
Is emitted when text of one the line edits changed.
void setNewValue()
This slots is automatically called when the checkbox state changed.
VtkAlgorithmPropertyVectorEdit(const QList< QString > contents, QString name, QVariant::Type type, VtkAlgorithmProperties *algProps, QWidget *parent=nullptr)
Constructor.
~VtkAlgorithmPropertyVectorEdit() override