diff --git a/src/app/tape/vlitepattern.cpp b/src/app/tape/vlitepattern.cpp index 5f1dbe0c6..1908979a2 100644 --- a/src/app/tape/vlitepattern.cpp +++ b/src/app/tape/vlitepattern.cpp @@ -35,9 +35,8 @@ VLitePattern::VLitePattern(QObject *parent) } //--------------------------------------------------------------------------------------------------------------------- -void VLitePattern::CreateEmptyFile(const QString &tablePath) +void VLitePattern::CreateEmptyFile() { - Q_UNUSED(tablePath) } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/vlitepattern.h b/src/app/tape/vlitepattern.h index 25fde389e..a540eb327 100644 --- a/src/app/tape/vlitepattern.h +++ b/src/app/tape/vlitepattern.h @@ -37,7 +37,7 @@ class VLitePattern : public VAbstractPattern public: VLitePattern(QObject *parent = nullptr); - virtual void CreateEmptyFile(const QString &tablePath) Q_DECL_OVERRIDE; + virtual void CreateEmptyFile() Q_DECL_OVERRIDE; virtual void IncrementReferens(quint32 id) const Q_DECL_OVERRIDE; virtual void DecrementReferens(quint32 id) const Q_DECL_OVERRIDE; diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index a1c5c8be5..ad8cec26d 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -147,8 +147,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par ui->lineEditGivenName->setText(m->GivenName()); ui->lineEditFamilyName->setText(m->FamilyName()); - ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(SexType::Male))); - ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(SexType::Female))); + ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(SexType1::Male))); + ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(SexType1::Female))); qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex())); if (index != -1) { diff --git a/src/app/valentina/dialogs/dialogindividualmeasurements.cpp b/src/app/valentina/dialogs/dialogindividualmeasurements.cpp deleted file mode 100644 index 4cc22e06c..000000000 --- a/src/app/valentina/dialogs/dialogindividualmeasurements.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/************************************************************************ - ** - ** @file dialogindividualmeasurements.cpp - ** @author Roman Telezhynskyi - ** @date 22 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013-2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "dialogindividualmeasurements.h" -#include "ui_dialogindividualmeasurements.h" -#include "../xml/vindividualmeasurements.h" -#include "../core/vapplication.h" -#include "../../libs/vmisc/vsettings.h" -#include "../../libs/vpatterndb/vcontainer.h" - -#include -#include -#include -#include -#include - -//--------------------------------------------------------------------------------------------------------------------- -DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, - QWidget *parent) : - QDialog(parent), ui(new Ui::DialogIndividualMeasurements), _name(patternPieceName), _tablePath(QString()), - data(data) -{ - ui->setupUi(this); - - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); - - QRect position = this->frameGeometry(); - position.moveCenter(QDesktopWidget().availableGeometry().center()); - move(position.topLeft()); - - { - const QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - SCASSERT(bOk != nullptr); - connect(bOk, &QPushButton::clicked, this, &DialogIndividualMeasurements::DialogAccepted); - } - { - const QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - SCASSERT(bCansel != nullptr); - connect(bCansel, &QPushButton::clicked, this, &DialogIndividualMeasurements::DialogRejected); - } - - ui->lineEditName->setText(_name); - - InitUnits(); - CheckState(); - connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogIndividualMeasurements::CheckState); - connect(ui->buttonGroupPath, static_cast(&QButtonGroup::buttonClicked), this, - &DialogIndividualMeasurements::CheckState); - connect(ui->toolButtonOpenExist, &QToolButton::clicked, this, &DialogIndividualMeasurements::OpenTable); - connect(ui->toolButtonOpenNew, &QToolButton::clicked, this, &DialogIndividualMeasurements::NewTable); - - adjustSize(); - setMaximumSize(size()); - setMinimumSize(size()); -} - -//--------------------------------------------------------------------------------------------------------------------- -DialogIndividualMeasurements::~DialogIndividualMeasurements() -{ - delete ui; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogIndividualMeasurements::DialogAccepted() -{ - _name = ui->lineEditName->text(); - if (ui->radioButtonExistM->isChecked()) - { - _tablePath = ui->lineEditPathExistM->text(); - } - else - { - _tablePath = ui->lineEditPathNewM->text(); - QFile table(_tablePath); - if (table.exists()) - { - table.remove(); - } - - //just in case - const QString path = QStringLiteral("://tables/individual/individual.vit"); - VDomDocument::ValidateXML("://schema/individual_measurements.xsd", path); - QFile iMeasur(path); - //TODO maybe make copy save? - if ( iMeasur.copy(_tablePath) == false ) - { - QMessageBox::warning(this, tr("Could not create measurements file"), tr("Please try again or change file")); - DialogRejected(); - } - } - try - { - VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath); - VIndividualMeasurements m(data); - m.setXMLContent(_tablePath); - const qint32 index = ui->comboBoxUnits->currentIndex(); - Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); - m.setUnit(unit); - qApp->setPatternUnit( m.MUnit()); - QFile iMeasur(_tablePath); - if (iMeasur.open(QIODevice::WriteOnly| QIODevice::Truncate)) - { - const int indent = 4; - QTextStream out(&iMeasur); - out.setCodec("UTF-8"); - m.save(out, indent); - iMeasur.close(); - } - iMeasur.setPermissions(QFile::ReadOwner | QFile::WriteOwner); - } - catch (VException &e) - { - e.CriticalMessageBox(tr("File error."), this); - qDebug()<<"File error."<lineEditName->text().isEmpty() == false) - { - flagName = true; - } - - bool flagPath = false; - if (ui->radioButtonExistM->isChecked()) - { - ui->labelGivenName->setEnabled(true); - ui->labelFamilyName->setEnabled(true); - ui->lineEditPathExistM->setEnabled(true); - ui->toolButtonOpenExist->setEnabled(true); - - ui->lineEditPathNewM->setEnabled(false); - ui->toolButtonOpenNew->setEnabled(false); - ui->comboBoxUnits->setEnabled(false); - - if (ui->lineEditPathExistM->text().isEmpty() == false) - { - flagPath = true; - } - } - else - { - ui->lineEditPathNewM->setEnabled(true); - ui->toolButtonOpenNew->setEnabled(true); - ui->comboBoxUnits->setEnabled(true); - - ui->labelGivenName->setEnabled(false); - ui->labelFamilyName->setEnabled(false); - ui->toolButtonOpenExist->setEnabled(false); - ui->lineEditPathExistM->setEnabled(false); - - if (ui->lineEditPathNewM->text().isEmpty() == false) - { - flagPath = true; - } - } - - - QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - SCASSERT(bOk != nullptr); - bOk->setEnabled(flagName && flagPath); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogIndividualMeasurements::OpenTable() -{ - const QString filter(tr("Individual measurements (*.vit)")); - const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements(); - - QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); - if (fileName.isEmpty()) - { - return; - } - - try - { - VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fileName); - } - catch (VException &e) - { - e.CriticalMessageBox(tr("File error."), this); - fileName.clear(); - } - VIndividualMeasurements m(data); - m.setXMLContent(fileName); - ui->labelGivenName->setText(m.GivenName()); - ui->labelFamilyName->setText(m.FamilyName()); - ui->lineEditPathExistM->setText(fileName); - ui->lineEditPathExistM->setToolTip(fileName); - CheckState(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogIndividualMeasurements::NewTable() -{ - const QString dir = qApp->ValentinaSettings()->GetPathIndividualMeasurements()+"/measurements.vit"; - QString name = QFileDialog::getSaveFileName(this, tr("Where save measurements?"), dir, - tr("Individual measurements (*.vit)")); - - if (name.isEmpty()) - { - return; - } - - // what if the users did not specify a suffix...? - const QFileInfo f( name ); - if (f.suffix().isEmpty() && f.suffix() != "vit") - { - name += ".vit"; - } - ui->lineEditPathNewM->setText(name); - ui->lineEditPathNewM->setToolTip(name); - CheckState(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogIndividualMeasurements::InitUnits() -{ - ui->comboBoxUnits->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); - ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); - ui->comboBoxUnits->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); - - // set default unit - const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->ValentinaSettings()->GetUnit()); - if (indexUnit != -1) - { - ui->comboBoxUnits->setCurrentIndex(indexUnit); - } -} diff --git a/src/app/valentina/dialogs/dialogindividualmeasurements.h b/src/app/valentina/dialogs/dialogindividualmeasurements.h deleted file mode 100644 index 793bd2908..000000000 --- a/src/app/valentina/dialogs/dialogindividualmeasurements.h +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************ - ** - ** @file dialogindividualmeasurements.h - ** @author Roman Telezhynskyi - ** @date 22 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013-2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef DIALOGINDIVIDUALMEASUREMENTS_H -#define DIALOGINDIVIDUALMEASUREMENTS_H - -#include - -class VContainer; - -namespace Ui -{ - class DialogIndividualMeasurements; -} - -class DialogIndividualMeasurements : public QDialog -{ - Q_OBJECT -public: - DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); - ~DialogIndividualMeasurements(); - QString name() const; - QString tablePath() const; -public slots: - void OpenTable(); - void NewTable(); - void CheckState(); - void DialogAccepted(); - void DialogRejected(); -private: - Q_DISABLE_COPY(DialogIndividualMeasurements) - Ui::DialogIndividualMeasurements *ui; - QString _name; - QString _tablePath; - VContainer *data; - void InitUnits(); -}; - -//--------------------------------------------------------------------------------------------------------------------- -inline QString DialogIndividualMeasurements::name() const -{ - return _name; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline QString DialogIndividualMeasurements::tablePath() const -{ - return _tablePath; -} - -#endif // DIALOGINDIVIDUALMEASUREMENTS_H diff --git a/src/app/valentina/dialogs/dialogindividualmeasurements.ui b/src/app/valentina/dialogs/dialogindividualmeasurements.ui deleted file mode 100644 index 0f51b031f..000000000 --- a/src/app/valentina/dialogs/dialogindividualmeasurements.ui +++ /dev/null @@ -1,288 +0,0 @@ - - - DialogIndividualMeasurements - - - Qt::ApplicationModal - - - - 0 - 0 - 505 - 295 - - - - Individual measurements - - - - :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - true - - - - - - - - Pattern piece name - - - - - - - - - - - - - - Exist measurements - - - false - - - buttonGroupPath - - - - - - - - - Path: - - - - - - - true - - - - - - - ... - - - - - - - - - - - - - - QLayout::SetMinimumSize - - - - - true - - - - 0 - 0 - - - - - 90 - 0 - - - - Given name: - - - - - - - - 1 - 0 - - - - - - - true - - - - - - - - - QLayout::SetMinimumSize - - - - - - 0 - 0 - - - - - 90 - 0 - - - - Family name: - - - - - - - - 1 - 0 - - - - - - - true - - - - - - - - - - - - - New measurements - - - true - - - buttonGroupPath - - - - - - - - - Units: - - - - - - - - - - - - - - Path: - - - - - - - true - - - - - - - ... - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - DialogIndividualMeasurements - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DialogIndividualMeasurements - reject() - - - 316 - 260 - - - 286 - 274 - - - - - - - - diff --git a/src/app/valentina/dialogs/dialogmeasurements.cpp b/src/app/valentina/dialogs/dialogmeasurements.cpp deleted file mode 100644 index 5965a4709..000000000 --- a/src/app/valentina/dialogs/dialogmeasurements.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpatterntype.cpp - ** @author Roman Telezhynskyi - ** @date 21 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013-2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "dialogmeasurements.h" -#include "ui_dialogmeasurements.h" -#include "../core/vapplication.h" - -//--------------------------------------------------------------------------------------------------------------------- -DialogMeasurements::DialogMeasurements(QWidget *parent) : - QDialog(parent), ui(new Ui::DialogMeasurements), result(MeasurementsType::Individual) -{ - ui->setupUi(this); - - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); - - connect(ui->toolButtonStandard, &QToolButton::clicked, this, &DialogMeasurements::StandardMeasurements); - connect(ui->toolButtonIndividual, &QToolButton::clicked, this, &DialogMeasurements::IndividualMeasurements); - - adjustSize(); - setMaximumSize(size()); - setMinimumSize(size()); -} - -//--------------------------------------------------------------------------------------------------------------------- -DialogMeasurements::~DialogMeasurements() -{ - delete ui; -} - -//--------------------------------------------------------------------------------------------------------------------- -MeasurementsType DialogMeasurements::type() const -{ - return result; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogMeasurements::StandardMeasurements() -{ - result = MeasurementsType::Standard; - accept(); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogMeasurements::IndividualMeasurements() -{ - result = MeasurementsType::Individual; - accept(); -} diff --git a/src/app/valentina/dialogs/dialogmeasurements.h b/src/app/valentina/dialogs/dialogmeasurements.h deleted file mode 100644 index d0004bc47..000000000 --- a/src/app/valentina/dialogs/dialogmeasurements.h +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************ - ** - ** @file dialogpatterntype.h - ** @author Roman Telezhynskyi - ** @date 21 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013-2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef DIALOGMEASUREMENTS_H -#define DIALOGMEASUREMENTS_H - -#include -#include "../options.h" - -namespace Ui -{ - class DialogMeasurements; -} - -class DialogMeasurements : public QDialog -{ - Q_OBJECT -public: - explicit DialogMeasurements(QWidget *parent = nullptr); - ~DialogMeasurements(); - MeasurementsType type() const; -private: - Q_DISABLE_COPY(DialogMeasurements) - Ui::DialogMeasurements *ui; - MeasurementsType result; - void StandardMeasurements(); - void IndividualMeasurements(); -}; - -#endif // DIALOGMEASUREMENTS_H diff --git a/src/app/valentina/dialogs/dialogmeasurements.ui b/src/app/valentina/dialogs/dialogmeasurements.ui deleted file mode 100644 index 19d54cf89..000000000 --- a/src/app/valentina/dialogs/dialogmeasurements.ui +++ /dev/null @@ -1,158 +0,0 @@ - - - DialogMeasurements - - - Qt::ApplicationModal - - - - 0 - 0 - 448 - 244 - - - - Measurements - - - - :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png - - - true - - - - - - - - - 0 - 0 - - - - <html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html> - - - Qt::AlignCenter - - - - - - - - - - - - 166 - 123 - - - - - 166 - 123 - - - - Graduation - - - - :/icon/Graduation.png:/icon/Graduation.png - - - - 160 - 120 - - - - - - - - - 0 - 0 - - - - Use for creation pattern standard measurement table - - - true - - - - - - - - - - - - 166 - 123 - - - - - 166 - 123 - - - - Individual - - - - :/icon/individual.png:/icon/individual.png - - - - 160 - 120 - - - - - - - - - 0 - 0 - - - - Use for creation pattern individual measurements - - - true - - - - - - - - - - - - - toolButtonStandard - - - - - - diff --git a/src/app/valentina/dialogs/dialognewpattern.cpp b/src/app/valentina/dialogs/dialognewpattern.cpp new file mode 100644 index 000000000..782933a5f --- /dev/null +++ b/src/app/valentina/dialogs/dialognewpattern.cpp @@ -0,0 +1,111 @@ +/************************************************************************ + ** + ** @file dialognewpattern.cpp + ** @author Roman Telezhynskyi + ** @date 22 2, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialognewpattern.h" +#include "ui_dialognewpattern.h" +#include "../xml/vindividualmeasurements.h" +#include "../core/vapplication.h" +#include "../../libs/vmisc/vsettings.h" +#include "../../libs/vpatterndb/vcontainer.h" + +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogNewPattern::DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent) + :QDialog(parent), ui(new Ui::DialogNewPattern), data(data) +{ + ui->setupUi(this); + + qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); + + QRect position = this->frameGeometry(); + position.moveCenter(QDesktopWidget().availableGeometry().center()); + move(position.topLeft()); + + ui->lineEditName->setText(patternPieceName); + + InitUnits(); + CheckState(); + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogNewPattern::CheckState); + + adjustSize(); + setMaximumSize(size()); + setMinimumSize(size()); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogNewPattern::~DialogNewPattern() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit DialogNewPattern::PatternUnit() const +{ + const qint32 index = ui->comboBoxUnits->currentIndex(); + return VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNewPattern::CheckState() +{ + bool flagName = false; + if (ui->lineEditName->text().isEmpty() == false) + { + flagName = true; + } + + QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + SCASSERT(bOk != nullptr); + bOk->setEnabled(flagName); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNewPattern::InitUnits() +{ + ui->comboBoxUnits->addItem(tr("Centimeters"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); + ui->comboBoxUnits->addItem(tr("Millimiters"), QVariant(VDomDocument::UnitsToStr(Unit::Mm))); + ui->comboBoxUnits->addItem(tr("Inches"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); + + // set default unit + const qint32 indexUnit = ui->comboBoxUnits->findData(qApp->ValentinaSettings()->GetUnit()); + if (indexUnit != -1) + { + ui->comboBoxUnits->setCurrentIndex(indexUnit); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogNewPattern::name() const +{ + return ui->lineEditName->text(); +} diff --git a/src/app/valentina/dialogs/dialogstandardmeasurements.h b/src/app/valentina/dialogs/dialognewpattern.h similarity index 67% rename from src/app/valentina/dialogs/dialogstandardmeasurements.h rename to src/app/valentina/dialogs/dialognewpattern.h index cc1785367..966e9d9e7 100644 --- a/src/app/valentina/dialogs/dialogstandardmeasurements.h +++ b/src/app/valentina/dialogs/dialognewpattern.h @@ -1,8 +1,8 @@ /************************************************************************ ** - ** @file dialogstandardmeasurements.h + ** @file dialogindividualmeasurements.h ** @author Roman Telezhynskyi - ** @date 21 2, 2014 + ** @date 22 2, 2014 ** ** @brief ** @copyright @@ -26,37 +26,35 @@ ** *************************************************************************/ -#ifndef DIALOGSTANDARDMEASUREMENTS_H -#define DIALOGSTANDARDMEASUREMENTS_H +#ifndef DIALOGINDIVIDUALMEASUREMENTS_H +#define DIALOGINDIVIDUALMEASUREMENTS_H #include +#include "../vmisc/def.h" + class VContainer; namespace Ui { - class DialogStandardMeasurements; + class DialogNewPattern; } -class DialogStandardMeasurements : public QDialog +class DialogNewPattern : public QDialog { Q_OBJECT public: - DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); - ~DialogStandardMeasurements(); + DialogNewPattern(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr); + ~DialogNewPattern(); QString name() const; - QString tablePath() const; + Unit PatternUnit() const; public slots: - void DialogAccepted(); - void DialogRejected(); void CheckState(); private: - Q_DISABLE_COPY(DialogStandardMeasurements) - Ui::DialogStandardMeasurements *ui; + Q_DISABLE_COPY(DialogNewPattern) + Ui::DialogNewPattern *ui; VContainer *data; - QString _name; - QString _tablePath; - void LoadStandardTables(); + void InitUnits(); }; -#endif // DIALOGSTANDARDMEASUREMENTS_H +#endif // DIALOGINDIVIDUALMEASUREMENTS_H diff --git a/src/app/valentina/dialogs/dialogstandardmeasurements.ui b/src/app/valentina/dialogs/dialognewpattern.ui similarity index 51% rename from src/app/valentina/dialogs/dialogstandardmeasurements.ui rename to src/app/valentina/dialogs/dialognewpattern.ui index d5e86603a..5145a4e5a 100644 --- a/src/app/valentina/dialogs/dialogstandardmeasurements.ui +++ b/src/app/valentina/dialogs/dialognewpattern.ui @@ -1,7 +1,7 @@ - DialogStandardMeasurements - + DialogNewPattern + Qt::ApplicationModal @@ -9,12 +9,12 @@ 0 0 - 430 + 325 113 - Standard table + Individual measurements @@ -28,66 +28,28 @@ - - - 0 - 0 - - - - - 206 - 0 - - Pattern piece name - - 0 - - - - - 0 - 0 - - - + - - - - 0 - 0 - - + - Standard measurements table + Units: - - - - 0 - 0 - - - + - - Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -102,32 +64,32 @@ buttonBox accepted() - DialogStandardMeasurements + DialogNewPattern accept() - 248 - 254 + 162 + 90 - 157 - 274 + 162 + 56 buttonBox rejected() - DialogStandardMeasurements + DialogNewPattern reject() - 316 - 260 + 162 + 90 - 286 - 274 + 162 + 56 diff --git a/src/app/valentina/dialogs/dialogs.h b/src/app/valentina/dialogs/dialogs.h index 5b5480f6a..f83a16e0e 100644 --- a/src/app/valentina/dialogs/dialogs.h +++ b/src/app/valentina/dialogs/dialogs.h @@ -33,9 +33,7 @@ #include "dialogincrements.h" #include "configdialog.h" #include "dialogpatternproperties.h" -#include "dialogmeasurements.h" -#include "dialogindividualmeasurements.h" -#include "dialogstandardmeasurements.h" +#include "dialognewpattern.h" #include "dialogaboutapp.h" #include "dialogpatternxmledit.h" diff --git a/src/app/valentina/dialogs/dialogs.pri b/src/app/valentina/dialogs/dialogs.pri index 685d578f5..f110de946 100644 --- a/src/app/valentina/dialogs/dialogs.pri +++ b/src/app/valentina/dialogs/dialogs.pri @@ -8,9 +8,7 @@ HEADERS += \ $$PWD/configdialog.h \ $$PWD/configpages/pages.h \ $$PWD/dialogpatternproperties.h \ - $$PWD/dialogmeasurements.h \ - $$PWD/dialogstandardmeasurements.h \ - $$PWD/dialogindividualmeasurements.h \ + $$PWD/dialognewpattern.h \ $$PWD/dialogaboutapp.h \ $$PWD/dialogpatternxmledit.h \ $$PWD/configpages/configurationpage.h \ @@ -26,9 +24,7 @@ SOURCES += \ $$PWD/dialoghistory.cpp \ $$PWD/configdialog.cpp \ $$PWD/dialogpatternproperties.cpp \ - $$PWD/dialogmeasurements.cpp \ - $$PWD/dialogstandardmeasurements.cpp \ - $$PWD/dialogindividualmeasurements.cpp \ + $$PWD/dialognewpattern.cpp \ $$PWD/dialogaboutapp.cpp \ $$PWD/dialogpatternxmledit.cpp \ $$PWD/configpages/configurationpage.cpp \ @@ -43,9 +39,7 @@ FORMS += \ $$PWD/dialogincrements.ui \ $$PWD/dialoghistory.ui \ $$PWD/dialogpatternproperties.ui \ - $$PWD/dialogmeasurements.ui \ - $$PWD/dialogstandardmeasurements.ui \ - $$PWD/dialogindividualmeasurements.ui \ + $$PWD/dialognewpattern.ui \ $$PWD/dialogaboutapp.ui \ $$PWD/dialogpatternxmledit.ui \ $$PWD/dialoglayoutsettings.ui \ diff --git a/src/app/valentina/dialogs/dialogstandardmeasurements.cpp b/src/app/valentina/dialogs/dialogstandardmeasurements.cpp deleted file mode 100644 index 52843c1df..000000000 --- a/src/app/valentina/dialogs/dialogstandardmeasurements.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/************************************************************************ - ** - ** @file dialogstandardmeasurements.cpp - ** @author Roman Telezhynskyi - ** @date 21 2, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2013-2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "dialogstandardmeasurements.h" -#include "ui_dialogstandardmeasurements.h" -#include "../xml/vstandardmeasurements.h" -#include "../core/vapplication.h" -#include "../../libs/vmisc/vsettings.h" -#include "../../libs/vpatterndb/vcontainer.h" -#include "../vmisc/logging.h" - -#include -#include -#include - -Q_LOGGING_CATEGORY(vStMeasur, "v.st.measurements") - -//--------------------------------------------------------------------------------------------------------------------- -DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, - QWidget *parent) : - QDialog(parent), ui(new Ui::DialogStandardMeasurements), data(data), _name(patternPieceName), _tablePath(QString()) -{ - ui->setupUi(this); - - qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); - - QRect position = this->frameGeometry(); - position.moveCenter(QDesktopWidget().availableGeometry().center()); - move(position.topLeft()); - - { - const QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - SCASSERT(bOk != nullptr); - connect(bOk, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogAccepted); - } - { - const QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); - SCASSERT(bCansel != nullptr); - connect(bCansel, &QPushButton::clicked, this, &DialogStandardMeasurements::DialogRejected); - } - - qCDebug(vStMeasur, "Pattern piece name %s", _name.toUtf8().constData()); - ui->lineEditName->setText(_name); - - LoadStandardTables(); - - CheckState(); - connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogStandardMeasurements::CheckState); - - adjustSize(); - setMaximumSize(size()); - setMinimumSize(size()); -} - -//--------------------------------------------------------------------------------------------------------------------- -DialogStandardMeasurements::~DialogStandardMeasurements() -{ - delete ui; -} - -//--------------------------------------------------------------------------------------------------------------------- -QString DialogStandardMeasurements::name() const -{ - return _name; -} - -//--------------------------------------------------------------------------------------------------------------------- -QString DialogStandardMeasurements::tablePath() const -{ - return _tablePath; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogStandardMeasurements::DialogAccepted() -{ - _name = ui->lineEditName->text(); - const qint32 index = ui->comboBoxTables->currentIndex(); - _tablePath = ui->comboBoxTables->itemData(index).toString(); - - try - { - VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath); - VStandardMeasurements m(data); - m.setXMLContent(_tablePath); - qApp->setPatternUnit(m.MUnit()); - } - catch (VException &e) - { - e.CriticalMessageBox(tr("File error."), this); - qDebug()<<"File error."<lineEditName->text().isEmpty() == false) - { - flagName = true; - } - - bool flagTable = false; - { - const QComboBox *box = ui->comboBoxTables; - SCASSERT(box != nullptr); - if (box->count() > 0 && box->currentIndex() != -1) - { - flagTable = true; - } - } - - QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); - SCASSERT(bOk != nullptr); - bOk->setEnabled(flagTable && flagName); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogStandardMeasurements::LoadStandardTables() -{ - qCDebug(vStMeasur, "Loading standard table."); - QStringList filters{"*.vst"}; - //Use standard path to standard measurements - const QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements(); - QDir tablesDir(path); - tablesDir.setNameFilters(filters); - tablesDir.setCurrent(path); - - const QStringList allFiles = tablesDir.entryList(QDir::NoDotAndDotDot | QDir::Files); - if (allFiles.isEmpty() == true) - { - qCDebug(vStMeasur, "Can't find standard measurements in path %s", path.toUtf8().constData()); - ui->comboBoxTables->clear(); - CheckState(); - return; - } - - qCDebug(vStMeasur, "Was found %d tables.", allFiles.size()); - for (int i = 0; i < allFiles.size(); ++i) - { - QFileInfo fi(allFiles.at(i)); - try - { - VDomDocument::ValidateXML("://schema/standard_measurements.xsd", fi.absoluteFilePath()); - VStandardMeasurements m(data); - m.setXMLContent(fi.absoluteFilePath()); - if (m.MUnit() == Unit::Inch) - { - qCWarning(vStMeasur, "We do not support inches for standard table. Ignore table %s .", - fi.absoluteFilePath().toUtf8().constData()); - } - else - { - const QString desc = m.TrDescription(); - if (desc.isEmpty() == false) - { - qCDebug(vStMeasur, "Adding table from %s", fi.absoluteFilePath().toUtf8().constData()); - ui->comboBoxTables->addItem(desc, QVariant(fi.absoluteFilePath())); - } - } - } - catch (VException &e) - { - qCDebug(vStMeasur, "File error. %s %s", e.ErrorMessage().toUtf8().constData(), - e.DetailedInformation().toUtf8().constData()); - continue; - } - } -} diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 813abb419..59f504ae2 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -45,6 +45,9 @@ #include "options.h" #include "../ifc/xml/vpatternconverter.h" #include "../vmisc/logging.h" +#include "../vformat/vmeasurements.h" +#include "../ifc/xml/vvstconverter.h" +#include "../ifc/xml/vvitconverter.h" #include #include @@ -157,11 +160,11 @@ void MainWindow::NewPP() return; } - AddPP(patternPieceName, doc->MPath()); + AddPP(patternPieceName); } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::AddPP(const QString &PPName, const QString &path) +void MainWindow::AddPP(const QString &PPName) { if (doc->appendPP(PPName) == false) { @@ -176,7 +179,7 @@ void MainWindow::AddPP(const QString &PPName, const QString &path) ui->view->itemClicked(nullptr);//hide options previous tool const QString label = doc->GenerateLabel(LabelType::NewPatternPiece); const quint32 id = pattern->AddGObject(new VPointF(30+comboBoxDraws->count()*5, 40, label, 5, 10)); - VToolBasePoint *spoint = new VToolBasePoint(doc, pattern, id, Source::FromGui, PPName, path); + VToolBasePoint *spoint = new VToolBasePoint(doc, pattern, id, Source::FromGui, PPName); sceneDraw->addItem(spoint); ui->view->itemClicked(spoint); @@ -2018,69 +2021,19 @@ void MainWindow::New() qCDebug(vMainWindow, "New PP."); QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); qCDebug(vMainWindow, "Generated PP name: %s", patternPieceName.toUtf8().constData()); - QString path; qCDebug(vMainWindow, "First PP"); - DialogMeasurements measurements(this); - if (measurements.exec() == QDialog::Rejected) + DialogNewPattern newPattern(pattern, patternPieceName, this); + if (newPattern.exec() == QDialog::Accepted) { - qCDebug(vMainWindow, "Creation PP was canceled"); - return; - } - if (measurements.type() == MeasurementsType::Standard) - { - qCDebug(vMainWindow, "PP with standard measurements"); - qApp->setPatternType(MeasurementsType::Standard); - DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this); - if (stMeasurements.exec() == QDialog::Accepted) - { - patternPieceName = stMeasurements.name(); - qCDebug(vMainWindow, "PP name: %s", patternPieceName.toUtf8().constData()); - path = stMeasurements.tablePath(); - qCDebug(vMainWindow, "Table path: %s", path.toUtf8().constData()); - VStandardMeasurements m(pattern); - m.setXMLContent(path); - m.SetSize(); - m.SetHeight(); - m.Measurements(); - } - else - { - qCDebug(vMainWindow, "Selection standard measurements canceled."); - return; - } + patternPieceName = newPattern.name(); + qApp->setPatternUnit(newPattern.PatternUnit()); + qCDebug(vMainWindow, "PP name: %s", patternPieceName.toUtf8().constData()); } else { - qCDebug(vMainWindow, "PP with individual measurements."); - QMessageBox::StandardButton ret; - ret = QMessageBox::question(this, tr("Individual measurements is under development"), - tr("There is no way create individual measurements file independent on the " - "pattern file.\nFor opening pattern need keep both files: pattern and " - "measurements. Do you want continue?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if (ret == QMessageBox::No) - { - return; - } - - qApp->setPatternType(MeasurementsType::Individual); - DialogIndividualMeasurements indMeasurements(pattern, patternPieceName, this); - if (indMeasurements.exec() == QDialog::Accepted) - { - patternPieceName = indMeasurements.name(); - qCDebug(vMainWindow, "PP name: %s", patternPieceName.toUtf8().constData()); - path = indMeasurements.tablePath(); - qCDebug(vMainWindow, "Table path: %s", path.toUtf8().constData()); - VIndividualMeasurements m(pattern); - m.setXMLContent(path); - m.Measurements(); - } - else - { - qCDebug(vMainWindow, "Selection individual measurements canceled."); - return; - } + qCDebug(vMainWindow, "Creation a new pattern was canceled."); + return; } //Set scene size to size scene view @@ -2088,7 +2041,7 @@ void MainWindow::New() VMainGraphicsView::NewSceneRect(sceneDetails, ui->view); ToolBarOption(); - AddPP(patternPieceName, path); + AddPP(patternPieceName); } else { @@ -2853,10 +2806,9 @@ void MainWindow::LoadPattern(const QString &fileName) doc->setXMLContent(fileName); qApp->setPatternUnit(doc->MUnit()); - qApp->setPatternType(doc->MType()); QString path = doc->MPath(); - path = CheckPathToMeasurements(path, qApp->patternType()); + path = CheckPathToMeasurements(path); if (path.isEmpty()) { Clear(); @@ -3055,9 +3007,14 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args) } //--------------------------------------------------------------------------------------------------------------------- -QString MainWindow::CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType) +QString MainWindow::CheckPathToMeasurements(const QString &path) { - QFile table(path); + if (path.isEmpty()) + { + return path; + } + + QFileInfo table(path); if (table.exists() == false) { QString text = tr("The measurements file

