PeriDyno 1.0.0
Loading...
Searching...
No Matches
QBoolFieldWidget.cpp
Go to the documentation of this file.
1#include "QBoolFieldWidget.h"
2
3#include <QHBoxLayout>
4#include <QCheckBox>
5#include <QLabel>
6
7#include "Field.h"
8#include "Format.h"
9
10namespace dyno
11{
13
16 {
18 if (f == nullptr) {
19 return;
20 }
21
22 //this->setStyleSheet("border:none");
23 QHBoxLayout* layout = new QHBoxLayout;
24 layout->setContentsMargins(0, 0, 0, 0);
25 layout->setSpacing(0);
26
27 this->setLayout(layout);
28
29 QLabel* name = new QLabel();
30 name->setFixedHeight(24);
31 name->setText(FormatFieldWidgetName(field->getObjectName()));
32 QCheckBox* checkbox = new QCheckBox();
33 checkbox->setFixedWidth(20);
34 //checkbox->setFixedSize(40, 18);
35 layout->addWidget(name, 0);
36 layout->addStretch(1);
37 layout->addWidget(checkbox, 0);
38
39 checkbox->setChecked(f->getValue());
40
41 connect(checkbox, SIGNAL(stateChanged(int)), this, SLOT(updateField(int)));
42 }
43
45 {
47 if (f == nullptr)
48 {
49 return;
50 }
51
52 if (status == Qt::Checked)
53 {
54 f->setValue(true);
55 f->update();
56 }
57 else if (status == Qt::PartiallyChecked)
58 {
59 //m_pLabel->setText("PartiallyChecked");
60 }
61 else
62 {
63 f->setValue(false);
64 f->update();
65 }
66
67 emit fieldChanged();
68 }
69
70}
71
#define IMPL_FIELD_WIDGET(_data_type_, _type_)
virtual void update()
Definition FBase.cpp:201
T getValue()
Definition Field.h:130
void setValue(T val)
Definition Field.h:111
void updateField(int status)
DECLARE_FIELD_WIDGET QBoolFieldWidget(FBase *field)
QFieldWidget(FBase *field)
TA * cast(TB *b)
Definition Typedef.inl:286
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
QString FormatFieldWidgetName(std::string name)
Definition Format.cpp:9