OGS
VtkAlgorithmPropertyVectorEdit Class Reference

Detailed Description

This edit widget consists of several QLineEdit to set a user vector property on the given VtkAlgorithmProperties object automatically.

Definition at line 25 of file VtkAlgorithmPropertyVectorEdit.h.

#include <VtkAlgorithmPropertyVectorEdit.h>

Inheritance diagram for VtkAlgorithmPropertyVectorEdit:
[legend]
Collaboration diagram for VtkAlgorithmPropertyVectorEdit:
[legend]

Signals

void editingFinished ()
 Is emitted when text of one the line edits changed.

Public Member Functions

 VtkAlgorithmPropertyVectorEdit (const QList< QString > contents, QString name, QVariant::Type type, VtkAlgorithmProperties *algProps, QWidget *parent=nullptr)
 Constructor.
 ~VtkAlgorithmPropertyVectorEdit () override

Private Slots

void setNewValue ()
 This slots is automatically called when the checkbox state changed.

Private Attributes

const QString _name
VtkAlgorithmProperties_algProps
QVariant::Type _type

Constructor & Destructor Documentation

◆ VtkAlgorithmPropertyVectorEdit()

VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit ( const QList< QString > contents,
QString name,
QVariant::Type type,
VtkAlgorithmProperties * algProps,
QWidget * parent = nullptr )

Constructor.

Parameters
contentsThe initial values of the text edits.
nameThe name of the user property to set.
typeThe type of the property.
algPropsThe VtkAlgorithmProperties object.
parentThe parent widget.

Definition at line 27 of file VtkAlgorithmPropertyVectorEdit.cpp.

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}
void editingFinished()
Is emitted when text of one the line edits changed.
void setNewValue()
This slots is automatically called when the checkbox state changed.

References _algProps, _name, _type, editingFinished(), and setNewValue().

◆ ~VtkAlgorithmPropertyVectorEdit()

VtkAlgorithmPropertyVectorEdit::~VtkAlgorithmPropertyVectorEdit ( )
overridedefault

Member Function Documentation

◆ editingFinished

void VtkAlgorithmPropertyVectorEdit::editingFinished ( )
signal

Is emitted when text of one the line edits changed.

Referenced by VtkAlgorithmPropertyVectorEdit(), and setNewValue().

◆ setNewValue

void VtkAlgorithmPropertyVectorEdit::setNewValue ( )
privateslot

This slots is automatically called when the checkbox state changed.

Definition at line 67 of file VtkAlgorithmPropertyVectorEdit.cpp.

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
77 _algProps->SetUserVectorProperty(_name, list);
78
79 emit editingFinished();
80}

References _algProps, _name, and editingFinished().

Referenced by VtkAlgorithmPropertyVectorEdit().

Member Data Documentation

◆ _algProps

VtkAlgorithmProperties* VtkAlgorithmPropertyVectorEdit::_algProps
private

Definition at line 45 of file VtkAlgorithmPropertyVectorEdit.h.

Referenced by VtkAlgorithmPropertyVectorEdit(), and setNewValue().

◆ _name

const QString VtkAlgorithmPropertyVectorEdit::_name
private

Definition at line 44 of file VtkAlgorithmPropertyVectorEdit.h.

Referenced by VtkAlgorithmPropertyVectorEdit(), and setNewValue().

◆ _type

QVariant::Type VtkAlgorithmPropertyVectorEdit::_type
private

Definition at line 46 of file VtkAlgorithmPropertyVectorEdit.h.

Referenced by VtkAlgorithmPropertyVectorEdit().


The documentation for this class was generated from the following files: