"Export from existing ..." now supports multisize measurements.

This commit is contained in:
Roman Telezhynskyi 2022-07-01 10:29:03 +03:00
parent 92398bbf52
commit b4462395e1
3 changed files with 24 additions and 27 deletions

View File

@ -8,6 +8,7 @@
- Fix Valentina app crash after canceling a tool.
- Puzzle app. Fix reading a piece name.
- Fix warning while segmenting flipped arc.
- Tape app. "Export from existing ..." now supports multisize measurements.
# Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece.

View File

@ -512,18 +512,10 @@ void TMainWindow::OpenTemplate()
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::CreateFromExisting()
{
const QString filter = tr("Individual measurements") + QStringLiteral(" (*.vit)");
//Use standard path to individual measurements
const QString pathTo = MApplication::VApp()->TapeSettings()->GetPathIndividualMeasurements();
const QString filter = tr("Measurements") + QStringLiteral(" (*.vst *.vit);;") + tr("All files") +
QStringLiteral(" (*.*)");
bool usedNotExistedDir = false;
QDir directory(pathTo);
if (not directory.exists())
{
usedNotExistedDir = directory.mkpath(QChar('.'));
}
const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter, nullptr,
const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), QDir::homePath(), filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
if (not mPath.isEmpty())
@ -537,11 +529,6 @@ void TMainWindow::CreateFromExisting()
MApplication::VApp()->NewMainWindow()->CreateFromExisting();
}
}
if (usedNotExistedDir)
{
QDir(pathTo).rmpath(QChar('.'));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -3679,15 +3666,13 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
throw VException(tr("File has unknown format."));
}
if (mType == MeasurementsType::Multisize)
{
throw VException (tr("Export from multisize measurements is not supported."));
}
QScopedPointer<VAbstractMConverter> converter(
(mType == MeasurementsType::Individual) ? static_cast<VAbstractMConverter*>(new VVITConverter(path))
: static_cast<VAbstractMConverter*>(new VVSTConverter(path)));
VVITConverter converter(path);
m_curFileFormatVersion = converter.GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter.GetFormatVersionStr();
m->setXMLContent(converter.Convert());// Read again after conversion
m_curFileFormatVersion = converter->GetCurrentFormatVersion();
m_curFileFormatVersionStr = converter->GetFormatVersionStr();
m->setXMLContent(converter->Convert());// Read again after conversion
if (not m->IsDefinedKnownNamesValid())
{

View File

@ -459,11 +459,22 @@ void VMeasurements::ClearForExport()
for (int i=0; i < list.size(); ++i)
{
QDomElement domElement = list.at(i).toElement();
if (domElement.isNull() == false)
if (not domElement.isNull())
{
if (qmu::QmuTokenParser::IsSingle(domElement.attribute(AttrValue)))
if (Type() == MeasurementsType::Individual)
{
SetAttribute(domElement, AttrValue, QChar('0'));
if (qmu::QmuTokenParser::IsSingle(domElement.attribute(AttrValue)))
{
SetAttribute(domElement, AttrValue, QChar('0'));
}
}
else if (Type() == MeasurementsType::Multisize)
{
SetAttribute(domElement, AttrBase, QChar('0'));
domElement.removeAttribute(AttrShiftA);
domElement.removeAttribute(AttrShiftB);
domElement.removeAttribute(AttrShiftC);
RemoveAllChildren(domElement);
}
}
}