Fix retranslation table headers in Tape.

This commit is contained in:
Roman Telezhynskyi 2021-03-26 16:27:17 +02:00
parent 8d7dc4bc91
commit 638d3182f4
2 changed files with 42 additions and 30 deletions

View File

@ -611,6 +611,7 @@ void TMainWindow::changeEvent(QEvent *event)
InitDimensionsBaseValue();
InitDimensionControls();
InitDimesionShifts();
RetranslateTableHeaders();
}
else
{
@ -2874,36 +2875,7 @@ void TMainWindow::InitTable()
{
ui->tableWidget->setColumnHidden( ColumnFormula, true );// formula
const QList< MeasurementDimension_p > dimensions = m->Dimensions().values();
if (dimensions.size() > 0)
{
MeasurementDimension_p dimension = dimensions.at(0);
ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
if (dimensions.size() < 2)
{
ui->tableWidget->setColumnHidden( ColumnShiftB, true );
}
else
{
MeasurementDimension_p dimension = dimensions.at(1);
ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
if (dimensions.size() < 3)
{
ui->tableWidget->setColumnHidden( ColumnShiftC, true );
}
else
{
MeasurementDimension_p dimension = dimensions.at(2);
ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
RetranslateTableHeaders();
}
else
{
@ -4452,6 +4424,44 @@ void TMainWindow::InitMeasurementDimension()
ui->comboBoxDimension->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::RetranslateTableHeaders()
{
if (mType == MeasurementsType::Multisize)
{
const QList< MeasurementDimension_p > dimensions = m->Dimensions().values();
if (not dimensions.isEmpty())
{
const MeasurementDimension_p& dimension = dimensions.at(0);
ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
if (dimensions.size() < 2)
{
ui->tableWidget->setColumnHidden( ColumnShiftB, true );
}
else
{
const MeasurementDimension_p &dimension = dimensions.at(1);
ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
if (dimensions.size() < 3)
{
ui->tableWidget->setColumnHidden( ColumnShiftC, true );
}
else
{
const MeasurementDimension_p &dimension = dimensions.at(2);
ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(
tr("%1 shift").arg(VAbstartMeasurementDimension::DimensionName(dimension->Type())));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
void TMainWindow::HackWidget(T **widget)

View File

@ -190,6 +190,8 @@ private:
void InitGender(QComboBox *gender);
void InitMeasurementDimension();
void RetranslateTableHeaders();
void ShowNewMData(bool fresh);
void ShowUnits();
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);