Create a measurement independent pattern file.
--HG-- branch : feature
This commit is contained in:
parent
8bc20fa82f
commit
8146f53be3
|
@ -35,9 +35,8 @@ VLitePattern::VLitePattern(QObject *parent)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLitePattern::CreateEmptyFile(const QString &tablePath)
|
||||
void VLitePattern::CreateEmptyFile()
|
||||
{
|
||||
Q_UNUSED(tablePath)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -1,268 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogindividualmeasurements.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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 <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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<void (QButtonGroup::*)(int)>(&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."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||
DialogRejected();
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIndividualMeasurements::DialogRejected()
|
||||
{
|
||||
_name.clear();
|
||||
_tablePath.clear();
|
||||
reject();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIndividualMeasurements::CheckState()
|
||||
{
|
||||
bool flagName = false;
|
||||
if (ui->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);
|
||||
}
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogindividualmeasurements.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef DIALOGINDIVIDUALMEASUREMENTS_H
|
||||
#define DIALOGINDIVIDUALMEASUREMENTS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
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
|
|
@ -1,288 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogIndividualMeasurements</class>
|
||||
<widget class="QDialog" name="DialogIndividualMeasurements">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>505</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Individual measurements</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Pattern piece name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonExistM">
|
||||
<property name="text">
|
||||
<string>Exist measurements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupPath</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditPathExistM">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonOpenExist">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Given name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelGivenName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Family name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelFamilyName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButtonNewM">
|
||||
<property name="text">
|
||||
<string>New measurements</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroupPath</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Units:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxUnits"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEditPathNewM">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButtonOpenNew">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogIndividualMeasurements</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogIndividualMeasurements</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroupPath"/>
|
||||
</buttongroups>
|
||||
</ui>
|
|
@ -1,73 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpatterntype.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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();
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpatterntype.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef DIALOGMEASUREMENTS_H
|
||||
#define DIALOGMEASUREMENTS_H
|
||||
|
||||
#include <QDialog>
|
||||
#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
|
|
@ -1,158 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogMeasurements</class>
|
||||
<widget class="QDialog" name="DialogMeasurements">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>448</width>
|
||||
<height>244</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Measurements</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:18pt;">Please, choose pattern type.</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QToolButton" name="toolButtonStandard">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>123</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>123</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Graduation</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/Graduation.png</normaloff>:/icon/Graduation.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use for creation pattern standard measurement table</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QToolButton" name="toolButtonIndividual">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>123</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>166</width>
|
||||
<height>123</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Individual</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/individual.png</normaloff>:/icon/individual.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use for creation pattern individual measurements</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>toolButtonStandard</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
111
src/app/valentina/dialogs/dialognewpattern.cpp
Normal file
111
src/app/valentina/dialogs/dialognewpattern.cpp
Normal file
|
@ -0,0 +1,111 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialognewpattern.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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 <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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();
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogstandardmeasurements.h
|
||||
** @file dialogindividualmeasurements.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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 <QDialog>
|
||||
|
||||
#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
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogStandardMeasurements</class>
|
||||
<widget class="QDialog" name="DialogStandardMeasurements">
|
||||
<class>DialogNewPattern</class>
|
||||
<widget class="QDialog" name="DialogNewPattern">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
|
@ -9,12 +9,12 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>430</width>
|
||||
<width>325</width>
|
||||
<height>113</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Standard table</string>
|
||||
<string>Individual measurements</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
|
@ -28,66 +28,28 @@
|
|||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>206</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pattern piece name</string>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEditName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEditName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Standard measurements table</string>
|
||||
<string>Units:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxTables">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBoxUnits"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
|
@ -102,32 +64,32 @@
|
|||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogStandardMeasurements</receiver>
|
||||
<receiver>DialogNewPattern</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
<x>162</x>
|
||||
<y>90</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
<x>162</x>
|
||||
<y>56</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogStandardMeasurements</receiver>
|
||||
<receiver>DialogNewPattern</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
<x>162</x>
|
||||
<y>90</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
<x>162</x>
|
||||
<y>56</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -1,205 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogstandardmeasurements.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#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 <QDir>
|
||||
#include <QPushButton>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
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."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogStandardMeasurements::DialogRejected()
|
||||
{
|
||||
_name.clear();
|
||||
_tablePath.clear();
|
||||
reject();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogStandardMeasurements::CheckState()
|
||||
{
|
||||
bool flagName = false;
|
||||
if (ui->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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <QInputDialog>
|
||||
#include <QDebug>
|
||||
|
@ -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,77 +2021,27 @@ 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();
|
||||
patternPieceName = newPattern.name();
|
||||
qApp->setPatternUnit(newPattern.PatternUnit());
|
||||
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.");
|
||||
qCDebug(vMainWindow, "Creation a new pattern was canceled.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//Set scene size to size scene view
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
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 <br/><br/> <b>%1</b> <br/><br/> %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;
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
// }
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<VToolRecord> 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"<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
QDomNodeList list = elementsByTagName(TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
|
||||
if (setTagText(TagMeasurements, path))
|
||||
{
|
||||
SetAttribute(element, AttrPath, path);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
|
@ -489,12 +478,8 @@ void VAbstractPattern::SetPath(const QString &path)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit VAbstractPattern::MUnit() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VAbstractPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QStringList units = QStringList() <<"mm" << "cm" << "inch";
|
||||
QString unit = GetParametrString(element, AttrUnit);
|
||||
const QStringList units = QStringList() << "mm" << "cm" << "inch";
|
||||
const QString unit = UniqueTagText(TagUnit);
|
||||
switch (units.indexOf(unit))
|
||||
{
|
||||
case 0:// mm
|
||||
|
@ -510,39 +495,6 @@ Unit VAbstractPattern::MUnit() const
|
|||
return Unit::Cm;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unit::Cm;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementsType VAbstractPattern::MType() const
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(VAbstractPattern::TagMeasurements);
|
||||
QDomElement element = list.at(0).toElement();
|
||||
if (element.isElement())
|
||||
{
|
||||
QString type = GetParametrString(element, AttrType);
|
||||
QStringList types = QStringList() << "standard" << "individual";
|
||||
switch (types.indexOf(type))
|
||||
{
|
||||
case 0:// standard
|
||||
return MeasurementsType::Standard;
|
||||
break;
|
||||
case 1:// individual
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
default:
|
||||
return MeasurementsType::Individual;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return MeasurementsType::Individual;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
QStringList ListMeasurements() const;
|
||||
|
||||
virtual void CreateEmptyFile(const QString &tablePath)=0;
|
||||
virtual void CreateEmptyFile()=0;
|
||||
|
||||
void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse);
|
||||
QString GetNameActivPP() const;
|
||||
|
@ -83,7 +83,6 @@ public:
|
|||
QString MPath() const;
|
||||
void SetPath(const QString &path);
|
||||
Unit MUnit() const;
|
||||
MeasurementsType MType() const;
|
||||
|
||||
quint32 SiblingNodeId(const quint32 &nodeId) const;
|
||||
|
||||
|
@ -123,10 +122,10 @@ public:
|
|||
static const QString TagGradation;
|
||||
static const QString TagHeights;
|
||||
static const QString TagSizes;
|
||||
static const QString TagUnit;
|
||||
|
||||
static const QString AttrName;
|
||||
static const QString AttrType;
|
||||
static const QString AttrPath;
|
||||
|
||||
static const QString AttrAll;
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ void MessageHandler::handleMessage(QtMsgType type, const QString &description, c
|
|||
Q_LOGGING_CATEGORY(vXML, "v.xml")
|
||||
|
||||
const QString VDomDocument::AttrId = QStringLiteral("id");
|
||||
const QString VDomDocument::AttrUnit = QStringLiteral("unit");
|
||||
const QString VDomDocument::UnitMM = QStringLiteral("mm");
|
||||
const QString VDomDocument::UnitCM = QStringLiteral("cm");
|
||||
const QString VDomDocument::UnitINCH = QStringLiteral("inch");
|
||||
|
|
|
@ -70,7 +70,6 @@ class VDomDocument : public QDomDocument
|
|||
Q_DECLARE_TR_FUNCTIONS(VDomDocument)
|
||||
public:
|
||||
static const QString AttrId;
|
||||
static const QString AttrUnit;
|
||||
static const QString UnitMM;
|
||||
static const QString UnitCM;
|
||||
static const QString UnitINCH;
|
||||
|
|
|
@ -48,8 +48,8 @@ const QString VToolBasePoint::ToolType = QStringLiteral("single");
|
|||
* @param parent parent object.
|
||||
*/
|
||||
VToolBasePoint::VToolBasePoint (VAbstractPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
||||
const QString &namePP, const QString &mPath, QGraphicsItem * parent )
|
||||
:VToolSinglePoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
|
||||
const QString &namePP, QGraphicsItem * parent )
|
||||
:VToolSinglePoint(doc, data, id, parent), namePP(namePP)
|
||||
{
|
||||
baseColor = Qt::red;
|
||||
this->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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user