2022-01-28 15:56:11 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
|
|
|
* Copyright (C) 2007-2021 Cppcheck team.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-08-22 11:37:44 +02:00
|
|
|
#include "variablecontractsdialog.h"
|
2022-02-02 16:17:28 +01:00
|
|
|
|
2020-08-22 11:37:44 +02:00
|
|
|
#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
|
|
|
}
|