%1

%3").arg(path) @@ -3071,18 +3028,38 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Measureme } else { - QString filter; + MeasurementsType patternType; + if (table.suffix() == QLatin1String("vst")) + { + patternType = MeasurementsType::Standard; + } + else if (table.suffix() == QLatin1String("vit")) + { + patternType = MeasurementsType::Individual; + } + else + { + patternType = MeasurementsType::Unknown; + } + QString mPath; if (patternType == MeasurementsType::Standard) { - filter = tr("Standard measurements (*.vst)"); + const QString filter = tr("Standard measurements (*.vst)"); //Use standard path to standard measurements const QString path = qApp->ValentinaSettings()->GetPathStandardMeasurements(); mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); } + else if (patternType == MeasurementsType::Individual) + { + const QString filter = tr("Individual measurements (*.vit)"); + //Use standard path to individual measurements + const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements(); + mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); + } else { - filter = tr("Individual measurements (*.vit)"); + const QString filter = tr("Individual measurements (*.vit);;Standard measurements (*.vst)"); //Use standard path to individual measurements const QString path = qApp->ValentinaSettings()->GetPathIndividualMeasurements(); mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter); @@ -3094,14 +3071,33 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Measureme } else { + VMeasurements *m = new VMeasurements(pattern); + m->setXMLContent(mPath); + + patternType = m->Type(); + + if (patternType == MeasurementsType::Unknown) + { + VException e("Measurement file has unknown format."); + throw e; + } + if (patternType == MeasurementsType::Standard) { - VDomDocument::ValidateXML("://schema/standard_measurements.xsd", mPath); + VVSTConverter converter(mPath); + converter.Convert(); + + VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, mPath); } else { - VDomDocument::ValidateXML("://schema/individual_measurements.xsd", mPath); + VVITConverter converter(mPath); + converter.Convert(); + + VDomDocument::ValidateXML(VVITConverter::CurrentSchema, mPath); } + + delete m; doc->SetPath(mPath); PatternWasModified(false); return mPath; diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index cfa5e4a88..252316b60 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -259,7 +259,7 @@ private: void CreateActions(); void InitAutoSave(); QString PatternPieceName(const QString &text); - QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType); + QString CheckPathToMeasurements(const QString &path); QComboBox *SetGradationList(const QString &label, const QStringList &list); void ChangePP(int index, bool zoomBestFit = true); /** @@ -279,7 +279,7 @@ private: QStringList GetUnlokedRestoreFileList()const; void ToolBarStyle(QToolBar *bar); - void AddPP(const QString &PPName, const QString &path); + void AddPP(const QString &PPName); void InitScenes(); }; diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index d2e7df82e..550c86896 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -2012,6 +2012,15 @@ DEPENDPATH += $$PWD/../../libs/vwidgets win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a +# VFormat static library (depend on VPatternDB, IFC) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat + +INCLUDEPATH += $$PWD/../../libs/vformat +DEPENDPATH += $$PWD/../../libs/vformat + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a + #VPatternDB static library (depend on vgeometry, vmisc, VLayout) unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb diff --git a/src/app/valentina/xml/vindividualmeasurements.cpp b/src/app/valentina/xml/vindividualmeasurements.cpp index edacbcbfa..5ed263098 100644 --- a/src/app/valentina/xml/vindividualmeasurements.cpp +++ b/src/app/valentina/xml/vindividualmeasurements.cpp @@ -112,13 +112,13 @@ void VIndividualMeasurements::setBirthDate(const QDate &date) } //--------------------------------------------------------------------------------------------------------------------- -SexType VIndividualMeasurements::Sex() const +SexType1 VIndividualMeasurements::Sex() const { return StrToGender(UniqueTagText(TagSex, "")); } //--------------------------------------------------------------------------------------------------------------------- -void VIndividualMeasurements::setSex(const SexType &sex) +void VIndividualMeasurements::setSex(const SexType1 &sex) { setTagText(TagSex, GenderToStr(sex)); } @@ -136,13 +136,13 @@ void VIndividualMeasurements::setMail(const QString &text) } //--------------------------------------------------------------------------------------------------------------------- -QString VIndividualMeasurements::GenderToStr(const SexType &sex) +QString VIndividualMeasurements::GenderToStr(const SexType1 &sex) { switch (sex) { - case SexType::Male: + case SexType1::Male: return SexMale; - case SexType::Female: + case SexType1::Female: return SexFemale; default: return SexMale; @@ -150,16 +150,16 @@ QString VIndividualMeasurements::GenderToStr(const SexType &sex) } //--------------------------------------------------------------------------------------------------------------------- -SexType VIndividualMeasurements::StrToGender(const QString &sex) +SexType1 VIndividualMeasurements::StrToGender(const QString &sex) { QStringList genders = QStringList() << SexMale << SexFemale; switch (genders.indexOf(sex)) { case 0: // SexMale - return SexType::Male; + return SexType1::Male; case 1: // SexFemale - return SexType::Female; + return SexType1::Female; default: - return SexType::Male; + return SexType1::Male; } } diff --git a/src/app/valentina/xml/vindividualmeasurements.h b/src/app/valentina/xml/vindividualmeasurements.h index 3b246ca55..e519adbb6 100644 --- a/src/app/valentina/xml/vindividualmeasurements.h +++ b/src/app/valentina/xml/vindividualmeasurements.h @@ -39,7 +39,7 @@ // max support version of format #define VIT_VERSION 0x000200 -enum class SexType : char { Male, Female }; +enum class SexType1 : char { Male, Female }; class VIndividualMeasurements:public VAbstractMeasurements { @@ -54,8 +54,8 @@ public: void setGivenName(const QString &text); QDate BirthDate() const; void setBirthDate(const QDate &date); - SexType Sex() const; - void setSex(const SexType &sex); + SexType1 Sex() const; + void setSex(const SexType1 &sex); QString Mail() const; void setMail(const QString &text); @@ -67,8 +67,8 @@ public: static const QString SexMale; static const QString SexFemale; - static QString GenderToStr(const SexType &sex); - static SexType StrToGender(const QString &sex); + static QString GenderToStr(const SexType1 &sex); + static SexType1 StrToGender(const QString &sex); protected: virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) Q_DECL_OVERRIDE; private: diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 9dd96d265..5afedde32 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -62,14 +62,9 @@ VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, //--------------------------------------------------------------------------------------------------------------------- /** * @brief CreateEmptyFile create minimal empty file. - * @param tablePath path to measurement file (standard or individual) */ -void VPattern::CreateEmptyFile(const QString &tablePath) +void VPattern::CreateEmptyFile() { - if (tablePath.isEmpty()) - { - throw VException("Path to measurement table empty."); - } this->clear(); QDomElement patternElement = this->createElement(TagPattern); @@ -84,12 +79,12 @@ void VPattern::CreateEmptyFile(const QString &tablePath) patternElement.appendChild(createElement(TagDescription)); patternElement.appendChild(createElement(TagNotes)); - QDomElement measurements = createElement(TagMeasurements); - SetAttribute(measurements, AttrUnit, UnitsToStr(qApp->patternUnit())); - SetAttribute(measurements, AttrType, qApp->patternType()); - SetAttribute(measurements, AttrPath, tablePath); - patternElement.appendChild(measurements); + QDomElement unit = createElement(TagUnit); + newNodeText = createTextNode(UnitsToStr(qApp->patternUnit())); + unit.appendChild(newNodeText); + patternElement.appendChild(unit); + patternElement.appendChild(createElement(TagMeasurements)); patternElement.appendChild(createElement(TagIncrements)); this->appendChild(patternElement); @@ -907,7 +902,7 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & } if (parse == Document::FullParse) { - spoint = new VToolBasePoint(this, data, id, Source::FromFile, nameActivPP, MPath()); + spoint = new VToolBasePoint(this, data, id, Source::FromFile, nameActivPP); scene->addItem(spoint); connect(spoint, &VToolBasePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor); @@ -2284,30 +2279,30 @@ void VPattern::PrepareForParse(const Document &parse) //--------------------------------------------------------------------------------------------------------------------- void VPattern::UpdateMeasurements() { - try - { - const QString path = MPath(); - if (MType() == MeasurementsType::Standard) - { - VStandardMeasurements m(data); - ValidateXML("://schema/standard_measurements.xsd", path); - m.setXMLContent(path); - m.Measurements(); - } - else - { - VIndividualMeasurements m(data); - ValidateXML("://schema/individual_measurements.xsd", path); - m.setXMLContent(path); - m.Measurements(); - } - } - catch (VException &e) - { - e.CriticalMessageBox(tr("File error."), qApp->getMainWindow()); - emit ClearMainWindow(); - return; - } +// try +// { +// const QString path = MPath(); +// if (MType() == MeasurementsType::Standard) +// { +// VStandardMeasurements m(data); +// ValidateXML("://schema/standard_measurements.xsd", path); +// m.setXMLContent(path); +// m.Measurements(); +// } +// else +// { +// VIndividualMeasurements m(data); +// ValidateXML("://schema/individual_measurements.xsd", path); +// m.setXMLContent(path); +// m.Measurements(); +// } +// } +// catch (VException &e) +// { +// e.CriticalMessageBox(tr("File error."), qApp->getMainWindow()); +// emit ClearMainWindow(); +// return; +// } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 51de51c1c..304649e0c 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -46,7 +46,7 @@ public: VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent = nullptr); - virtual void CreateEmptyFile(const QString &tablePath) Q_DECL_OVERRIDE; + virtual void CreateEmptyFile() Q_DECL_OVERRIDE; void Parse(const Document &parse); diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 4181d616d..88715edb1 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -51,10 +51,10 @@ const QString VAbstractPattern::TagTools = QStringLiteral("tools"); const QString VAbstractPattern::TagGradation = QStringLiteral("gradation"); const QString VAbstractPattern::TagHeights = QStringLiteral("heights"); const QString VAbstractPattern::TagSizes = QStringLiteral("sizes"); +const QString VAbstractPattern::TagUnit = QStringLiteral("unit"); const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrType = QStringLiteral("type"); -const QString VAbstractPattern::AttrPath = QStringLiteral("path"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); @@ -453,16 +453,7 @@ QVector VAbstractPattern::getLocalHistory() const //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::MPath() const { - QDomNodeList list = elementsByTagName(TagMeasurements); - QDomElement element = list.at(0).toElement(); - if (element.isElement()) - { - return GetParametrString(element, AttrPath); - } - else - { - return QString(); - } + return UniqueTagText(TagUnit); } //--------------------------------------------------------------------------------------------------------------------- @@ -473,11 +464,9 @@ void VAbstractPattern::SetPath(const QString &path) qDebug()<<"Path to measurements is empty"<setPen(QPen(baseColor, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); @@ -111,7 +111,7 @@ void VToolBasePoint::AddToFile() patternPiece.appendChild(doc->createElement(VAbstractPattern::TagModeling)); patternPiece.appendChild(doc->createElement(VAbstractPattern::TagDetails)); - AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP, mPath); + AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP); connect(addPP, &AddPatternPiece::ClearScene, doc, &VAbstractPattern::ClearScene); connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing); qApp->getUndoStack()->push(addPP); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h index 82bbd1f84..87397a524 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h @@ -40,7 +40,7 @@ class VToolBasePoint : public VToolSinglePoint Q_OBJECT public: VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, - const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr ); + const QString &namePP, QGraphicsItem * parent = nullptr ); virtual ~VToolBasePoint() Q_DECL_OVERRIDE; virtual void setDialog() Q_DECL_OVERRIDE; static const QString ToolType; @@ -72,7 +72,6 @@ protected: virtual void SetVisualization() Q_DECL_OVERRIDE {} private: QString namePP; - QString mPath; void SetColorLabel(const Qt::GlobalColor & color); }; diff --git a/src/libs/vtools/undocommands/addpatternpiece.cpp b/src/libs/vtools/undocommands/addpatternpiece.cpp index a65ecfae4..b4453bf34 100644 --- a/src/libs/vtools/undocommands/addpatternpiece.cpp +++ b/src/libs/vtools/undocommands/addpatternpiece.cpp @@ -30,11 +30,10 @@ //--------------------------------------------------------------------------------------------------------------------- AddPatternPiece::AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, - const QString &mPath, QUndoCommand *parent) - : VUndoCommand(xml, doc, parent), namePP(namePP), mPath(mPath) + QUndoCommand *parent) + : VUndoCommand(xml, doc, parent), namePP(namePP) { SCASSERT(namePP.isEmpty() == false); - SCASSERT(mPath.isEmpty() == false); setText(tr("add pattern piece %1").arg(namePP)); } @@ -65,9 +64,9 @@ void AddPatternPiece::redo() { qCDebug(vUndo, "Redo."); - if (doc->CountPP() == 0 && mPath.isEmpty() == false) + if (doc->CountPP() == 0) { - doc->CreateEmptyFile(mPath); + doc->CreateEmptyFile(); } QDomElement rootElement = doc->documentElement(); diff --git a/src/libs/vtools/undocommands/addpatternpiece.h b/src/libs/vtools/undocommands/addpatternpiece.h index d03b3427f..814131425 100644 --- a/src/libs/vtools/undocommands/addpatternpiece.h +++ b/src/libs/vtools/undocommands/addpatternpiece.h @@ -35,15 +35,13 @@ class AddPatternPiece : public VUndoCommand { Q_OBJECT public: - AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, const QString &mPath, - QUndoCommand *parent = 0); + AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, const QString &namePP, QUndoCommand *parent = 0); virtual ~AddPatternPiece() Q_DECL_OVERRIDE; virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(AddPatternPiece) QString namePP; - QString mPath; }; #endif // ADDPATTERNPIECE_H