diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp
index 2010b142e..d5143816d 100644
--- a/src/app/valentina/mainwindow.cpp
+++ b/src/app/valentina/mainwindow.cpp
@@ -319,6 +319,23 @@ void MainWindow::ToggleMSync(bool toggle)
}
}
+//---------------------------------------------------------------------------------------------------------------------
+QString MainWindow::RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const
+{
+ if (patternPath.isEmpty())
+ {
+ return absoluteMPath;
+ }
+
+ if (absoluteMPath.isEmpty())
+ {
+ return absoluteMPath;
+ }
+
+ QDir dir(QFileInfo(patternPath).absoluteDir());
+ return dir.relativeFilePath(absoluteMPath);
+}
+
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief OptionDraw help change name of pattern piece.
@@ -1003,9 +1020,9 @@ void MainWindow::LoadIndividual()
{
if (not doc->MPath().isEmpty())
{
- watcher->removePath(doc->MPath());
+ watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath());
}
- doc->SetPath(mPath);
+ doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath);
PatternWasModified(false);
ui->actionShowM->setEnabled(true);
@@ -1029,9 +1046,9 @@ void MainWindow::LoadStandard()
{
if (not doc->MPath().isEmpty())
{
- watcher->removePath(doc->MPath());
+ watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath());
}
- doc->SetPath(mPath);
+ doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath);
PatternWasModified(false);
ui->actionShowM->setEnabled(true);
@@ -1914,10 +1931,11 @@ void MainWindow::Clear()
ui->actionDraw->setChecked(true);
ui->actionLayout->setEnabled(true);
qCDebug(vMainWindow, "Returned to Draw mode.");
- setCurrentFile(QString());
pattern->Clear();
qCDebug(vMainWindow, "Clearing pattern.");
+ watcher->removePath(QFileInfo(QFileInfo(curFile).absoluteDir(), doc->MPath()).absoluteFilePath());
doc->clear();
+ setCurrentFile(QString());
qCDebug(vMainWindow, "Clearing scenes.");
sceneDraw->clear();
sceneDetails->clear();
@@ -1941,7 +1959,7 @@ void MainWindow::Clear()
ui->actionShowM->setEnabled(false);
SetEnableTool(false);
qApp->setPatternUnit(Unit::Cm);
- qApp->setPatternType(MeasurementsType::Individual);
+ qApp->setPatternType(MeasurementsType::Unknown);
ui->toolBarOption->clear();
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
@@ -2482,6 +2500,13 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error)
{
qCDebug(vMainWindow, "Saving pattern file %s.", fileName.toUtf8().constData());
QFileInfo tempInfo(fileName);
+
+ const QString mPath = doc->MPath();
+ if (not mPath.isEmpty() && curFile != fileName)
+ {
+ doc->SetPath(RelativeMPath(fileName, mPath));
+ }
+
const bool result = doc->SaveDocument(fileName, error);
if (result)
{
@@ -2495,6 +2520,7 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error)
}
else
{
+ doc->SetPath(mPath);
qCDebug(vMainWindow, "Could not save file %s. %s.", fileName.toUtf8().constData(), error.toUtf8().constData());
}
return result;
@@ -3037,33 +3063,30 @@ void MainWindow::LoadPattern(const QString &fileName)
qApp->setPatternUnit(doc->MUnit());
QString path = doc->MPath();
- path = CheckPathToMeasurements(path);
- if (path.isEmpty())
+ if (not path.isEmpty())
{
- Clear();
- return;
- }
-
- if (qApp->patternType() == MeasurementsType::Standard)
- {
- VStandardMeasurements m(pattern);
- VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, path);
- m.setXMLContent(path);
- if (m.MUnit() == Unit::Inch)
+ //Search absolute path
+ path = QFileInfo(QFileInfo(fileName).absoluteDir(), path).absoluteFilePath();
+ // Check if exist
+ path = CheckPathToMeasurements(fileName, path);
+ if (path.isEmpty())
{
- QMessageBox::critical(this, tr("Wrong units."),
- tr("Application doesn't support standard table with inches."));
- qCDebug(vMainWindow, "Application doesn't support standard table with inches.");
Clear();
return;
}
- m.SetSize();
- m.SetHeight();
- }
- else
- {
- VDomDocument::ValidateXML(VVITConverter::CurrentSchema, path);
+
+ if (not LoadMeasurements(path))
+ {
+ Clear();
+ return;
+ }
+ else
+ {
+ watcher->addPath(path);
+ ui->actionShowM->setEnabled(true);
+ }
}
+
ToolBarOption();
}
catch (VException &e)
@@ -3236,7 +3259,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
}
//---------------------------------------------------------------------------------------------------------------------
-QString MainWindow::CheckPathToMeasurements(const QString &path)
+QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QString &path)
{
if (path.isEmpty())
{
@@ -3334,8 +3357,9 @@ QString MainWindow::CheckPathToMeasurements(const QString &path)
throw e;
}
- doc->SetPath(mPath);
+ doc->SetPath(RelativeMPath(patternPath, mPath));
PatternWasModified(false);
+ qApp->setPatternType(patternType);
return mPath;
}
}
diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h
index 971f35ea0..4da273ad6 100644
--- a/src/app/valentina/mainwindow.h
+++ b/src/app/valentina/mainwindow.h
@@ -271,7 +271,7 @@ private:
void CreateActions();
void InitAutoSave();
QString PatternPieceName(const QString &text);
- QString CheckPathToMeasurements(const QString &path);
+ QString CheckPathToMeasurements(const QString &patternPath, const QString &path);
QComboBox *SetGradationList(const QString &label, const QStringList &list);
void ChangePP(int index, bool zoomBestFit = true);
/**
@@ -298,6 +298,8 @@ private:
bool LoadMeasurements(const QString &path);
void ToggleMSync(bool toggle);
+
+ QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath) const;
};
#endif // MAINWINDOW_H
diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc
index de07f5252..9e30ee05b 100644
--- a/src/libs/ifc/schema.qrc
+++ b/src/libs/ifc/schema.qrc
@@ -5,8 +5,9 @@
schema/pattern/v0.1.2.xsd
schema/pattern/v0.1.3.xsd
schema/pattern/v0.1.4.xsd
+ schema/pattern/v0.2.0.xsd
schema/standard_measurements/v0.3.0.xsd
- schema/standard_measurements/v0.4.0.xsd
+ schema/standard_measurements/v0.4.0.xsd
schema/individual_measurements/v0.2.0.xsd
schema/individual_measurements/v0.3.0.xsd
diff --git a/src/libs/ifc/schema/pattern/v0.2.0.xsd b/src/libs/ifc/schema/pattern/v0.2.0.xsd
new file mode 100644
index 000000000..d6686e302
--- /dev/null
+++ b/src/libs/ifc/schema/pattern/v0.2.0.xsd
@@ -0,0 +1,325 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp
index 028b1ae8a..9b2bf8389 100644
--- a/src/libs/ifc/xml/vpatternconverter.cpp
+++ b/src/libs/ifc/xml/vpatternconverter.cpp
@@ -40,8 +40,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
-const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.4");
-const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.4.xsd");
+const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.0");
+const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.0.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@@ -95,6 +95,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000103):
return QStringLiteral("://schema/pattern/v0.1.3.xsd");
case (0x000104):
+ return QStringLiteral("://schema/pattern/v0.1.4.xsd");
+ case (0x000200):
return CurrentSchema;
default:
{
@@ -152,6 +154,16 @@ void VPatternConverter::ApplyPatches()
#endif
}
case (0x000104):
+ {
+ ToV0_2_0();
+ const QString schema = XSDSchema(0x000200);
+ ValidateXML(schema, fileName);
+ // continue conversion
+ #ifdef Q_CC_CLANG
+ [[clang::fallthrough]];
+ #endif
+ }
+ case (0x000200):
break;
default:
break;
@@ -203,3 +215,10 @@ void VPatternConverter::ToV0_1_4()
SetVersion(QStringLiteral("0.1.4"));
Save();
}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VPatternConverter::ToV0_2_0()
+{
+ SetVersion(QStringLiteral("0.2.0"));
+ Save();
+}
diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h
index 2f747f0da..a8badd867 100644
--- a/src/libs/ifc/xml/vpatternconverter.h
+++ b/src/libs/ifc/xml/vpatternconverter.h
@@ -59,6 +59,7 @@ private:
void ToV0_1_2();
void ToV0_1_3();
void ToV0_1_4();
+ void ToV0_2_0();
};
#endif // VPATTERNCONVERTER_H