From ff768c1c0f34d906214bed624780feca1ee362e1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 16 Oct 2015 20:26:05 +0300 Subject: [PATCH] Show pattern making system in tab Information of a measurement file. --HG-- branch : develop --- .../configpages/tapeconfigurationpage.cpp | 74 ------------ .../configpages/tapeconfigurationpage.h | 1 - src/app/tape/tmainwindow.cpp | 112 ++++++++++++++++-- src/app/tape/tmainwindow.h | 8 +- src/app/tape/tmainwindow.ui | 46 ++++--- src/libs/ifc/schema.qrc | 2 + .../schema/individual_measurements/v0.3.2.xsd | 72 +++++++++++ .../schema/standard_measurements/v0.4.1.xsd | 66 +++++++++++ src/libs/ifc/xml/vvitconverter.cpp | 34 +++++- src/libs/ifc/xml/vvitconverter.h | 2 + src/libs/ifc/xml/vvstconverter.cpp | 34 +++++- src/libs/ifc/xml/vvstconverter.h | 2 + src/libs/vformat/vmeasurements.cpp | 36 ++++++ src/libs/vformat/vmeasurements.h | 6 + src/libs/vmisc/def.cpp | 78 +++++++++++- src/libs/vmisc/def.h | 4 + 16 files changed, 468 insertions(+), 109 deletions(-) create mode 100644 src/libs/ifc/schema/individual_measurements/v0.3.2.xsd create mode 100644 src/libs/ifc/schema/standard_measurements/v0.4.1.xsd diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp index b3b7789a7..95ce1393c 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.cpp @@ -238,80 +238,6 @@ void TapeConfigurationPage::SetLabelComboBox(const QStringList &list) } } -//--------------------------------------------------------------------------------------------------------------------- -void TapeConfigurationPage::InitPMSystems(QComboBox *systemCombo) -{ - QMap systems; - systems.insert(qApp->TrVars()->PMSystemName(p0_S), p0_S); - systems.insert(qApp->TrVars()->PMSystemName(p1_S), p1_S); - systems.insert(qApp->TrVars()->PMSystemName(p2_S), p2_S); - systems.insert(qApp->TrVars()->PMSystemName(p3_S), p3_S); - systems.insert(qApp->TrVars()->PMSystemName(p4_S), p4_S); - systems.insert(qApp->TrVars()->PMSystemName(p5_S), p5_S); - systems.insert(qApp->TrVars()->PMSystemName(p6_S), p6_S); - systems.insert(qApp->TrVars()->PMSystemName(p7_S), p7_S); - systems.insert(qApp->TrVars()->PMSystemName(p8_S), p8_S); - systems.insert(qApp->TrVars()->PMSystemName(p9_S), p9_S); - systems.insert(qApp->TrVars()->PMSystemName(p10_S), p10_S); - systems.insert(qApp->TrVars()->PMSystemName(p11_S), p11_S); - systems.insert(qApp->TrVars()->PMSystemName(p12_S), p12_S); - systems.insert(qApp->TrVars()->PMSystemName(p13_S), p13_S); - systems.insert(qApp->TrVars()->PMSystemName(p14_S), p14_S); - systems.insert(qApp->TrVars()->PMSystemName(p15_S), p15_S); - systems.insert(qApp->TrVars()->PMSystemName(p16_S), p16_S); - systems.insert(qApp->TrVars()->PMSystemName(p17_S), p17_S); - systems.insert(qApp->TrVars()->PMSystemName(p18_S), p18_S); - systems.insert(qApp->TrVars()->PMSystemName(p19_S), p19_S); - systems.insert(qApp->TrVars()->PMSystemName(p20_S), p20_S); - systems.insert(qApp->TrVars()->PMSystemName(p21_S), p21_S); - systems.insert(qApp->TrVars()->PMSystemName(p22_S), p22_S); - systems.insert(qApp->TrVars()->PMSystemName(p23_S), p23_S); - systems.insert(qApp->TrVars()->PMSystemName(p24_S), p24_S); - systems.insert(qApp->TrVars()->PMSystemName(p25_S), p25_S); - systems.insert(qApp->TrVars()->PMSystemName(p26_S), p26_S); - systems.insert(qApp->TrVars()->PMSystemName(p27_S), p27_S); - systems.insert(qApp->TrVars()->PMSystemName(p28_S), p28_S); - systems.insert(qApp->TrVars()->PMSystemName(p29_S), p29_S); - systems.insert(qApp->TrVars()->PMSystemName(p30_S), p30_S); - systems.insert(qApp->TrVars()->PMSystemName(p31_S), p31_S); - systems.insert(qApp->TrVars()->PMSystemName(p32_S), p32_S); - systems.insert(qApp->TrVars()->PMSystemName(p33_S), p33_S); - systems.insert(qApp->TrVars()->PMSystemName(p34_S), p34_S); - systems.insert(qApp->TrVars()->PMSystemName(p35_S), p35_S); - systems.insert(qApp->TrVars()->PMSystemName(p36_S), p36_S); - systems.insert(qApp->TrVars()->PMSystemName(p37_S), p37_S); - systems.insert(qApp->TrVars()->PMSystemName(p38_S), p38_S); - systems.insert(qApp->TrVars()->PMSystemName(p39_S), p39_S); - systems.insert(qApp->TrVars()->PMSystemName(p40_S), p40_S); - systems.insert(qApp->TrVars()->PMSystemName(p41_S), p41_S); - systems.insert(qApp->TrVars()->PMSystemName(p42_S), p42_S); - systems.insert(qApp->TrVars()->PMSystemName(p43_S), p43_S); - systems.insert(qApp->TrVars()->PMSystemName(p44_S), p44_S); - systems.insert(qApp->TrVars()->PMSystemName(p45_S), p45_S); - systems.insert(qApp->TrVars()->PMSystemName(p46_S), p46_S); - systems.insert(qApp->TrVars()->PMSystemName(p47_S), p47_S); - systems.insert(qApp->TrVars()->PMSystemName(p48_S), p48_S); - systems.insert(qApp->TrVars()->PMSystemName(p49_S), p49_S); - systems.insert(qApp->TrVars()->PMSystemName(p50_S), p50_S); - systems.insert(qApp->TrVars()->PMSystemName(p51_S), p51_S); - systems.insert(qApp->TrVars()->PMSystemName(p52_S), p52_S); - systems.insert(qApp->TrVars()->PMSystemName(p53_S), p53_S); - systems.insert(qApp->TrVars()->PMSystemName(p54_S), p54_S); - -// * The default option (blank field or 'None') should appear at the top of the list. -// * The list should be sorted alphabetically so users can find their system easily. -// * 'None' would be in the middle of an alphabetically sorted list. - - systemCombo->addItem(qApp->TrVars()->PMSystemName(p998_S), p998_S); - - QMap::const_iterator i = systems.constBegin(); - while (i != systems.constEnd()) - { - systemCombo->addItem(i.key(), i.value()); - ++i; - } -} - //--------------------------------------------------------------------------------------------------------------------- void TapeConfigurationPage::RetranslateUi() { diff --git a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h index e3bb02c2d..67f8eb405 100644 --- a/src/app/tape/dialogs/configpages/tapeconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapeconfigurationpage.h @@ -77,7 +77,6 @@ private: QGroupBox *LangGroup(); void SetLabelComboBox(const QStringList &list); - void InitPMSystems(QComboBox *systemCombo); void RetranslateUi(); }; diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 9e2c9b86b..395c1d98d 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -73,7 +73,10 @@ TMainWindow::TMainWindow(QWidget *parent) comboBoxUnits(nullptr), formulaBaseHeight(0), lock(nullptr), - search() + search(), + labelGradationHeights(nullptr), + labelGradationSizes(nullptr), + labelPatternUnit(nullptr) { ui->setupUi(this); search = QSharedPointer(new VTableSearch(ui->tableWidget)); @@ -118,6 +121,7 @@ void TMainWindow::RetranslateTable() { const int row = ui->tableWidget->currentRow(); RefreshTable(); + ShowUnits(); ui->tableWidget->selectRow(row); } } @@ -447,6 +451,49 @@ void TMainWindow::changeEvent(QEvent *event) { // retranslate designer form (single inheritance approach) ui->retranslateUi(this); + + if (mType == MeasurementsType::Standard) + { + ui->labelMType->setText(tr("Standard measurements")); + ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + " " + + VDomDocument::UnitsToStr(m->MUnit(), true)); + ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + " " + + VDomDocument::UnitsToStr(m->MUnit(), true)); + + labelGradationHeights = new QLabel(tr("Height: ")); + labelGradationSizes = new QLabel(tr("Size: ")); + } + else + { + ui->labelMType->setText(tr("Individual measurements")); + + const qint32 index = ui->comboBoxGender->currentIndex(); + ui->comboBoxGender->blockSignals(true); + ui->comboBoxGender->clear(); + InitGender(ui->comboBoxGender); + ui->comboBoxGender->setCurrentIndex(index); + ui->comboBoxGender->blockSignals(false); + } + + { + const qint32 index = ui->comboBoxPMSystem->currentIndex(); + ui->comboBoxPMSystem->blockSignals(true); + ui->comboBoxPMSystem->clear(); + InitPMSystems(ui->comboBoxPMSystem); + ui->comboBoxPMSystem->setCurrentIndex(index); + ui->comboBoxPMSystem->blockSignals(false); + } + + { + labelPatternUnit = new QLabel(tr("Pattern unit:")); + + const qint32 index = comboBoxUnits->currentIndex(); + comboBoxUnits->blockSignals(true); + comboBoxUnits->clear(); + InitComboBoxUnits(); + comboBoxUnits->setCurrentIndex(index); + comboBoxUnits->blockSignals(false); + } } // remember to call base class implementation @@ -676,6 +723,19 @@ void TMainWindow::SaveNotes() } } +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::SavePMSystem(int index) +{ + QString system = ui->comboBoxPMSystem->itemData(index).toString(); + system.remove(0, 1);// clear p + + if (m->PMSystem() != system) + { + m->SetPMSystem(system); + MeasurementsWasSaved(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ReadOnly(bool ro) { @@ -1667,12 +1727,14 @@ void TMainWindow::InitWindow() const QStringList listHeights = VMeasurement::WholeListHeights(mUnit); const QStringList listSizes = VMeasurement::WholeListSizes(mUnit); - gradationHeights = SetGradationList(tr("Height: "), listHeights); + labelGradationHeights = new QLabel(tr("Height: ")); + gradationHeights = SetGradationList(labelGradationHeights, listHeights); SetDefaultHeight(static_cast(data->height())); connect(gradationHeights, static_cast(&QComboBox::currentIndexChanged), this, &TMainWindow::ChangedHeight); - gradationSizes = SetGradationList(tr("Size: "), listSizes); + labelGradationSizes = new QLabel(tr("Size: ")); + gradationSizes = SetGradationList(labelGradationSizes, listSizes); SetDefaultSize(static_cast(data->size())); connect(gradationSizes, static_cast(&QComboBox::currentIndexChanged), this, &TMainWindow::ChangedSize); @@ -1729,9 +1791,8 @@ void TMainWindow::InitWindow() ui->lineEditGivenName->setText(m->GivenName()); ui->lineEditFamilyName->setText(m->FamilyName()); - ui->comboBoxGender->addItem(tr("unknown", "gender"), QVariant(static_cast(GenderType::Unknown))); - ui->comboBoxGender->addItem(tr("male", "gender"), QVariant(static_cast(GenderType::Male))); - ui->comboBoxGender->addItem(tr("female", "gender"), QVariant(static_cast(GenderType::Female))); + ui->comboBoxGender->clear(); + InitGender(ui->comboBoxGender); const qint32 index = ui->comboBoxGender->findData(static_cast(m->Gender())); ui->comboBoxGender->setCurrentIndex(index); @@ -1753,6 +1814,14 @@ void TMainWindow::InitWindow() connect(ui->toolButtonExpr, &QToolButton::clicked, this, &TMainWindow::Fx); } + ui->comboBoxPMSystem->setEnabled(true); + ui->comboBoxPMSystem->clear(); + InitPMSystems(ui->comboBoxPMSystem); + const qint32 index = ui->comboBoxPMSystem->findData(QLatin1Char('p')+m->PMSystem()); + ui->comboBoxPMSystem->setCurrentIndex(index); + connect(ui->comboBoxPMSystem, static_cast(&QComboBox::currentIndexChanged), this, + &TMainWindow::SavePMSystem); + connect(ui->lineEditFind, &QLineEdit::textEdited, this, &TMainWindow::Find); connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, &TMainWindow::FindPrevious); connect(ui->toolButtonFindNext, &QToolButton::clicked, this, &TMainWindow::FindNext); @@ -1937,9 +2006,9 @@ QTableWidgetItem *TMainWindow::AddCell(const QString &text, int row, int column, } //--------------------------------------------------------------------------------------------------------------------- -QComboBox *TMainWindow::SetGradationList(const QString &label, const QStringList &list) +QComboBox *TMainWindow::SetGradationList(QLabel *label, const QStringList &list) { - ui->toolBarGradation->addWidget(new QLabel(label)); + ui->toolBarGradation->addWidget(label); QComboBox *comboBox = new QComboBox; comboBox->addItems(list); @@ -2253,6 +2322,8 @@ void TMainWindow::GUIReadOnly(bool ro) ui->lineEditEmail->setReadOnly(ro); } + ui->comboBoxPMSystem->setDisabled(ro); + MeasurementReadOnly(ro); } @@ -2521,12 +2592,11 @@ void TMainWindow::SetDecimals() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::InitUnits() { - ui->toolBarGradation->addWidget(new QLabel(tr("Pattern unit:"))); + labelPatternUnit = new QLabel(tr("Pattern unit:")); + ui->toolBarGradation->addWidget(labelPatternUnit); comboBoxUnits = new QComboBox(this); - comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Cm, true), QVariant(static_cast(Unit::Cm))); - comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Mm, true), QVariant(static_cast(Unit::Mm))); - comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Inch, true), QVariant(static_cast(Unit::Inch))); + InitComboBoxUnits(); // set default unit const qint32 indexUnit = comboBoxUnits->findData(static_cast(pUnit)); @@ -2541,6 +2611,24 @@ void TMainWindow::InitUnits() ui->toolBarGradation->addWidget(comboBoxUnits); } +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::InitComboBoxUnits() +{ + SCASSERT(comboBoxUnits != nullptr); + comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Cm, true), QVariant(static_cast(Unit::Cm))); + comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Mm, true), QVariant(static_cast(Unit::Mm))); + comboBoxUnits->addItem(VDomDocument::UnitsToStr(Unit::Inch, true), QVariant(static_cast(Unit::Inch))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::InitGender(QComboBox *gender) +{ + SCASSERT(gender != nullptr); + gender->addItem(tr("unknown", "gender"), QVariant(static_cast(GenderType::Unknown))); + gender->addItem(tr("male", "gender"), QVariant(static_cast(GenderType::Male))); + gender->addItem(tr("female", "gender"), QVariant(static_cast(GenderType::Female))); +} + //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::ShowInGraphicalShell() { diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 34ab5f677..9cbe6530d 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -87,6 +87,7 @@ private slots: void SaveGender(int index); void SaveBirthDate(const QDate & date); void SaveNotes(); + void SavePMSystem(int index); void ReadOnly(bool ro); void Remove(); @@ -138,12 +139,17 @@ private: int formulaBaseHeight; VLockGuardPtr lock; QSharedPointer search; + QLabel *labelGradationHeights; + QLabel *labelGradationSizes; + QLabel *labelPatternUnit; void SetupMenu(); void InitWindow(); void InitTable(); void SetDecimals(); void InitUnits(); + void InitComboBoxUnits(); + void InitGender(QComboBox *gender); void ShowUnits(); void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); @@ -156,7 +162,7 @@ private: QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true); - QComboBox *SetGradationList(const QString &label, const QStringList &list); + QComboBox *SetGradationList(QLabel *label, const QStringList &list); void SetDefaultHeight(int value); void SetDefaultSize(int value); diff --git a/src/app/tape/tmainwindow.ui b/src/app/tape/tmainwindow.ui index 114476d16..c4dddc246 100644 --- a/src/app/tape/tmainwindow.ui +++ b/src/app/tape/tmainwindow.ui @@ -566,70 +566,70 @@ - + Base size: - + Base size value - + Base height: - + Base height value - + Given name: - + false - + Family name: - + false - + Birth date: - + false @@ -652,42 +652,42 @@ - + Gender: - + false - + Email: - + false - + Notes: - + false @@ -700,6 +700,20 @@ + + + + PM system: + + + + + + + false + + + diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index b28677382..de7259a73 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -8,8 +8,10 @@ schema/pattern/v0.2.0.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd + schema/standard_measurements/v0.4.1.xsd schema/individual_measurements/v0.2.0.xsd schema/individual_measurements/v0.3.0.xsd schema/individual_measurements/v0.3.1.xsd + schema/individual_measurements/v0.3.2.xsd diff --git a/src/libs/ifc/schema/individual_measurements/v0.3.2.xsd b/src/libs/ifc/schema/individual_measurements/v0.3.2.xsd new file mode 100644 index 000000000..a6a241e53 --- /dev/null +++ b/src/libs/ifc/schema/individual_measurements/v0.3.2.xsd @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/schema/standard_measurements/v0.4.1.xsd b/src/libs/ifc/schema/standard_measurements/v0.4.1.xsd new file mode 100644 index 000000000..788adcbb1 --- /dev/null +++ b/src/libs/ifc/schema/standard_measurements/v0.4.1.xsd @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index a847146ca..bdd3eac36 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -40,8 +40,8 @@ */ const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0"); -const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.3.1"); -const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.3.1.xsd"); +const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.3.2"); +const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.3.2.xsd"); //--------------------------------------------------------------------------------------------------------------------- VVITConverter::VVITConverter(const QString &fileName) @@ -91,6 +91,8 @@ QString VVITConverter::XSDSchema(int ver) const case (0x000300): return QStringLiteral("://schema/individual_measurements/v0.3.0.xsd"); case (0x000301): + return QStringLiteral("://schema/individual_measurements/v0.3.1.xsd"); + case (0x000302): return CurrentSchema; default: { @@ -122,6 +124,13 @@ void VVITConverter::ApplyPatches() V_FALLTHROUGH } case (0x000301): + { + ToV0_3_2(); + const QString schema = XSDSchema(0x000302); + ValidateXML(schema, fileName); + V_FALLTHROUGH + } + case (0x000302): break; default: break; @@ -235,6 +244,19 @@ void VVITConverter::GenderV0_3_1() parent.replaceChild(gender, sex); } +//--------------------------------------------------------------------------------------------------------------------- +void VVITConverter::PM_SystemV0_3_2() +{ + QDomElement pm_system = createElement(QStringLiteral("pm_system")); + pm_system.appendChild(createTextNode(QStringLiteral("998"))); + + const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("personal")); + QDomElement personal = nodeList.at(0).toElement(); + + QDomElement parent = personal.parentNode().toElement(); + parent.insertBefore(pm_system, personal); +} + //--------------------------------------------------------------------------------------------------------------------- void VVITConverter::ToV0_3_0() { @@ -252,3 +274,11 @@ void VVITConverter::ToV0_3_1() GenderV0_3_1(); Save(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VVITConverter::ToV0_3_2() +{ + SetVersion(QStringLiteral("0.3.2")); + PM_SystemV0_3_2(); + Save(); +} diff --git a/src/libs/ifc/xml/vvitconverter.h b/src/libs/ifc/xml/vvitconverter.h index dc9d5d07b..10c808fee 100644 --- a/src/libs/ifc/xml/vvitconverter.h +++ b/src/libs/ifc/xml/vvitconverter.h @@ -60,9 +60,11 @@ private: void ConvertMeasurementsToV0_3_0(); QDomElement AddMV0_3_0(const QString &name, qreal value); void GenderV0_3_1(); + void PM_SystemV0_3_2(); void ToV0_3_0(); void ToV0_3_1(); + void ToV0_3_2(); }; #endif // VVITCONVERTER_H diff --git a/src/libs/ifc/xml/vvstconverter.cpp b/src/libs/ifc/xml/vvstconverter.cpp index 83ebac3a5..ea6c2d4ba 100644 --- a/src/libs/ifc/xml/vvstconverter.cpp +++ b/src/libs/ifc/xml/vvstconverter.cpp @@ -40,8 +40,8 @@ */ const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0"); -const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.4.0"); -const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/standard_measurements/v0.4.0.xsd"); +const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.4.1"); +const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/standard_measurements/v0.4.1.xsd"); //--------------------------------------------------------------------------------------------------------------------- VVSTConverter::VVSTConverter(const QString &fileName) @@ -89,6 +89,8 @@ QString VVSTConverter::XSDSchema(int ver) const case (0x000300): return QStringLiteral("://schema/standard_measurements/v0.3.0.xsd"); case (0x000400): + return QStringLiteral("://schema/standard_measurements/v0.4.0.xsd"); + case (0x000401): return CurrentSchema; default: { @@ -113,6 +115,13 @@ void VVSTConverter::ApplyPatches() V_FALLTHROUGH } case (0x000400): + { + ToV0_4_1(); + const QString schema = XSDSchema(0x000401); + ValidateXML(schema, fileName); + V_FALLTHROUGH + } + case (0x000401): break; default: break; @@ -241,6 +250,19 @@ QDomElement VVSTConverter::AddMV0_4_0(const QString &name, qreal value, qreal si return element; } +//--------------------------------------------------------------------------------------------------------------------- +void VVSTConverter::PM_SystemV0_4_1() +{ + QDomElement pm_system = createElement(QStringLiteral("pm_system")); + pm_system.appendChild(createTextNode(QStringLiteral("998"))); + + const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral("size")); + QDomElement personal = nodeList.at(0).toElement(); + + QDomElement parent = personal.parentNode().toElement(); + parent.insertBefore(pm_system, personal); +} + //--------------------------------------------------------------------------------------------------------------------- void VVSTConverter::ToV0_4_0() { @@ -251,3 +273,11 @@ void VVSTConverter::ToV0_4_0() ConvertMeasurementsToV0_4_0(); Save(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VVSTConverter::ToV0_4_1() +{ + SetVersion(QStringLiteral("0.4.1")); + PM_SystemV0_4_1(); + Save(); +} diff --git a/src/libs/ifc/xml/vvstconverter.h b/src/libs/ifc/xml/vvstconverter.h index 4a0d55c49..f124ff3fb 100644 --- a/src/libs/ifc/xml/vvstconverter.h +++ b/src/libs/ifc/xml/vvstconverter.h @@ -59,8 +59,10 @@ private: void RemoveTagsForV0_4_0(); void ConvertMeasurementsToV0_4_0(); QDomElement AddMV0_4_0(const QString &name, qreal value, qreal sizeIncrease, qreal heightIncrease); + void PM_SystemV0_4_1(); void ToV0_4_0(); + void ToV0_4_1(); }; #endif // VMEASUREMENTCONVERTER_H diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 91eed876e..e2f151596 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -45,6 +45,7 @@ const QString VMeasurements::TagFamilyName = QStringLiteral("family-name") const QString VMeasurements::TagGivenName = QStringLiteral("given-name"); const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date"); const QString VMeasurements::TagGender = QStringLiteral("gender"); +const QString VMeasurements::TagPMSystem = QStringLiteral("pm_system"); const QString VMeasurements::TagEmail = QStringLiteral("email"); const QString VMeasurements::TagReadOnly = QStringLiteral("read-only"); const QString VMeasurements::TagMeasurement = QStringLiteral("m"); @@ -411,6 +412,21 @@ void VMeasurements::SetGender(const GenderType &gender) } } +//--------------------------------------------------------------------------------------------------------------------- +QString VMeasurements::PMSystem() const +{ + return UniqueTagText(TagPMSystem, ClearPMCode(p998_S)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurements::SetPMSystem(const QString &system) +{ + if (not ReadOnly()) + { + setTagText(TagPMSystem, ClearPMCode(system)); + } +} + //--------------------------------------------------------------------------------------------------------------------- QString VMeasurements::Email() const { @@ -676,6 +692,10 @@ void VMeasurements::CreateEmptyStandardFile(Unit unit, int baseSize, int baseHei mUnit.appendChild(unitText); mElement.appendChild(mUnit); + QDomElement system = createElement(TagPMSystem); + system.appendChild(createTextNode(ClearPMCode(p998_S))); + mElement.appendChild(system); + QDomElement size = createElement(TagSize); SetAttribute(size, AttrBase, QString().setNum(baseSize)); mElement.appendChild(size); @@ -714,6 +734,10 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit) mUnit.appendChild(createTextNode(UnitsToStr(unit))); mElement.appendChild(mUnit); + QDomElement system = createElement(TagPMSystem); + system.appendChild(createTextNode(ClearPMCode(p998_S))); + mElement.appendChild(system); + QDomElement personal = createElement(TagPersonal); personal.appendChild(createElement(TagFamilyName)); personal.appendChild(createElement(TagGivenName)); @@ -862,3 +886,15 @@ qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool } } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VMeasurements::ClearPMCode(const QString &code) const +{ + QString clear = code; + const int index = clear.indexOf(QLatin1Char('p')); + if (index == 0) + { + clear.remove(0, 1); + } + return clear; +} diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 0e7bd148c..3c5e7f338 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -76,6 +76,9 @@ public: GenderType Gender() const; void SetGender(const GenderType &gender); + QString PMSystem() const; + void SetPMSystem(const QString &system); + QString Email() const; void SetEmail(const QString &text); @@ -102,6 +105,7 @@ public: static const QString TagGivenName; static const QString TagBirthDate; static const QString TagGender; + static const QString TagPMSystem; static const QString TagEmail; static const QString TagReadOnly; static const QString TagMeasurement; @@ -146,6 +150,8 @@ private: MeasurementsType ReadType() const; qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const; + + QString ClearPMCode(const QString &code) const; }; #endif // VMEASUREMENTS_H diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 36ec2bb2e..f61e9ee78 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -27,8 +27,10 @@ *************************************************************************/ #include "def.h" +#include "vabstractapplication.h" +#include "../vpatterndb/vtranslatevars.h" -#include +#include // Keep synchronize all names with initialization in VTranslateVars class!!!!! //measurements @@ -966,3 +968,77 @@ QStringList AllGroupNames() return originalNames; } + +//--------------------------------------------------------------------------------------------------------------------- +void InitPMSystems(QComboBox *systemCombo) +{ + QMap systems; + systems.insert(qApp->TrVars()->PMSystemName(p0_S), p0_S); + systems.insert(qApp->TrVars()->PMSystemName(p1_S), p1_S); + systems.insert(qApp->TrVars()->PMSystemName(p2_S), p2_S); + systems.insert(qApp->TrVars()->PMSystemName(p3_S), p3_S); + systems.insert(qApp->TrVars()->PMSystemName(p4_S), p4_S); + systems.insert(qApp->TrVars()->PMSystemName(p5_S), p5_S); + systems.insert(qApp->TrVars()->PMSystemName(p6_S), p6_S); + systems.insert(qApp->TrVars()->PMSystemName(p7_S), p7_S); + systems.insert(qApp->TrVars()->PMSystemName(p8_S), p8_S); + systems.insert(qApp->TrVars()->PMSystemName(p9_S), p9_S); + systems.insert(qApp->TrVars()->PMSystemName(p10_S), p10_S); + systems.insert(qApp->TrVars()->PMSystemName(p11_S), p11_S); + systems.insert(qApp->TrVars()->PMSystemName(p12_S), p12_S); + systems.insert(qApp->TrVars()->PMSystemName(p13_S), p13_S); + systems.insert(qApp->TrVars()->PMSystemName(p14_S), p14_S); + systems.insert(qApp->TrVars()->PMSystemName(p15_S), p15_S); + systems.insert(qApp->TrVars()->PMSystemName(p16_S), p16_S); + systems.insert(qApp->TrVars()->PMSystemName(p17_S), p17_S); + systems.insert(qApp->TrVars()->PMSystemName(p18_S), p18_S); + systems.insert(qApp->TrVars()->PMSystemName(p19_S), p19_S); + systems.insert(qApp->TrVars()->PMSystemName(p20_S), p20_S); + systems.insert(qApp->TrVars()->PMSystemName(p21_S), p21_S); + systems.insert(qApp->TrVars()->PMSystemName(p22_S), p22_S); + systems.insert(qApp->TrVars()->PMSystemName(p23_S), p23_S); + systems.insert(qApp->TrVars()->PMSystemName(p24_S), p24_S); + systems.insert(qApp->TrVars()->PMSystemName(p25_S), p25_S); + systems.insert(qApp->TrVars()->PMSystemName(p26_S), p26_S); + systems.insert(qApp->TrVars()->PMSystemName(p27_S), p27_S); + systems.insert(qApp->TrVars()->PMSystemName(p28_S), p28_S); + systems.insert(qApp->TrVars()->PMSystemName(p29_S), p29_S); + systems.insert(qApp->TrVars()->PMSystemName(p30_S), p30_S); + systems.insert(qApp->TrVars()->PMSystemName(p31_S), p31_S); + systems.insert(qApp->TrVars()->PMSystemName(p32_S), p32_S); + systems.insert(qApp->TrVars()->PMSystemName(p33_S), p33_S); + systems.insert(qApp->TrVars()->PMSystemName(p34_S), p34_S); + systems.insert(qApp->TrVars()->PMSystemName(p35_S), p35_S); + systems.insert(qApp->TrVars()->PMSystemName(p36_S), p36_S); + systems.insert(qApp->TrVars()->PMSystemName(p37_S), p37_S); + systems.insert(qApp->TrVars()->PMSystemName(p38_S), p38_S); + systems.insert(qApp->TrVars()->PMSystemName(p39_S), p39_S); + systems.insert(qApp->TrVars()->PMSystemName(p40_S), p40_S); + systems.insert(qApp->TrVars()->PMSystemName(p41_S), p41_S); + systems.insert(qApp->TrVars()->PMSystemName(p42_S), p42_S); + systems.insert(qApp->TrVars()->PMSystemName(p43_S), p43_S); + systems.insert(qApp->TrVars()->PMSystemName(p44_S), p44_S); + systems.insert(qApp->TrVars()->PMSystemName(p45_S), p45_S); + systems.insert(qApp->TrVars()->PMSystemName(p46_S), p46_S); + systems.insert(qApp->TrVars()->PMSystemName(p47_S), p47_S); + systems.insert(qApp->TrVars()->PMSystemName(p48_S), p48_S); + systems.insert(qApp->TrVars()->PMSystemName(p49_S), p49_S); + systems.insert(qApp->TrVars()->PMSystemName(p50_S), p50_S); + systems.insert(qApp->TrVars()->PMSystemName(p51_S), p51_S); + systems.insert(qApp->TrVars()->PMSystemName(p52_S), p52_S); + systems.insert(qApp->TrVars()->PMSystemName(p53_S), p53_S); + systems.insert(qApp->TrVars()->PMSystemName(p54_S), p54_S); + +// * The default option (blank field or 'None') should appear at the top of the list. +// * The list should be sorted alphabetically so users can find their system easily. + + SCASSERT(systemCombo != nullptr); + systemCombo->addItem(qApp->TrVars()->PMSystemName(p998_S), p998_S); + + QMap::const_iterator i = systems.constBegin(); + while (i != systems.constEnd()) + { + systemCombo->addItem(i.key(), i.value()); + ++i; + } +} diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 8668b21cc..e2b030f69 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -38,6 +38,8 @@ #include "debugbreak.h" +class QComboBox; + #define SceneSize 50000 #define DefPointRadius 1.5//mm @@ -517,6 +519,8 @@ extern const QString p53_S; extern const QString p54_S; extern const QString p998_S; +void InitPMSystems(QComboBox *systemCombo); + // functions extern const QString sin_F; extern const QString cos_F;