Refactoring.
Unify initialization and translation dimensions base value.
This commit is contained in:
parent
1ffbc0a720
commit
15978bd868
|
@ -563,7 +563,7 @@ void TMainWindow::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
ui->labelMType->setText(tr("Multisize measurements"));
|
ui->labelMType->setText(tr("Multisize measurements"));
|
||||||
|
|
||||||
RetranslateDimensionBaseValues();
|
InitDimensionsBaseValue();
|
||||||
|
|
||||||
labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit)));
|
labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit)));
|
||||||
labelGradationSizes->setText(tr("Size (%1):").arg(UnitsToStr(mUnit)));
|
labelGradationSizes->setText(tr("Size (%1):").arg(UnitsToStr(mUnit)));
|
||||||
|
@ -2025,6 +2025,7 @@ void TMainWindow::InitWindow()
|
||||||
ui->labelMType->setText(tr("Multisize measurements"));
|
ui->labelMType->setText(tr("Multisize measurements"));
|
||||||
|
|
||||||
InitDimensionsBaseValue();
|
InitDimensionsBaseValue();
|
||||||
|
HackDimensionBaseValue();
|
||||||
|
|
||||||
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct
|
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct
|
||||||
// working the retranslation UI
|
// working the retranslation UI
|
||||||
|
@ -2087,12 +2088,7 @@ void TMainWindow::InitWindow()
|
||||||
HackWidget(&ui->labelInHeights);
|
HackWidget(&ui->labelInHeights);
|
||||||
|
|
||||||
// Tab Information
|
// Tab Information
|
||||||
HackWidget(&ui->labelDimensionA);
|
HackDimensionBaseValue();
|
||||||
HackWidget(&ui->labelDimensionABase);
|
|
||||||
HackWidget(&ui->labelDimensionB);
|
|
||||||
HackWidget(&ui->labelDimensionBBase);
|
|
||||||
HackWidget(&ui->labelDimensionC);
|
|
||||||
HackWidget(&ui->labelDimensionCBase);
|
|
||||||
HackWidget(&ui->frameBaseValue);
|
HackWidget(&ui->frameBaseValue);
|
||||||
HackWidget(&ui->labelBaseValues);
|
HackWidget(&ui->labelBaseValues);
|
||||||
|
|
||||||
|
@ -2205,11 +2201,6 @@ void TMainWindow::InitDimensionsBaseValue()
|
||||||
base->setText(QString::number(dimension->BaseValue()));
|
base->setText(QString::number(dimension->BaseValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
HackWidget(&name);
|
|
||||||
HackWidget(&base);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
||||||
|
@ -3068,6 +3059,28 @@ bool TMainWindow::IgnoreLocking(int error, const QString &path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::HackDimensionBaseValue()
|
||||||
|
{
|
||||||
|
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||||
|
|
||||||
|
auto DimensionsBaseValue = [this, dimensions](int index, QLabel *name, QLabel *base)
|
||||||
|
{
|
||||||
|
SCASSERT(name != nullptr)
|
||||||
|
SCASSERT(base != nullptr)
|
||||||
|
|
||||||
|
if (dimensions.size() <= index)
|
||||||
|
{
|
||||||
|
HackWidget(&name);
|
||||||
|
HackWidget(&base);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
||||||
|
DimensionsBaseValue(1, ui->labelDimensionB, ui->labelDimensionBBase);
|
||||||
|
DimensionsBaseValue(2, ui->labelDimensionC, ui->labelDimensionCBase);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString TMainWindow::CheckMName(const QString &name, const QSet<QString> &importedNames) const
|
QString TMainWindow::CheckMName(const QString &name, const QSet<QString> &importedNames) const
|
||||||
{
|
{
|
||||||
|
@ -3362,39 +3375,6 @@ QString TMainWindow::DimensionName(MeasurementDimension type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void TMainWindow::RetranslateDimensionBaseValues()
|
|
||||||
{
|
|
||||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
|
||||||
const QString unit = UnitsToStr(m->MUnit(), true);
|
|
||||||
|
|
||||||
auto DimensionsBaseValue = [this, dimensions, unit](int index, QLabel *name, QLabel *base)
|
|
||||||
{
|
|
||||||
SCASSERT(name != nullptr)
|
|
||||||
SCASSERT(base != nullptr)
|
|
||||||
|
|
||||||
if (dimensions.size() > index)
|
|
||||||
{
|
|
||||||
MeasurementDimension_p dimension = dimensions.at(index);
|
|
||||||
name->setText(DimensionName(dimension->Type())+QChar(':'));
|
|
||||||
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
|
|
||||||
|
|
||||||
if (dimension->IsCircumference())
|
|
||||||
{
|
|
||||||
base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
base->setText(QString::number(dimension->BaseValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase);
|
|
||||||
DimensionsBaseValue(1, ui->labelDimensionC, ui->labelDimensionCBase);
|
|
||||||
DimensionsBaseValue(2, ui->labelDimensionB, ui->labelDimensionBBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString TMainWindow::DimensionToolTip(MeasurementDimension type, bool circumference)
|
QString TMainWindow::DimensionToolTip(MeasurementDimension type, bool circumference)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,6 +210,7 @@ private:
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void HackWidget(T **widget);
|
void HackWidget(T **widget);
|
||||||
|
void HackDimensionBaseValue();
|
||||||
|
|
||||||
QString CheckMName(const QString &name, const QSet<QString> &importedNames) const;
|
QString CheckMName(const QString &name, const QSet<QString> &importedNames) const;
|
||||||
void ShowError(const QString &text);
|
void ShowError(const QString &text);
|
||||||
|
@ -222,8 +223,6 @@ private:
|
||||||
|
|
||||||
QString DimensionName(MeasurementDimension type);
|
QString DimensionName(MeasurementDimension type);
|
||||||
QString DimensionToolTip(MeasurementDimension type, bool circumference);
|
QString DimensionToolTip(MeasurementDimension type, bool circumference);
|
||||||
|
|
||||||
void RetranslateDimensionBaseValues();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TMAINWINDOW_H
|
#endif // TMAINWINDOW_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user