Refactoring.
This commit is contained in:
parent
672278209d
commit
22d21a867a
|
@ -405,6 +405,37 @@ void DialogSetupMultisize::ZDimensionBodyMeasurementChanged()
|
|||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::CheckDimension(QGroupBox *group, QGroupBox *nameGroup, QLineEdit *lineEdit,
|
||||
bool &dimensionValid, int &dimensions,
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(group != nullptr)
|
||||
SCASSERT(nameGroup != nullptr)
|
||||
SCASSERT(lineEdit != nullptr)
|
||||
|
||||
if (group->isChecked())
|
||||
{
|
||||
dimensionValid = dimension->IsValid();
|
||||
++dimensions;
|
||||
|
||||
if (ui->labelError->text().isEmpty() && not dimensionValid)
|
||||
{
|
||||
ui->labelError->setText(tr("Please, provide correct data for dimension %1").arg(dimension->Axis()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nameGroup->isChecked() && lineEdit->text().isEmpty())
|
||||
{
|
||||
if (ui->labelError->text().isEmpty())
|
||||
{
|
||||
ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::CheckState()
|
||||
{
|
||||
|
@ -417,35 +448,6 @@ void DialogSetupMultisize::CheckState()
|
|||
|
||||
int dimensions = 0;
|
||||
|
||||
auto CheckDimension = [this](QGroupBox *group, QGroupBox *nameGroup, QLineEdit *lineEdit, bool &dimensionValid,
|
||||
int &dimensions, const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(group != nullptr)
|
||||
SCASSERT(nameGroup != nullptr)
|
||||
SCASSERT(lineEdit != nullptr)
|
||||
|
||||
if (group->isChecked())
|
||||
{
|
||||
dimensionValid = dimension->IsValid();
|
||||
++dimensions;
|
||||
|
||||
if (ui->labelError->text().isEmpty() && not dimensionValid)
|
||||
{
|
||||
ui->labelError->setText(tr("Please, provide correct data for dimension %1").arg(dimension->Axis()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nameGroup->isChecked() && lineEdit->text().isEmpty())
|
||||
{
|
||||
if (ui->labelError->text().isEmpty())
|
||||
{
|
||||
ui->labelError->setText(tr("Please, provide custom name for dimension %1").arg(dimension->Axis()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CheckDimension(ui->groupBoxXDimension, ui->groupBoxCustomXDimensionName, ui->lineEditCustomXDimensionName,
|
||||
xDimensionValid, dimensions, m_xDimension);
|
||||
CheckDimension(ui->groupBoxYDimension, ui->groupBoxCustomYDimensionName, ui->lineEditCustomYDimensionName,
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
|
||||
class QDoubleSpinBox;
|
||||
class QGroupBox;
|
||||
class QLineEdit;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -76,6 +78,8 @@ private:
|
|||
QSharedPointer<VWMeasurementDimension> m_wDimension;
|
||||
QSharedPointer<VZMeasurementDimension> m_zDimension;
|
||||
|
||||
void CheckDimension(QGroupBox *group, QGroupBox *nameGroup, QLineEdit *lineEdit, bool &dimensionValid,
|
||||
int &dimensions, const MeasurementDimension_p &dimension);
|
||||
void CheckState();
|
||||
|
||||
void InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
||||
|
|
Loading…
Reference in New Issue
Block a user