From fb405d5754e3190f3c6e91459fbf3d8921c65e41 Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 11 Dec 2014 17:12:16 +0200 Subject: [PATCH] Move XSD files to library. --HG-- branch : feature --- src/app/app.pro | 1 - src/app/mainwindow.cpp | 3 +- src/libs/ifc/ifc.pro | 4 ++ .../share/resources => libs/ifc}/schema.qrc | 2 +- .../ifc}/schema/individual_measurements.xsd | 0 .../ifc/schema/pattern/v0.1.1.xsd} | 0 .../ifc}/schema/standard_measurements.xsd | 0 src/libs/ifc/xml/vabstractconverter.cpp | 3 +- src/libs/ifc/xml/vabstractconverter.h | 7 +++- src/libs/ifc/xml/vpatternconverter.cpp | 41 ++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.h | 42 +++++++++++++++++++ src/libs/ifc/xml/xml.pri | 6 ++- 12 files changed, 102 insertions(+), 7 deletions(-) rename src/{app/share/resources => libs/ifc}/schema.qrc (78%) rename src/{app/share/resources => libs/ifc}/schema/individual_measurements.xsd (100%) rename src/{app/share/resources/schema/pattern.xsd => libs/ifc/schema/pattern/v0.1.1.xsd} (100%) rename src/{app/share/resources => libs/ifc}/schema/standard_measurements.xsd (100%) create mode 100644 src/libs/ifc/xml/vpatternconverter.cpp create mode 100644 src/libs/ifc/xml/vpatternconverter.h diff --git a/src/app/app.pro b/src/app/app.pro index 08cf66634..1985d19f2 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -51,7 +51,6 @@ RESOURCES += \ share/resources/icon.qrc \ # All other icons except cursors and Windows theme. share/resources/cursor.qrc \ # Tools cursor icons. share/resources/theme.qrc \ # Windows theme icons. - share/resources/schema.qrc \ # Schemas for validation xml files. share/resources/measurements.qrc \ # For measurements files that we save as resource. share/resources/flags.qrc diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 372900df2..4aff0a822 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -44,6 +44,7 @@ #include "undocommands/renamepp.h" #include "vtooloptionspropertybrowser.h" #include "options.h" +#include "../libs/ifc/xml/vpatternconverter.h" #include #include @@ -2350,7 +2351,7 @@ void MainWindow::LoadPattern(const QString &fileName) qApp->setOpeningPattern();//Begin opening file try { - VDomDocument::ValidateXML("://schema/pattern.xsd", fileName); + VDomDocument::ValidateXML(VPatternConverter::CurrentSchema(), fileName); doc->setContent(fileName); qApp->setPatternUnit(doc->MUnit()); diff --git a/src/libs/ifc/ifc.pro b/src/libs/ifc/ifc.pro index 99424515d..411f569c5 100644 --- a/src/libs/ifc/ifc.pro +++ b/src/libs/ifc/ifc.pro @@ -39,6 +39,10 @@ MOC_DIR = moc # objecs files OBJECTS_DIR = obj +# Resource files. This files will be included in binary. +RESOURCES += \ + schema.qrc # Schemas for validation xml files. + # Set using ccache. Function enable_ccache() defined in Valentina.pri. $$enable_ccache() diff --git a/src/app/share/resources/schema.qrc b/src/libs/ifc/schema.qrc similarity index 78% rename from src/app/share/resources/schema.qrc rename to src/libs/ifc/schema.qrc index 9209df5ca..ce37b86bc 100644 --- a/src/app/share/resources/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -1,7 +1,7 @@ - schema/pattern.xsd schema/individual_measurements.xsd schema/standard_measurements.xsd + schema/pattern/v0.1.1.xsd diff --git a/src/app/share/resources/schema/individual_measurements.xsd b/src/libs/ifc/schema/individual_measurements.xsd similarity index 100% rename from src/app/share/resources/schema/individual_measurements.xsd rename to src/libs/ifc/schema/individual_measurements.xsd diff --git a/src/app/share/resources/schema/pattern.xsd b/src/libs/ifc/schema/pattern/v0.1.1.xsd similarity index 100% rename from src/app/share/resources/schema/pattern.xsd rename to src/libs/ifc/schema/pattern/v0.1.1.xsd diff --git a/src/app/share/resources/schema/standard_measurements.xsd b/src/libs/ifc/schema/standard_measurements.xsd similarity index 100% rename from src/app/share/resources/schema/standard_measurements.xsd rename to src/libs/ifc/schema/standard_measurements.xsd diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index 85911600d..cfe0b6a50 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -28,7 +28,8 @@ #include "vabstractconverter.h" - +//--------------------------------------------------------------------------------------------------------------------- VAbstractConverter::VAbstractConverter() + :VDomDocument() { } diff --git a/src/libs/ifc/xml/vabstractconverter.h b/src/libs/ifc/xml/vabstractconverter.h index c62cd9fe4..39f5398f3 100644 --- a/src/libs/ifc/xml/vabstractconverter.h +++ b/src/libs/ifc/xml/vabstractconverter.h @@ -29,12 +29,17 @@ #ifndef VABSTRACTCONVERTER_H #define VABSTRACTCONVERTER_H +#include "vdomdocument.h" -class VAbstractConverter +class VAbstractConverter :public VDomDocument { public: VAbstractConverter(); + virtual ~VAbstractConverter(){} + +private: + Q_DISABLE_COPY(VAbstractConverter) }; #endif // VABSTRACTCONVERTER_H diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp new file mode 100644 index 000000000..7d3ba374b --- /dev/null +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -0,0 +1,41 @@ +/************************************************************************ + ** + ** @file vpatternconverter.cpp + ** @author Roman Telezhynskyi + ** @date 11 12, 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) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vpatternconverter.h" + +//--------------------------------------------------------------------------------------------------------------------- +VPatternConverter::VPatternConverter() + :VAbstractConverter() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPatternConverter::CurrentSchema() +{ + return QStringLiteral("://schema/pattern/v0.1.1.xsd"); +} diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h new file mode 100644 index 000000000..295d10563 --- /dev/null +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -0,0 +1,42 @@ +/************************************************************************ + ** + ** @file vpatternconverter.h + ** @author Roman Telezhynskyi + ** @date 11 12, 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) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VPATTERNCONVERTER_H +#define VPATTERNCONVERTER_H + +#include "vabstractconverter.h" + +class VPatternConverter : public VAbstractConverter +{ +public: + VPatternConverter(); + + static QString CurrentSchema(); +}; + +#endif // VPATTERNCONVERTER_H diff --git a/src/libs/ifc/xml/xml.pri b/src/libs/ifc/xml/xml.pri index 3a23b3a95..c64e090e9 100644 --- a/src/libs/ifc/xml/xml.pri +++ b/src/libs/ifc/xml/xml.pri @@ -3,8 +3,10 @@ HEADERS += \ $$PWD/vabstractconverter.h \ - $$PWD/vdomdocument.h + $$PWD/vdomdocument.h \ + $$PWD/vpatternconverter.h SOURCES += \ $$PWD/vabstractconverter.cpp \ - $$PWD/vdomdocument.cpp + $$PWD/vdomdocument.cpp \ + $$PWD/vpatternconverter.cpp