76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
#ifndef ATTRIBUTE_DIALOG_H
|
|
#define ATTRIBUTE_DIALOG_H
|
|
|
|
#include <QIntValidator>
|
|
#include <QGroupBox>
|
|
#include <QRadioButton>
|
|
#include <QDialog>
|
|
#include <QLineEdit>
|
|
#include <QLabel>
|
|
#include <QVBoxLayout>
|
|
#include <comdel/domain/instanceattribute.h>
|
|
|
|
#include <comdel/domain/value.h>
|
|
|
|
namespace display {
|
|
|
|
class AttributeDialog: public QDialog {
|
|
|
|
public:
|
|
AttributeDialog(domain::InstanceAttribute *attribute) {
|
|
this->setWindowTitle(QString::fromStdString("Izmjeni " + attribute->attribute.getName()));
|
|
|
|
auto layout = new QVBoxLayout(this);
|
|
this->setLayout(layout);
|
|
auto popup = *attribute->attribute.getPopup();
|
|
|
|
layout->addWidget(new QLabel(popup.getTitle().c_str()));
|
|
layout->addWidget(new QLabel(popup.getText().c_str()));
|
|
|
|
auto type = attribute->attribute.getDefault().getType();
|
|
|
|
if(attribute->attribute.getPopup()->isEnumerated()) {
|
|
|
|
} else if(!(type == domain::Value::ValueType::WIRE_REFERENCE || type == domain::Value::ValueType::BOOL)) {
|
|
|
|
auto edit = new QLineEdit(this);
|
|
layout->addWidget(edit);
|
|
|
|
switch (attribute->attribute.getDefault().getType()) {
|
|
case domain::Value::ValueType::INT:
|
|
edit->setValidator(new QIntValidator(-10000000, 10000000, edit));
|
|
edit->insert(std::to_string(attribute->value.asInt()).c_str());
|
|
break;
|
|
case domain::Value::ValueType::STRING:
|
|
edit->insert(attribute->value.asString().c_str());
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
} else if(type == domain::Value::ValueType::BOOL) {
|
|
auto *group = new QGroupBox(this);
|
|
group->setCheckable(true);
|
|
group->setChecked(true);
|
|
|
|
auto isTrue = new QRadioButton("true", group);
|
|
auto isFalse = new QRadioButton("false", group);
|
|
|
|
if(attribute->value.asBool()) {
|
|
isTrue->setChecked(true);
|
|
} else {
|
|
isFalse->setChecked(true);
|
|
}
|
|
|
|
|
|
|
|
layout->addWidget(group);
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif //ATTRIBUTE_DIALOG_H
|