2020-08-22 11:37:44 +02:00
|
|
|
#include "variablecontractsdialog.h"
|
|
|
|
#include "ui_variablecontractsdialog.h"
|
|
|
|
|
|
|
|
#include <QRegExpValidator>
|
|
|
|
|
|
|
|
VariableContractsDialog::VariableContractsDialog(QWidget *parent, QString var) :
|
|
|
|
QDialog(parent),
|
2020-08-24 22:11:07 +02:00
|
|
|
mUI(new Ui::VariableContractsDialog)
|
2020-08-22 11:37:44 +02:00
|
|
|
{
|
2020-08-24 22:11:07 +02:00
|
|
|
mUI->setupUi(this);
|
2020-08-22 11:37:44 +02:00
|
|
|
|
|
|
|
mVarName = var.indexOf(" ") < 0 ? var : var.mid(0, var.indexOf(" "));
|
|
|
|
|
|
|
|
this->setWindowTitle(mVarName);
|
|
|
|
|
2022-01-18 20:17:05 +01:00
|
|
|
auto getMinMax = [](const QString& var, const QString& minmax) {
|
2020-08-22 11:37:44 +02:00
|
|
|
if (var.indexOf(" " + minmax + ":") < 0)
|
|
|
|
return QString();
|
|
|
|
int pos1 = var.indexOf(" " + minmax + ":") + 2 + minmax.length();
|
|
|
|
int pos2 = var.indexOf(" ", pos1);
|
|
|
|
if (pos2 < 0)
|
|
|
|
return var.mid(pos1);
|
|
|
|
return var.mid(pos1, pos2-pos1);
|
|
|
|
};
|
|
|
|
|
2020-08-24 22:11:07 +02:00
|
|
|
mUI->mMinValue->setText(getMinMax(var, "min"));
|
|
|
|
mUI->mMaxValue->setText(getMinMax(var, "max"));
|
2020-08-22 11:37:44 +02:00
|
|
|
|
2020-08-24 22:11:07 +02:00
|
|
|
mUI->mMinValue->setValidator(new QRegExpValidator(QRegExp("-?[0-9]*")));
|
|
|
|
mUI->mMaxValue->setValidator(new QRegExpValidator(QRegExp("-?[0-9]*")));
|
2020-08-22 11:37:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VariableContractsDialog::~VariableContractsDialog()
|
|
|
|
{
|
2020-08-24 22:11:07 +02:00
|
|
|
delete mUI;
|
2020-08-22 11:37:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString VariableContractsDialog::getVarname() const
|
|
|
|
{
|
|
|
|
return mVarName;
|
|
|
|
}
|
|
|
|
QString VariableContractsDialog::getMin() const
|
|
|
|
{
|
2020-08-24 22:11:07 +02:00
|
|
|
return mUI->mMinValue->text();
|
2020-08-22 11:37:44 +02:00
|
|
|
}
|
|
|
|
QString VariableContractsDialog::getMax() const
|
|
|
|
{
|
2020-08-24 22:11:07 +02:00
|
|
|
return mUI->mMaxValue->text();
|
2020-08-22 11:37:44 +02:00
|
|
|
}
|