From 4db0f3a420506b330076c3bd59991ba910987876 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 1 Oct 2020 16:56:44 +0300 Subject: [PATCH] Prepare base values. --- src/app/tape/tmainwindow.cpp | 142 +++++++++- src/app/tape/tmainwindow.h | 6 + src/app/tape/tmainwindow.ui | 532 +++++++++++++++++++---------------- 3 files changed, 424 insertions(+), 256 deletions(-) diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 05d5726cc..b596ba0ba 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -562,10 +562,8 @@ void TMainWindow::changeEvent(QEvent *event) if (mType == MeasurementsType::Multisize) { ui->labelMType->setText(tr("Multisize measurements")); - ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) + - UnitsToStr(m->MUnit(), true)); - ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) + - UnitsToStr(m->MUnit(), true)); + + RetranslateDimensionBaseValues(); labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit))); labelGradationSizes->setText(tr("Size (%1):").arg(UnitsToStr(mUnit))); @@ -2017,7 +2015,7 @@ void TMainWindow::InitWindow() SCASSERT(m != nullptr) ui->labelToolTip->setVisible(false); ui->tabWidget->setVisible(true); - ui->tabWidget->setCurrentIndex(0); + ui->tabWidget->setCurrentIndex(0); // measurements ui->plainTextEditNotes->setEnabled(true); ui->toolBarGradation->setVisible(true); @@ -2025,10 +2023,8 @@ void TMainWindow::InitWindow() if (mType == MeasurementsType::Multisize) { ui->labelMType->setText(tr("Multisize measurements")); - ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) + - UnitsToStr(m->MUnit(), true)); - ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) + - UnitsToStr(m->MUnit(), true)); + + InitDimensionsBaseValue(); // Because Qt Designer doesn't know about our deleting we will create empty objects for correct // working the retranslation UI @@ -2091,10 +2087,14 @@ void TMainWindow::InitWindow() HackWidget(&ui->labelInHeights); // Tab Information - HackWidget(&ui->labelBaseSize); - HackWidget(&ui->labelBaseSizeValue); - HackWidget(&ui->labelBaseHeight); - HackWidget(&ui->labelBaseHeightValue); + HackWidget(&ui->labelDimensionA); + HackWidget(&ui->labelDimensionABase); + HackWidget(&ui->labelDimensionB); + HackWidget(&ui->labelDimensionBBase); + HackWidget(&ui->labelDimensionC); + HackWidget(&ui->labelDimensionCBase); + HackWidget(&ui->frameBaseValue); + HackWidget(&ui->labelBaseValues); ui->lineEditCustomerName->setText(m->Customer()); @@ -2179,6 +2179,44 @@ void TMainWindow::InitWindow() InitTable(); } +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::InitDimensionsBaseValue() +{ + const QList 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() || dimension->Type() == MeasurementDimension::X) + { + base->setText(QString("%1 %2").arg(dimension->BaseValue()).arg(unit)); + } + else + { + base->setText(QString::number(dimension->BaseValue())); + } + } + else + { + HackWidget(&name); + HackWidget(&base); + } + }; + + DimensionsBaseValue(0, ui->labelDimensionA, ui->labelDimensionABase); + DimensionsBaseValue(1, ui->labelDimensionB, ui->labelDimensionBBase); + DimensionsBaseValue(2, ui->labelDimensionC, ui->labelDimensionCBase); +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitTable() { @@ -3306,6 +3344,84 @@ void TMainWindow::SetCurrentPatternUnit() } } +//--------------------------------------------------------------------------------------------------------------------- +QString TMainWindow::DimensionName(MeasurementDimension type) +{ + switch(type) + { + case MeasurementDimension::X: + return tr("Height"); + case MeasurementDimension::Y: + return tr("Size"); + case MeasurementDimension::W: + return tr("Hip"); + case MeasurementDimension::Z: + return tr("Waist"); + default: + return QString(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::RetranslateDimensionBaseValues() +{ + const QList 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) +{ + const bool fc = m->IsFullCircumference(); + switch(type) + { + case MeasurementDimension::X: + return tr("Height"); + case MeasurementDimension::Y: + if (circumference) + { + return fc ? tr("Chest full circumference") : tr("Chest half circumference"); + } + else + { + return tr("Size"); + } + return circumference ? tr("Chest circumference") : tr("Size"); + case MeasurementDimension::W: + return fc ? tr("Hip full circumference") : tr("Hip half circumference"); + case MeasurementDimension::Z: + return fc ? tr("Waist full circumference") : tr("Waist half circumference"); + default: + return QString(); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::SetDecimals() { diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 15795d3d4..316ad399c 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -155,6 +155,7 @@ private: void SetupMenu(); void InitWindow(); + void InitDimensionsBaseValue(); void InitTable(); void SetDecimals(); void InitUnits(); @@ -218,6 +219,11 @@ private: void ImportMultisizeMeasurements(const QxtCsvModel &csv); void SetCurrentPatternUnit(); + + QString DimensionName(MeasurementDimension type); + QString DimensionToolTip(MeasurementDimension type, bool circumference); + + void RetranslateDimensionBaseValues(); }; #endif // TMAINWINDOW_H diff --git a/src/app/tape/tmainwindow.ui b/src/app/tape/tmainwindow.ui index 62e6dab34..511467ada 100644 --- a/src/app/tape/tmainwindow.ui +++ b/src/app/tape/tmainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 835 - 726 + 1034 + 896 @@ -24,7 +24,7 @@ 0 - + @@ -47,7 +47,7 @@ - 0 + 1 @@ -572,261 +572,307 @@ Information - - - - - Type: + + + + + QFormLayout::ExpandingFieldsGrow - - - - - - Measurement type - - - - - - - Path: - - - - - - - - - - 0 - 0 - - - - false - - - background: transparent; - - - false - - - true - - - Path to the measurement file + + + + Type: - - + + + + Measurement type + + + + + + + Path: + + + + + + + + + + 0 + 0 + + + + false + + + background: transparent; + + + false + + + true + + + Path to the measurement file + + + + + + + false + + + + 0 + 0 + + + + Show in Explorer + + + + + + + + + PM system: + + + + + false - + + 0 + 0 + + + + + 0 + 0 + + + + + + + + 0 0 - Show in Explorer + Base Values: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + Customer name: + + + + + + + false + + + + 0 + 0 + + + + Customer's name + + + + + + + Birth date: + + + + + + + false + + + + 0 + 0 + + + + + 124 + 0 + + + + yyyy-MM-dd + + + true + + + 0 + + + + 1800 + 1 + 1 + + + + + + + + Gender: + + + + + + + false + + + + 0 + 0 + + + + + + + + Email: + + + + + + + false + + + + 0 + 0 + + + + Customer's email address + + + + + + + Notes: + + + + + + + false + + + + 0 + 1 + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + + + + A + + + + + + + Base + + + + + + + B + + + + + + + Base + + + + + + + C + + + + + + + Base + + + + + + - - - - PM system: - - - - - - - false - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - Base size: - - - - - - - Base size value - - - - - - - Base height: - - - - - - - Base height value - - - - - - - Customer name: - - - - - - - false - - - - 0 - 0 - - - - Customer's name - - - - - - - Birth date: - - - - - - - false - - - - 0 - 0 - - - - - 124 - 0 - - - - yyyy-MM-dd - - - true - - - 0 - - - - 1800 - 1 - 1 - - - - - - - - Gender: - - - - - - - false - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - Email: - - - - - - - false - - - - 0 - 0 - - - - Customer's email address - - - - - - - Notes: - - - - - - - false - - - - 0 - 1 - - - - @@ -838,8 +884,8 @@ 0 0 - 835 - 22 + 1034 + 21