cppcheck/gui/variablecontractsdialog.cpp

50 lines
1.3 KiB
C++
Raw Normal View History

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),
mUI(new Ui::VariableContractsDialog)
2020-08-22 11:37:44 +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);
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);
};
mUI->mMinValue->setText(getMinMax(var, "min"));
mUI->mMaxValue->setText(getMinMax(var, "max"));
2020-08-22 11:37:44 +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()
{
delete mUI;
2020-08-22 11:37:44 +02:00
}
QString VariableContractsDialog::getVarname() const
{
return mVarName;
}
QString VariableContractsDialog::getMin() const
{
return mUI->mMinValue->text();
2020-08-22 11:37:44 +02:00
}
QString VariableContractsDialog::getMax() const
{
return mUI->mMaxValue->text();
2020-08-22 11:37:44 +02:00
}