diff --git a/ChangeLog.txt b/ChangeLog.txt index 9139249be..7eb956719 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,7 @@ - Fix warning while segmenting flipped arc. - Tape app. "Export from existing ..." now supports multisize measurements. - Fix main path validation. False positive double curve. +- Fix Setup multisize measurements dialog. Improved handling Height dimension. # Valentina 0.7.51 April 18, 2022 - Z value change for a layout piece. diff --git a/src/app/tape/dialogs/dialogdimensionlabels.cpp b/src/app/tape/dialogs/dialogdimensionlabels.cpp index a984be32a..5a5bcc8d9 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.cpp +++ b/src/app/tape/dialogs/dialogdimensionlabels.cpp @@ -205,7 +205,7 @@ auto DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimensi if (dimension->Type() == MeasurementDimension::Y) { - if (dimension->IsCircumference()) + if (dimension->IsBodyMeasurement()) { return QString::number(m_fullCircumference ? value*2 : value); } diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index 2d3cda383..1b9f9e5a7 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -756,7 +756,7 @@ void DialogRestrictDimension::FillBases(const QVector &bases, const Measu } else { - if (dimension->IsCircumference()) + if (dimension->IsBodyMeasurement()) { control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base); } @@ -787,7 +787,7 @@ void DialogRestrictDimension::FillBases(const QVector &bases, const Measu auto DialogRestrictDimension::DimensionLabels(const QVector &bases, const MeasurementDimension_p &dimension) const -> QStringList { - const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X; + const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X; const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); const DimesionLabels dimensionLabels = dimension->Labels(); @@ -817,7 +817,7 @@ auto DialogRestrictDimension::DimensionLabels(const QVector &bases, } else { - if (dimension->IsCircumference()) + if (dimension->IsBodyMeasurement()) { labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); } diff --git a/src/app/tape/dialogs/dialogsetupmultisize.cpp b/src/app/tape/dialogs/dialogsetupmultisize.cpp index a9e134eff..2f8a45be6 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.cpp +++ b/src/app/tape/dialogs/dialogsetupmultisize.cpp @@ -166,14 +166,14 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) : connect(ui->checkBoxFullCircumference, &QCheckBox::stateChanged, this, &DialogSetupMultisize::ShowFullCircumference); - connect(ui->checkBoxXDimensionCircumference, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::XDimensionCircumferenceChanged); - connect(ui->checkBoxYDimensionCircumference, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::YDimensionCircumferenceChanged); - connect(ui->checkBoxWDimensionCircumference, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::WDimensionCircumferenceChanged); - connect(ui->checkBoxZDimensionCircumference, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::ZDimensionCircumferenceChanged); + connect(ui->checkBoxXDimensionBodyMeasurement, &QCheckBox::stateChanged, + this, &DialogSetupMultisize::XDimensionBodyMeasurementChanged); + connect(ui->checkBoxYDimensionBodyMeasurement, &QCheckBox::stateChanged, + this, &DialogSetupMultisize::YDimensionBodyMeasurementChanged); + connect(ui->checkBoxWDimensionBodyMeasurement, &QCheckBox::stateChanged, + this, &DialogSetupMultisize::WDimensionBodyMeasurementChanged); + connect(ui->checkBoxZDimensionBodyMeasurement, &QCheckBox::stateChanged, + this, &DialogSetupMultisize::ZDimensionBodyMeasurementChanged); connect(ui->lineEditCustomXDimensionName, &QLineEdit::textChanged, this, [this](const QString &text) { @@ -307,8 +307,6 @@ void DialogSetupMultisize::ShowFullCircumference() comboBoxBase->blockSignals(false); }; - ShowDimensionFullCircumference(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, - ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension); ShowDimensionFullCircumference(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); ShowDimensionFullCircumference(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, @@ -320,16 +318,10 @@ void DialogSetupMultisize::ShowFullCircumference() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::XDimensionCircumferenceChanged() +void DialogSetupMultisize::XDimensionBodyMeasurementChanged() { - bool checked = ui->checkBoxXDimensionCircumference->isChecked(); - m_xDimension->SetCircumference(checked); - - const bool c = m_xDimension->IsCircumference(); - const QString unitStr = c ? " " + UnitsToStr(m_xDimension->Units()) : QString(); - - ui->doubleSpinBoxXDimensionMinValue->setSuffix(unitStr); - ui->doubleSpinBoxXDimensionMaxValue->setSuffix(unitStr); + bool checked = ui->checkBoxXDimensionBodyMeasurement->isChecked(); + m_xDimension->SetBodyMeasurement(checked); InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep, m_xDimension); @@ -348,16 +340,10 @@ void DialogSetupMultisize::XDimensionCircumferenceChanged() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::YDimensionCircumferenceChanged() +void DialogSetupMultisize::YDimensionBodyMeasurementChanged() { - bool checked = ui->checkBoxYDimensionCircumference->isChecked(); - m_yDimension->SetCircumference(checked); - - const bool c = m_yDimension->IsCircumference(); - const QString unitStr = c ? " " + UnitsToStr(m_yDimension->Units()) : QString(); - - ui->doubleSpinBoxYDimensionMinValue->setSuffix(unitStr); - ui->doubleSpinBoxYDimensionMaxValue->setSuffix(unitStr); + bool checked = ui->checkBoxYDimensionBodyMeasurement->isChecked(); + m_yDimension->SetBodyMeasurement(checked); InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, m_yDimension); @@ -376,16 +362,10 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::WDimensionCircumferenceChanged() +void DialogSetupMultisize::WDimensionBodyMeasurementChanged() { - bool checked = ui->checkBoxWDimensionCircumference->isChecked(); - m_wDimension->SetCircumference(checked); - - const bool c = m_wDimension->IsCircumference(); - const QString unitStr = c ? " " + UnitsToStr(m_wDimension->Units()) : QString(); - - ui->doubleSpinBoxWDimensionMinValue->setSuffix(unitStr); - ui->doubleSpinBoxWDimensionMaxValue->setSuffix(unitStr); + bool checked = ui->checkBoxWDimensionBodyMeasurement->isChecked(); + m_wDimension->SetBodyMeasurement(checked); InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep, m_wDimension); @@ -404,16 +384,10 @@ void DialogSetupMultisize::WDimensionCircumferenceChanged() } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::ZDimensionCircumferenceChanged() +void DialogSetupMultisize::ZDimensionBodyMeasurementChanged() { - bool checked = ui->checkBoxZDimensionCircumference->isChecked(); - m_zDimension->SetCircumference(checked); - - const bool c = m_zDimension->IsCircumference(); - const QString unitStr = c ? " " + UnitsToStr(m_zDimension->Units()) : QString(); - - ui->doubleSpinBoxZDimensionMinValue->setSuffix(unitStr); - ui->doubleSpinBoxZDimensionMaxValue->setSuffix(unitStr); + bool checked = ui->checkBoxZDimensionBodyMeasurement->isChecked(); + m_zDimension->SetBodyMeasurement(checked); InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep, m_zDimension); @@ -513,33 +487,25 @@ void DialogSetupMultisize::InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinV dimension->SetMinValue(dimension->RangeMin()); dimension->SetMaxValue(dimension->RangeMax()); - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); + const QString unitStr = m ? " " + UnitsToStr(m_xDimension->Units()) : QString(); doubleSpinBoxMinValue->blockSignals(true); - const QString unitStr = " " + UnitsToStr(dimension->Units()); - if (c || dimension->Type() == MeasurementDimension::X) - { - doubleSpinBoxMinValue->setSuffix(unitStr); - } - + doubleSpinBoxMinValue->setSuffix(unitStr); doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1); - doubleSpinBoxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin()); - doubleSpinBoxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); - doubleSpinBoxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue()); + doubleSpinBoxMinValue->setMinimum(m && fc ? dimension->RangeMin()*2 : dimension->RangeMin()); + doubleSpinBoxMinValue->setMaximum(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); + doubleSpinBoxMinValue->setValue(m && fc ? dimension->MinValue()*2 : dimension->MinValue()); doubleSpinBoxMinValue->blockSignals(false); doubleSpinBoxMaxValue->blockSignals(true); - if (c || dimension->Type() == MeasurementDimension::X) - { - doubleSpinBoxMaxValue->setSuffix(unitStr); - } - + doubleSpinBoxMaxValue->setSuffix(unitStr); doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1); - doubleSpinBoxMaxValue->setMinimum(c && fc ? dimension->MinValue()*2 : dimension->MinValue()); - doubleSpinBoxMaxValue->setMaximum(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); - doubleSpinBoxMaxValue->setValue(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); - doubleSpinBoxMaxValue->setValue(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); + doubleSpinBoxMaxValue->setMinimum(m && fc ? dimension->MinValue()*2 : dimension->MinValue()); + doubleSpinBoxMaxValue->setMaximum(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); + doubleSpinBoxMaxValue->setValue(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); + doubleSpinBoxMaxValue->setValue(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); doubleSpinBoxMaxValue->blockSignals(false); } @@ -549,9 +515,9 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, { SCASSERT(comboBoxStep != nullptr) - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); - const QString unitStr = " " + UnitsToStr(dimension->Units()); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); + const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString(); dimension->SetStep(-1); @@ -560,8 +526,7 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, comboBoxStep->clear(); for(auto step : steps) { - comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step*2 : step) - .arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), step); + comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step*2 : step).arg(unitStr), step); } comboBoxStep->setCurrentIndex(-1); // force a user to select @@ -621,16 +586,16 @@ void DialogSetupMultisize::DimensionMinValueChanged(qreal value, QDoubleSpinBox SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxBase != nullptr) - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); - dimension->SetMinValue(c && fc ? value / 2 : value); + dimension->SetMinValue(m && fc ? value / 2 : value); doubleSpinBoxMaxValue->blockSignals(true); doubleSpinBoxMaxValue->setMinimum(value); doubleSpinBoxMaxValue->blockSignals(false); - dimension->SetMaxValue(c && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value()); + dimension->SetMaxValue(m && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value()); UpdateSteps(comboBoxStep, dimension); UpdateBase(comboBoxBase, dimension); @@ -647,16 +612,16 @@ void DialogSetupMultisize::DimensionMaxValueChanged(qreal value, QDoubleSpinBox SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxBase != nullptr) - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); - dimension->SetMaxValue(c && fc ? value / 2 : value); + dimension->SetMaxValue(m && fc ? value / 2 : value); doubleSpinBoxMinValue->blockSignals(true); doubleSpinBoxMinValue->setMaximum(value); doubleSpinBoxMinValue->blockSignals(false); - dimension->SetMinValue(c && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value()); + dimension->SetMinValue(m && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value()); UpdateSteps(comboBoxStep, dimension); UpdateBase(comboBoxBase, dimension); @@ -707,17 +672,16 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, comboBoxStep->blockSignals(true); - const QString unitStr = " " + UnitsToStr(dimension->Units()); const QVector steps = dimension->ValidSteps(); comboBoxStep->clear(); - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); + const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString(); for(auto step : steps) { - comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step * 2 : step) - .arg(c ? unitStr : QString()), step); + comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step * 2 : step).arg(unitStr), step); } comboBoxStep->setCurrentIndex(comboBoxStep->findData(oldStep)); @@ -742,16 +706,15 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, comboBoxBase->blockSignals(true); - const QString unitStr = " " + UnitsToStr(dimension->Units()); const QVector bases = dimension->ValidBases(); comboBoxBase->clear(); - const bool fc = ui->checkBoxFullCircumference->isChecked(); - const bool c = dimension->IsCircumference(); + const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false; + const bool m = dimension->IsBodyMeasurement(); + const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString(); for(auto base : bases) { - comboBoxBase->addItem(QStringLiteral("%1%2").arg(c && fc ? base * 2 : base) - .arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), base); + comboBoxBase->addItem(QStringLiteral("%1%2").arg(m && fc ? base * 2 : base).arg(unitStr), base); } comboBoxBase->setCurrentIndex(comboBoxBase->findData(oldBase)); diff --git a/src/app/tape/dialogs/dialogsetupmultisize.h b/src/app/tape/dialogs/dialogsetupmultisize.h index 98295ccdc..4a9ccaf3e 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.h +++ b/src/app/tape/dialogs/dialogsetupmultisize.h @@ -62,13 +62,13 @@ protected: private slots: void ShowFullCircumference(); - void XDimensionCircumferenceChanged(); - void YDimensionCircumferenceChanged(); - void WDimensionCircumferenceChanged(); - void ZDimensionCircumferenceChanged(); + void XDimensionBodyMeasurementChanged(); + void YDimensionBodyMeasurementChanged(); + void WDimensionBodyMeasurementChanged(); + void ZDimensionBodyMeasurementChanged(); private: - Q_DISABLE_COPY_MOVE(DialogSetupMultisize) + Q_DISABLE_COPY_MOVE(DialogSetupMultisize) // NOLINT Ui::DialogSetupMultisize *ui; bool m_isInitialized{false}; QSharedPointer m_xDimension; diff --git a/src/app/tape/dialogs/dialogsetupmultisize.ui b/src/app/tape/dialogs/dialogsetupmultisize.ui index 18c2c393f..e8bf8509b 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.ui +++ b/src/app/tape/dialogs/dialogsetupmultisize.ui @@ -147,9 +147,12 @@ - + + + A body measurement measured in units of length. + - Circumference + Body Measurement true @@ -282,9 +285,12 @@ - + + + A body measurement measured in units of length. Circumference. + - Circumference + Body Measurement true @@ -417,9 +423,12 @@ - + + + A body measurement measured in units of length. Circumference. + - Circumference + Body Measurement true @@ -552,9 +561,12 @@ - + + + A body measurement measured in units of length. Circumference. + - Circumference + Body Measurement true diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index f969ef6ee..58964e2d9 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -2761,7 +2761,7 @@ void TMainWindow::InitDimensionsBaseValue() } else { - if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X) + if (dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X) { if (dimension->Type() != MeasurementDimension::X && fc) { @@ -2829,7 +2829,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p } else { - if (dimension->IsCircumference()) + if (dimension->IsBodyMeasurement()) { control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base); } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 05383b234..45fe3db8e 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2146,7 +2146,7 @@ void MainWindow::StoreMultisizeMDimensions() QList dimensions = m->Dimensions().values(); - if (dimensions.size() > 0) + if (not dimensions.isEmpty()) { if (not dimensionALabel.isNull()) { @@ -2190,9 +2190,9 @@ void MainWindow::StoreMultisizeMDimensions() VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase); VAbstractValApplication::VApp()->SetDimensionSizeLabel( labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase))); - const bool circumference = dimension->IsCircumference(); + const bool measurement = dimension->IsBodyMeasurement(); VAbstractValApplication::VApp() - ->SetDimensionSizeUnits(circumference ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE); + ->SetDimensionSizeUnits(measurement ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE); break; } case MeasurementDimension::W: @@ -4614,7 +4614,7 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p } else { - if (dimension->IsCircumference()) + if (dimension->IsBodyMeasurement()) { control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base); } diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 3b0a486f0..6a33ff30f 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -76,6 +76,7 @@ schema/multisize_measurements/v0.5.1.xsd schema/multisize_measurements/v0.5.2.xsd schema/multisize_measurements/v0.5.3.xsd + schema/multisize_measurements/v0.5.4.xsd schema/individual_measurements/v0.2.0.xsd schema/individual_measurements/v0.3.0.xsd schema/individual_measurements/v0.3.1.xsd diff --git a/src/libs/ifc/schema/multisize_measurements/v0.5.4.xsd b/src/libs/ifc/schema/multisize_measurements/v0.5.4.xsd new file mode 100644 index 000000000..825fb200c --- /dev/null +++ b/src/libs/ifc/schema/multisize_measurements/v0.5.4.xsd @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index d64e4f065..ad3724bdc 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -54,8 +54,8 @@ */ const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0"); -const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.3"); -const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.3.xsd"); +const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.4"); +const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd"); //VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -63,6 +63,9 @@ const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/mu namespace { Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension"))) } //--------------------------------------------------------------------------------------------------------------------- @@ -86,7 +89,8 @@ auto VVSTConverter::XSDSchema(unsigned ver) const -> QString std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/multisize_measurements/v0.5.0.xsd")), std::make_pair(FormatVersion(0, 5, 1), QStringLiteral("://schema/multisize_measurements/v0.5.1.xsd")), std::make_pair(FormatVersion(0, 5, 2), QStringLiteral("://schema/multisize_measurements/v0.5.2.xsd")), - std::make_pair(FormatVersion(0, 5, 3), CurrentSchema), + std::make_pair(FormatVersion(0, 5, 3), QStringLiteral("://schema/multisize_measurements/v0.5.3.xsd")), + std::make_pair(FormatVersion(0, 5, 4), CurrentSchema), }; if (schemas.contains(ver)) @@ -119,10 +123,11 @@ void VVSTConverter::ApplyPatches() case (FormatVersion(0, 5, 0)): case (FormatVersion(0, 5, 1)): case (FormatVersion(0, 5, 2)): - ToV0_5_3(); + case (FormatVersion(0, 5, 3)): + ToV0_5_4(); ValidateXML(CurrentSchema); Q_FALLTHROUGH(); - case (FormatVersion(0, 5, 3)): + case (FormatVersion(0, 5, 4)): break; default: InvalidVersion(m_ver); @@ -141,7 +146,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion() auto VVSTConverter::IsReadOnly() const -> bool { // Check if attribute read-only was not changed in file format - Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 3), + Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 4), "Check attribute read-only."); // Possibly in future attribute read-only will change position etc. @@ -415,6 +420,22 @@ void VVSTConverter::ConvertMeasurementsToV0_5_0() } } +//--------------------------------------------------------------------------------------------------------------------- +void VVSTConverter::ConvertCircumferenceAttreibuteToV0_5_4() +{ + const QDomNodeList list = elementsByTagName(*strTagDimension); + for (int i=0; i < list.size(); ++i) + { + QDomElement dom = list.at(i).toElement(); + if (dom.hasAttribute(*strAttrCircumference)) + { + bool m = GetParametrBool(dom, *strAttrCircumference, trueStr); + dom.removeAttribute(*strAttrCircumference); + SetAttribute(dom, *strAttrMeasurement, m); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VVSTConverter::ToV0_4_0() { @@ -469,12 +490,13 @@ void VVSTConverter::ToV0_5_0() } //--------------------------------------------------------------------------------------------------------------------- -void VVSTConverter::ToV0_5_3() +void VVSTConverter::ToV0_5_4() { - // TODO. Delete if minimal supported version is 0.5.3 - Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 3), + // TODO. Delete if minimal supported version is 0.5.4 + Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 4), "Time to refactor the code."); - SetVersion(QStringLiteral("0.5.3")); + SetVersion(QStringLiteral("0.5.4")); + ConvertCircumferenceAttreibuteToV0_5_4(); Save(); } diff --git a/src/libs/ifc/xml/vvstconverter.h b/src/libs/ifc/xml/vvstconverter.h index 43af16f59..bfcb3003f 100644 --- a/src/libs/ifc/xml/vvstconverter.h +++ b/src/libs/ifc/xml/vvstconverter.h @@ -49,7 +49,7 @@ public: static const QString MeasurementMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 3, 0); - static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 3); + static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 4); protected: virtual unsigned MinVer() const override; @@ -78,11 +78,13 @@ private: void RemoveTagsForV0_5_0(); void ConvertMeasurementsToV0_5_0(); + void ConvertCircumferenceAttreibuteToV0_5_4(); + void ToV0_4_0(); void ToV0_4_1(); void ToV0_4_2(); void ToV0_5_0(); - void ToV0_5_3(); + void ToV0_5_4(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vformat/vdimensions.cpp b/src/libs/vformat/vdimensions.cpp index a4a1c8e96..f1641895e 100644 --- a/src/libs/vformat/vdimensions.cpp +++ b/src/libs/vformat/vdimensions.cpp @@ -54,7 +54,7 @@ auto VAbstartMeasurementDimension::IsValid() -> bool //--------------------------------------------------------------------------------------------------------------------- auto VAbstartMeasurementDimension::RangeMin() const -> int { - if (m_circumference) + if (m_measurement) { const int rangeMinCm = 20; const int rangeMinMm = 200; @@ -79,7 +79,7 @@ auto VAbstartMeasurementDimension::RangeMin() const -> int //--------------------------------------------------------------------------------------------------------------------- auto VAbstartMeasurementDimension::RangeMax() const -> int { - if (m_circumference) + if (m_measurement) { const int rangeMaxCm = 272; const int rangeMaxMm = 2720; @@ -276,19 +276,19 @@ auto VAbstartMeasurementDimension::DimensionToolTip(const MeasurementDimension_p switch(dimension->Type()) { case MeasurementDimension::Y: - if (dimension->CustomName().isEmpty() && dimension->IsCircumference()) + if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement()) { return fc ? tr("Chest full circumference", "dimension") : tr("Chest half circumference", "dimension"); } return {}; case MeasurementDimension::W: - if (dimension->CustomName().isEmpty() && dimension->IsCircumference()) + if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement()) { return fc ? tr("Waist full circumference", "dimension") : tr("Waist half circumference", "dimension"); } return {}; case MeasurementDimension::Z: - if (dimension->CustomName().isEmpty() && dimension->IsCircumference()) + if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement()) { return fc ? tr("Hip full circumference", "dimension") : tr("Hip half circumference", "dimension"); } diff --git a/src/libs/vformat/vdimensions.h b/src/libs/vformat/vdimensions.h index 0360af457..e7358a375 100644 --- a/src/libs/vformat/vdimensions.h +++ b/src/libs/vformat/vdimensions.h @@ -83,8 +83,8 @@ public: // cppcheck-suppress functionStatic auto Units() const -> Unit; - auto IsCircumference() const -> bool; - void SetCircumference(bool circumference); + auto IsBodyMeasurement() const -> bool; + void SetBodyMeasurement(bool measurement); auto RangeMin() const -> int; auto RangeMax() const -> int; @@ -124,7 +124,7 @@ private: qreal m_baseValue{0}; QString m_error{}; DimesionLabels m_labels{}; - bool m_circumference{true}; + bool m_measurement{true}; QString m_customName{}; }; @@ -189,15 +189,15 @@ inline auto VAbstartMeasurementDimension::Units() const -> Unit } //--------------------------------------------------------------------------------------------------------------------- -inline auto VAbstartMeasurementDimension::IsCircumference() const -> bool +inline auto VAbstartMeasurementDimension::IsBodyMeasurement() const -> bool { - return m_circumference; + return m_measurement; } //--------------------------------------------------------------------------------------------------------------------- -inline void VAbstartMeasurementDimension::SetCircumference(bool circumference) +inline void VAbstartMeasurementDimension::SetBodyMeasurement(bool measurement) { - m_circumference = circumference; + m_measurement = measurement; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 6420ef703..13c97d71e 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -93,7 +93,7 @@ const QString VMeasurements::AttrFullName = QStringLiteral("full_name") const QString VMeasurements::AttrMin = QStringLiteral("min"); const QString VMeasurements::AttrMax = QStringLiteral("max"); const QString VMeasurements::AttrStep = QStringLiteral("step"); -const QString VMeasurements::AttrCircumference = QStringLiteral("circumference"); +const QString VMeasurements::AttrMeasurement = QStringLiteral("measurement"); const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference"); const QString VMeasurements::AttrLabel = QStringLiteral("label"); const QString VMeasurements::AttrDimension = QStringLiteral("dimension"); @@ -1250,7 +1250,7 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit) } //--------------------------------------------------------------------------------------------------------------------- -QDomElement VMeasurements::CreateDimensions(const QVector &dimensions) +auto VMeasurements::CreateDimensions(const QVector &dimensions) -> QDomElement { QDomElement dimensionsTag = createElement(TagDimensions); @@ -1263,8 +1263,8 @@ QDomElement VMeasurements::CreateDimensions(const QVectorMinValue()); SetAttribute(dimensionTag, AttrMax, dimension->MaxValue()); SetAttribute(dimensionTag, AttrStep, dimension->Step()); - SetAttributeOrRemoveIf(dimensionTag, AttrCircumference, dimension->IsCircumference(), - [](bool c) noexcept {return c;}); + SetAttributeOrRemoveIf(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(), + [](bool m) noexcept {return m;}); SetAttributeOrRemoveIf(dimensionTag, AttrCustomName, dimension->CustomName(), [](const QString &name) noexcept {return name.isEmpty();}); @@ -1427,7 +1427,7 @@ auto VMeasurements::ReadDimensions() const -> VDimensions } dimension->SetBaseValue(GetParametrDouble(dom, AttrBase, QChar('0'))); - dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr)); + dimension->SetBodyMeasurement(GetParametrBool(dom, AttrMeasurement, trueStr)); dimension->SetCustomName(GetParametrEmptyString(dom, AttrCustomName)); dimension->SetLabels(ReadDimensionLabels(dom)); dimensions.insert(type, dimension); diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 792f855b0..7d88587e5 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -168,7 +168,7 @@ public: static const QString AttrMin; static const QString AttrMax; static const QString AttrStep; - static const QString AttrCircumference; + static const QString AttrMeasurement; static const QString AttrFullCircumference; static const QString AttrLabel; static const QString AttrDimension; diff --git a/src/test/ValentinaTest/tst_vmeasurements.cpp b/src/test/ValentinaTest/tst_vmeasurements.cpp index 4fa0dd187..644458511 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.cpp +++ b/src/test/ValentinaTest/tst_vmeasurements.cpp @@ -56,7 +56,7 @@ void TST_VMeasurements::CreateEmptyMultisizeFile() auto m_yDimension = QSharedPointer::create(mUnit, 22, 72, 2); m_yDimension->SetBaseValue(50); - m_yDimension->SetCircumference(true); + m_yDimension->SetBodyMeasurement(true); QVector dimensions{m_xDimension, m_yDimension}; @@ -151,7 +151,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() auto m_yDimension = QSharedPointer::create(mUnit, 22, 72, 2); m_yDimension->SetBaseValue(50); - m_yDimension->SetCircumference(true); + m_yDimension->SetBodyMeasurement(true); QVector dimensions{m_xDimension, m_yDimension};