2022-04-19 06:16:41 +00:00
|
|
|
#ifndef ATTRIBUTE_DIALOG_H
|
|
|
|
#define ATTRIBUTE_DIALOG_H
|
|
|
|
|
|
|
|
#include <QIntValidator>
|
2022-05-15 14:13:29 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QComboBox>
|
2022-04-19 06:16:41 +00:00
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QVBoxLayout>
|
2022-05-15 16:38:17 +00:00
|
|
|
#include <utility>
|
2022-05-27 06:18:17 +00:00
|
|
|
#include <comdel/domain/instance_attribute.h>
|
2022-04-19 06:16:41 +00:00
|
|
|
|
|
|
|
#include <comdel/domain/value.h>
|
2022-05-27 06:18:17 +00:00
|
|
|
#include "comdel/domain/comdel_validator.h"
|
2022-04-19 06:16:41 +00:00
|
|
|
|
|
|
|
namespace display {
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
class AttributeDialog : public QDialog {
|
|
|
|
domain::Value value;
|
2022-05-15 14:13:29 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
long long int parseInt(std::string expression) {
|
|
|
|
try {
|
|
|
|
if (expression.size() > 2) {
|
|
|
|
if (expression.substr(0, 2) == "0x") {
|
|
|
|
return std::stoll(expression, nullptr, 16);
|
|
|
|
} else if (expression.substr(0, 2) == "0b") {
|
|
|
|
return std::stoll(expression, nullptr, 2);
|
|
|
|
} else {
|
|
|
|
return std::stoll(expression, nullptr, 10);
|
|
|
|
}
|
2022-05-15 14:13:29 +00:00
|
|
|
} else {
|
2022-05-27 06:18:17 +00:00
|
|
|
return std::stoll(expression, nullptr, 10);
|
2022-05-15 14:13:29 +00:00
|
|
|
}
|
2022-05-27 06:18:17 +00:00
|
|
|
} catch (std::exception &e) {
|
|
|
|
return 0;
|
2022-05-15 14:13:29 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
domain::InstanceAttribute *attributeValue;
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
public:
|
2022-06-09 18:24:27 +00:00
|
|
|
AttributeDialog(domain::InstanceAttribute *attribute, bool updating = true);
|
2022-05-15 14:13:29 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
public slots:
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
void onTextChanged(const QString &string);
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
void onEnumerationChanged(int index);
|
2022-05-15 14:13:29 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
void onUpdate();
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-15 14:13:29 +00:00
|
|
|
};
|
|
|
|
|
2022-04-19 06:16:41 +00:00
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
class MemoryDialog : public QDialog {
|
2022-05-15 21:55:03 +00:00
|
|
|
domain::Value value;
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
domain::InstanceAttribute *attributeValue;
|
2022-05-15 21:55:03 +00:00
|
|
|
std::vector<std::string> memoryInstances;
|
|
|
|
|
|
|
|
public:
|
2022-05-27 06:18:17 +00:00
|
|
|
MemoryDialog(domain::InstanceAttribute *attribute,
|
2022-06-09 18:24:27 +00:00
|
|
|
std::vector<std::shared_ptr<domain::ComponentInstance>> instances, bool updating = true);
|
2022-05-15 21:55:03 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
void onMemoryChanged(int index);
|
2022-05-15 21:55:03 +00:00
|
|
|
|
|
|
|
void onUpdate();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
class ErrorDialog : public QDialog {
|
2022-05-15 16:38:17 +00:00
|
|
|
public:
|
2022-05-27 06:18:17 +00:00
|
|
|
ErrorDialog(std::vector<domain::ValidationError> errors);
|
2022-05-15 16:38:17 +00:00
|
|
|
};
|
|
|
|
|
2022-05-27 06:18:17 +00:00
|
|
|
class WarningDialog : public QDialog {
|
2022-05-15 16:38:17 +00:00
|
|
|
public:
|
2022-05-27 06:18:17 +00:00
|
|
|
WarningDialog(domain::ValidationError error);
|
2022-05-15 16:38:17 +00:00
|
|
|
};
|
|
|
|
|
2022-04-19 06:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //ATTRIBUTE_DIALOG_H
|