Merge with feature
--HG-- branch : develop
This commit is contained in:
commit
7738b974fc
|
@ -10,11 +10,13 @@ TEMPLATE = app
|
|||
DEPENDPATH += \
|
||||
../src/app \
|
||||
../src/libs/qmuparser \
|
||||
../src/libs/vpropertyexplorer
|
||||
../src/libs/vpropertyexplorer \
|
||||
../src/libs/ifc
|
||||
|
||||
include(../src/app/app.pri)
|
||||
include(../src/libs/qmuparser/qmuparser.pri)
|
||||
include(../src/libs/vpropertyexplorer/vpropertyexplorer.pri)
|
||||
include(../src/libs/ifc/ifc.pri)
|
||||
|
||||
# Add here path to new translation file with name "valentina_*_*.ts" if you want to add new language.
|
||||
# Same paths in variable INSTALL_TRANSLATIONS (app.pro).
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Suport subdirectories. Just better project code tree.
|
||||
include(container/container.pri)
|
||||
include(dialogs/dialogs.pri)
|
||||
include(exception/exception.pri)
|
||||
include(geometry/geometry.pri)
|
||||
include(tools/tools.pri)
|
||||
include(widgets/widgets.pri)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -346,6 +345,14 @@ else:unix: LIBS += -L$${OUT_PWD}/../libs/vpropertyexplorer/$${DESTDIR} -lvproper
|
|||
INCLUDEPATH += $${PWD}/../libs/vpropertyexplorer
|
||||
DEPENDPATH += $${PWD}/../libs/vpropertyexplorer
|
||||
|
||||
# IFC static library
|
||||
unix|win32: LIBS += -L$$OUT_PWD/../libs/ifc/$${DESTDIR}/ -lifc
|
||||
|
||||
INCLUDEPATH += $$PWD/../libs/ifc
|
||||
DEPENDPATH += $$PWD/../libs/ifc
|
||||
|
||||
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/ifc.lib
|
||||
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/ifc/$${DESTDIR}/libifc.a
|
||||
|
||||
# Strip after you link all libaries.
|
||||
CONFIG(release, debug|release){
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "variables.h"
|
||||
#include "../geometry/vdetail.h"
|
||||
#include "../geometry/vgobject.h"
|
||||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../libs/ifc/exception/vexceptionbadid.h"
|
||||
#include "../geometry/vabstractcurve.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vapplication.h"
|
||||
#include "../exception/vexceptionobjecterror.h"
|
||||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../exception/vexceptionconversionerror.h"
|
||||
#include "../exception/vexceptionemptyparameter.h"
|
||||
#include "../exception/vexceptionwrongid.h"
|
||||
#include "../libs/ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../libs/ifc/exception/vexceptionbadid.h"
|
||||
#include "../libs/ifc/exception/vexceptionconversionerror.h"
|
||||
#include "../libs/ifc/exception/vexceptionemptyparameter.h"
|
||||
#include "../libs/ifc/exception/vexceptionwrongid.h"
|
||||
#include "vmaingraphicsview.h"
|
||||
#include "../container/calculator.h"
|
||||
#include "../version.h"
|
||||
|
@ -2039,53 +2039,6 @@ QString VApplication::STDescription(const QString &id) const
|
|||
return QString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::SafeCopy(const QString &source, const QString &destination, QString &error)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
||||
QFile patternFile(destination);
|
||||
patternFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
|
||||
// We need here temporary file because we want restore document after error of copying temp file.
|
||||
QTemporaryFile tempOfPattern;
|
||||
if (tempOfPattern.open())
|
||||
{
|
||||
if (patternFile.exists())
|
||||
{
|
||||
patternFile.copy(tempOfPattern.fileName());
|
||||
}
|
||||
}
|
||||
if ( patternFile.exists() == false || patternFile.remove() )
|
||||
{
|
||||
QFile sourceFile(source);
|
||||
if ( sourceFile.copy(patternFile.fileName()) == false )
|
||||
{
|
||||
error = tr("Could not copy temp file to document file");
|
||||
tempOfPattern.copy(destination);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = tr("Could not remove document file");
|
||||
result = false;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup--; // turn off check permission again
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VApplication::StartLogging()
|
||||
{
|
||||
|
|
|
@ -106,7 +106,6 @@ public:
|
|||
|
||||
static QStringList LabelLanguages();
|
||||
QString STDescription(const QString &id)const;
|
||||
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
||||
|
||||
void StartLogging();
|
||||
QTextStream *LogFile();
|
||||
|
|
|
@ -64,7 +64,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
||||
m = new VIndividualMeasurements(data);
|
||||
m->setContent(filePath);
|
||||
m->setXMLContent(filePath);
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ void DialogIncrements::OpenTable()
|
|||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
||||
|
||||
m1 = new VIndividualMeasurements(data);
|
||||
m1->setContent(filePath);
|
||||
m1->setXMLContent(filePath);
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ void DialogIncrements::OpenTable()
|
|||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
|
||||
|
||||
m1 = new VStandardMeasurements(data);
|
||||
m1->setContent(filePath);
|
||||
m1->setXMLContent(filePath);
|
||||
Unit mUnit = m1->MUnit();
|
||||
if (qApp->patternUnit() != mUnit)
|
||||
{
|
||||
|
|
|
@ -111,7 +111,7 @@ void DialogIndividualMeasurements::DialogAccepted()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath);
|
||||
VIndividualMeasurements m(data);
|
||||
m.setContent(_tablePath);
|
||||
m.setXMLContent(_tablePath);
|
||||
const qint32 index = ui->comboBoxUnits->currentIndex();
|
||||
Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString());
|
||||
m.setUnit(unit);
|
||||
|
@ -215,7 +215,7 @@ void DialogIndividualMeasurements::OpenTable()
|
|||
fileName.clear();
|
||||
}
|
||||
VIndividualMeasurements m(data);
|
||||
m.setContent(fileName);
|
||||
m.setXMLContent(fileName);
|
||||
ui->labelGivenName->setText(m.GivenName());
|
||||
ui->labelFamilyName->setText(m.FamilyName());
|
||||
ui->lineEditPathExistM->setText(fileName);
|
||||
|
|
|
@ -99,7 +99,7 @@ void DialogStandardMeasurements::DialogAccepted()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath);
|
||||
VStandardMeasurements m(data);
|
||||
m.setContent(_tablePath);
|
||||
m.setXMLContent(_tablePath);
|
||||
qApp->setPatternUnit(m.MUnit());
|
||||
}
|
||||
catch (VException &e)
|
||||
|
@ -170,7 +170,7 @@ void DialogStandardMeasurements::LoadStandardTables()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", fi.absoluteFilePath());
|
||||
VStandardMeasurements m(data);
|
||||
m.setContent(fi.absoluteFilePath());
|
||||
m.setXMLContent(fi.absoluteFilePath());
|
||||
if (m.MUnit() == Unit::Inch)
|
||||
{
|
||||
qCWarning(vStMeasur)<<"We do not support inches for standard table. Ignore table"
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "dialogundo.h"
|
||||
#include "ui_dialogundo.h"
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../exception/vexceptionundo.h"
|
||||
#include "../../libs/ifc/exception/vexceptionundo.h"
|
||||
#include <QCloseEvent>
|
||||
#include <QUndoStack>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "../../geometry/vpointf.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
#include "../../xml/vdomdocument.h"
|
||||
#include "../../libs/ifc/xml/vdomdocument.h"
|
||||
#include "../../visualization/vistoolarc.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "../../geometry/vpointf.h"
|
||||
#include "../../geometry/vsplinepath.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
#include "../../xml/vdomdocument.h"
|
||||
#include "../../libs/ifc/xml/vdomdocument.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "../../../libs/qmuparser/qmuparsererror.h"
|
||||
#include "../../core/vapplication.h"
|
||||
#include "../../core/vsettings.h"
|
||||
#include "../../xml/vdomdocument.h"
|
||||
#include "../../libs/ifc/xml/vdomdocument.h"
|
||||
#include <QTimer>
|
||||
#include <QCloseEvent>
|
||||
#include <QShowEvent>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "vsplinepath.h"
|
||||
#include "vsplinepath_p.h"
|
||||
#include "../exception/vexception.h"
|
||||
#include "../libs/ifc/exception/vexception.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "undocommands/renamepp.h"
|
||||
#include "vtooloptionspropertybrowser.h"
|
||||
#include "options.h"
|
||||
#include "../libs/ifc/xml/vpatternconverter.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QDebug>
|
||||
|
@ -166,7 +167,7 @@ void MainWindow::ActionNewPP()
|
|||
path = stMeasurements.tablePath();
|
||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||
VStandardMeasurements m(pattern);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.SetSize();
|
||||
m.SetHeight();
|
||||
m.Measurements();
|
||||
|
@ -200,7 +201,7 @@ void MainWindow::ActionNewPP()
|
|||
path = indMeasurements.tablePath();
|
||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||
VIndividualMeasurements m(pattern);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
else
|
||||
|
@ -2350,8 +2351,11 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
qApp->setOpeningPattern();//Begin opening file
|
||||
try
|
||||
{
|
||||
VDomDocument::ValidateXML("://schema/pattern.xsd", fileName);
|
||||
doc->setContent(fileName);
|
||||
VPatternConverter converter(fileName);
|
||||
converter.Convert();
|
||||
|
||||
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema, fileName);
|
||||
doc->setXMLContent(fileName);
|
||||
|
||||
qApp->setPatternUnit(doc->MUnit());
|
||||
qApp->setPatternType(doc->MType());
|
||||
|
@ -2368,7 +2372,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
{
|
||||
VStandardMeasurements m(pattern);
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
if (m.MUnit() == Unit::Inch)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Wrong units."),
|
||||
|
@ -2483,7 +2487,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
|
|||
for (int i = 0; i < restoreFiles.size(); ++i)
|
||||
{
|
||||
QString error;
|
||||
if (VApplication::SafeCopy(restoreFiles.at(i) +".autosave", restoreFiles.at(i), error))
|
||||
if (VDomDocument::SafeCopy(restoreFiles.at(i) +".autosave", restoreFiles.at(i), error))
|
||||
{
|
||||
QFile autoFile(restoreFiles.at(i) +".autosave");
|
||||
autoFile.remove();
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#ifndef OPTIONS_H
|
||||
#define OPTIONS_H
|
||||
|
||||
#include <csignal>
|
||||
#include <QtGlobal>
|
||||
#include "../libs/ifc/ifcdef.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
# if defined( Q_CC_MSVC ) // MSVC USED
|
||||
|
@ -46,12 +46,8 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
|||
class QString;
|
||||
class QStringList;
|
||||
|
||||
static const quint32 null_id = 0;
|
||||
|
||||
#define SceneSize 50000
|
||||
#define DefPointRadius 2.0//mm
|
||||
#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
|
||||
#define NULL_ID_STR "0"
|
||||
|
||||
extern const QString nameRegExp;
|
||||
extern const QString degreeSymbol;
|
||||
|
@ -122,8 +118,6 @@ enum class Vis : unsigned char
|
|||
|
||||
enum class Source : char { FromGui, FromFile, FromTool };
|
||||
enum class Draw : char { Calculation, Modeling };
|
||||
enum class Unit : char { Mm, Cm, Inch };
|
||||
enum class MeasurementsType : char { Standard, Individual };
|
||||
enum class NodeDetail : char { Contour, Modeling };
|
||||
enum class Contour : char { OpenContour, CloseContour };
|
||||
enum class EquidistantType : char { OpenEquidistant, CloseEquidistant };
|
||||
|
@ -324,76 +318,4 @@ extern const QString cm_Oprt;
|
|||
extern const QString mm_Oprt;
|
||||
extern const QString in_Oprt;
|
||||
|
||||
/*
|
||||
* This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow
|
||||
* you to continue afterwards should you choose to.
|
||||
* idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148
|
||||
* Usefull links:
|
||||
* 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? -
|
||||
* https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func
|
||||
*
|
||||
* 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx
|
||||
*
|
||||
* 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx
|
||||
*
|
||||
* 4. Continue to debug after failed assertion on Linux? [C/C++] -
|
||||
* https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c
|
||||
*/
|
||||
#ifndef QT_NO_DEBUG
|
||||
#ifdef Q_OS_WIN32
|
||||
#ifdef Q_CC_MSVC
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __FUNCSIG__, __FILE__, __LINE__); \
|
||||
DebugBreak(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\
|
||||
DebugBreak(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#endif /*Q_CC_MSVC*/
|
||||
#else
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\
|
||||
std::raise(SIGTRAP); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#endif /* Q_OS_WIN32 */
|
||||
#else // define but disable this function if debugging is not set
|
||||
#define SCASSERT(cond) qt_noop();
|
||||
#endif /* QT_NO_DEBUG */
|
||||
|
||||
// Detect whether the compiler supports C++11 noexcept exception specifications.
|
||||
# if defined(__clang__)
|
||||
# if __has_feature(cxx_noexcept)
|
||||
# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
|
||||
# endif
|
||||
# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114
|
||||
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x)
|
||||
# else
|
||||
# define V_NOEXCEPT_EXPR(x)
|
||||
# endif
|
||||
|
||||
#endif // OPTIONS_H
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "../container/calculator.h"
|
||||
#include "../../undocommands/addtocalc.h"
|
||||
#include "../../undocommands/savetooloptions.h"
|
||||
#include "../../exception/vexceptionundo.h"
|
||||
#include "../../libs/ifc/exception/vexceptionundo.h"
|
||||
|
||||
qreal VDrawTool::factor = 1;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "../../container/calculator.h"
|
||||
#include "../../dialogs/tools/dialogalongline.h"
|
||||
#include "../../geometry/vpointf.h"
|
||||
#include "../../exception/vexceptionobjecterror.h"
|
||||
#include "../../libs/ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../../visualization/vistoolalongline.h"
|
||||
|
||||
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
|
||||
|
|
|
@ -33,7 +33,7 @@ const QString VAbstractMeasurements::AttrValue = QStringLiteral("value");
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractMeasurements::VAbstractMeasurements(VContainer *data)
|
||||
:VDomDocument(data)
|
||||
:VDomDocument(), data(data)
|
||||
{
|
||||
SCASSERT(data != nullptr)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#ifndef VABSTRACTMEASUREMENTS_H
|
||||
#define VABSTRACTMEASUREMENTS_H
|
||||
|
||||
#include "vdomdocument.h"
|
||||
#include "../libs/ifc/xml/vdomdocument.h"
|
||||
#include "../container/vcontainer.h"
|
||||
|
||||
class VAbstractMeasurements : public VDomDocument
|
||||
{
|
||||
|
@ -42,6 +43,9 @@ public:
|
|||
static const QString AttrValue;
|
||||
static qreal UnitConvertor(qreal value, const Unit &from, const Unit &to);
|
||||
protected:
|
||||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
|
||||
void Measurement(const QString &tag);
|
||||
virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) = 0;
|
||||
private:
|
||||
|
|
|
@ -32,11 +32,12 @@
|
|||
#include "../tools/vtooluniondetails.h"
|
||||
#include "../tools/drawTools/drawtools.h"
|
||||
#include "../tools/nodeDetails/nodedetails.h"
|
||||
#include "../exception/vexceptionobjecterror.h"
|
||||
#include "../exception/vexceptionwrongid.h"
|
||||
#include "../exception/vexceptionconversionerror.h"
|
||||
#include "../exception/vexceptionemptyparameter.h"
|
||||
#include "../exception/vexceptionundo.h"
|
||||
#include "../libs/ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../libs/ifc/exception/vexceptionwrongid.h"
|
||||
#include "../libs/ifc/exception/vexceptionconversionerror.h"
|
||||
#include "../libs/ifc/exception/vexceptionemptyparameter.h"
|
||||
#include "../libs/ifc/exception/vexceptionundo.h"
|
||||
#include "../libs/ifc/xml/vpatternconverter.h"
|
||||
#include "../core/undoevent.h"
|
||||
#include "../core/vsettings.h"
|
||||
#include "vstandardmeasurements.h"
|
||||
|
@ -121,7 +122,7 @@ const QString VPattern::IncrementDescription = QStringLiteral("description");
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
||||
VMainGraphicsScene *sceneDetail, QObject *parent)
|
||||
: QObject(parent), VDomDocument(data), nameActivPP(QString()), tools(QHash<quint32, VDataTool*>()),
|
||||
: QObject(parent), VDomDocument(), data(data), nameActivPP(QString()), tools(QHash<quint32, VDataTool*>()),
|
||||
history(QVector<VToolRecord>()), cursor(0), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw),
|
||||
sceneDetail(sceneDetail)
|
||||
{
|
||||
|
@ -146,7 +147,7 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
|
|||
patternElement.appendChild(createComment("Valentina pattern format."));
|
||||
|
||||
QDomElement version = createElement(TagVersion);
|
||||
QDomText newNodeText = createTextNode(VAL_STR_VERSION);
|
||||
QDomText newNodeText = createTextNode(VPatternConverter::PatternMaxVerStr);
|
||||
version.appendChild(newNodeText);
|
||||
patternElement.appendChild(version);
|
||||
|
||||
|
@ -2431,13 +2432,13 @@ void VPattern::SetNotes(const QString &text)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPattern::GetVersion() const
|
||||
{
|
||||
return UniqueTagText(TagVersion, VAL_STR_VERSION);
|
||||
return UniqueTagText(TagVersion, VPatternConverter::PatternMaxVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetVersion()
|
||||
{
|
||||
setTagText(TagVersion, VAL_STR_VERSION);
|
||||
setTagText(TagVersion, VPatternConverter::PatternMaxVerStr);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
|
||||
|
@ -2572,14 +2573,14 @@ void VPattern::UpdateMeasurements()
|
|||
{
|
||||
VStandardMeasurements m(data);
|
||||
ValidateXML("://schema/standard_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
else
|
||||
{
|
||||
VIndividualMeasurements m(data);
|
||||
ValidateXML("://schema/individual_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,9 @@
|
|||
#ifndef VPATTERN_H
|
||||
#define VPATTERN_H
|
||||
|
||||
#include "vdomdocument.h"
|
||||
#include "../libs/ifc/xml/vdomdocument.h"
|
||||
#include "vtoolrecord.h"
|
||||
#include "../container/vcontainer.h"
|
||||
|
||||
class VDataTool;
|
||||
class VMainGraphicsScene;
|
||||
|
@ -38,16 +39,6 @@ class VMainGraphicsScene;
|
|||
enum class Document : char { LiteParse, LitePPParse, FullParse };
|
||||
enum class LabelType : char {NewPatternPiece, NewLabel};
|
||||
|
||||
/*
|
||||
VAL_VERSION is (major << 16) + (minor << 8) + patch.
|
||||
*/
|
||||
// version without patch part
|
||||
#define VAL_MIN_VERSION 0x000100
|
||||
// max support version of format
|
||||
#define VAL_VERSION 0x000101
|
||||
|
||||
#define VAL_STR_VERSION "0.1.1"
|
||||
|
||||
/**
|
||||
* @brief The VPattern class working with pattern file.
|
||||
*/
|
||||
|
@ -233,6 +224,9 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VPattern)
|
||||
|
||||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
|
||||
/** @brief nameActivDraw name current pattern peace. */
|
||||
QString nameActivPP;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
HEADERS += \
|
||||
$$PWD/vtoolrecord.h \
|
||||
$$PWD/vdomdocument.h \
|
||||
$$PWD/vpattern.h \
|
||||
$$PWD/vstandardmeasurements.h \
|
||||
$$PWD/vindividualmeasurements.h \
|
||||
|
@ -11,7 +10,6 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/vtoolrecord.cpp \
|
||||
$$PWD/vdomdocument.cpp \
|
||||
$$PWD/vpattern.cpp \
|
||||
$$PWD/vstandardmeasurements.cpp \
|
||||
$$PWD/vindividualmeasurements.cpp \
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <QMessageBox>
|
||||
#include <QSpacerItem>
|
||||
#include <QApplication>
|
||||
#include "../options.h"
|
||||
#include <QLoggingCategory>
|
||||
|
||||
Q_LOGGING_CATEGORY(vExcep, "v.excep")
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
#include <QException>
|
||||
#include <QString>
|
||||
#include <QCoreApplication>
|
||||
#include "../options.h"
|
||||
#include "ifcdef.h"
|
||||
|
||||
class QWidget;
|
||||
|
|
@ -27,7 +27,6 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vexceptionbadid.h"
|
||||
#include "../options.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
13
src/libs/ifc/ifc.pri
Normal file
13
src/libs/ifc/ifc.pri
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Suport subdirectories. Just better project code tree.
|
||||
include(exception/exception.pri)
|
||||
include(xml/xml.pri)
|
||||
|
||||
# ADD TO EACH PATH $$PWD VARIABLE!!!!!!
|
||||
# This need for corect working file translations.pro
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/stable.h \
|
||||
$$PWD/ifcdef.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/stable.cpp
|
88
src/libs/ifc/ifc.pro
Normal file
88
src/libs/ifc/ifc.pro
Normal file
|
@ -0,0 +1,88 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-12-10T17:53:37
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
# File with common stuff for whole project
|
||||
include(../../../Valentina.pri)
|
||||
|
||||
# Library work with xml.
|
||||
QT += xml xmlpatterns printsupport
|
||||
|
||||
# We don't need gui library.
|
||||
QT -= gui
|
||||
|
||||
# Name of library
|
||||
TARGET = ifc # Internal Format Converter
|
||||
|
||||
# We want create library
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += \
|
||||
staticlib \# Making static library
|
||||
c++11 # We use C++11 standard
|
||||
|
||||
# Use out-of-source builds (shadow builds)
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
|
||||
include(ifc.pri)
|
||||
|
||||
# This is static library so no need in "make install"
|
||||
|
||||
# directory for executable file
|
||||
DESTDIR = bin
|
||||
|
||||
# files created moc
|
||||
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()
|
||||
|
||||
# Set precompiled headers. Function set_PCH() defined in Valentina.pri.
|
||||
$$set_PCH()
|
||||
|
||||
CONFIG(debug, debug|release){
|
||||
# Debug mode
|
||||
unix {
|
||||
#Turn on compilers warnings.
|
||||
*-g++{
|
||||
QMAKE_CXXFLAGS += \
|
||||
# Key -isystem disable checking errors in system headers.
|
||||
-isystem "$${OUT_PWD}/$${MOC_DIR}" \
|
||||
$$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||
}
|
||||
clang*{
|
||||
QMAKE_CXXFLAGS += \
|
||||
# Key -isystem disable checking errors in system headers.
|
||||
-isystem "$${OUT_PWD}/$${MOC_DIR}" \
|
||||
$$CLANG_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||
}
|
||||
} else {
|
||||
*-g++{
|
||||
QMAKE_CXXFLAGS += $$GCC_DEBUG_CXXFLAGS # See Valentina.pri for more details.
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
# Release mode
|
||||
|
||||
!unix:*-g++{
|
||||
QMAKE_CXXFLAGS += -fno-omit-frame-pointer # Need for exchndl.dll
|
||||
}
|
||||
|
||||
!macx:!win32-msvc*{
|
||||
# Turn on debug symbols in release mode on Unix systems.
|
||||
# On Mac OS X temporarily disabled. TODO: find way how to strip binary file.
|
||||
QMAKE_CXXFLAGS_RELEASE += -g -gdwarf-3
|
||||
QMAKE_CFLAGS_RELEASE += -g -gdwarf-3
|
||||
QMAKE_LFLAGS_RELEASE =
|
||||
}
|
||||
}
|
114
src/libs/ifc/ifcdef.h
Normal file
114
src/libs/ifc/ifcdef.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file ifcdef.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 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
|
||||
** <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 IFCDEF_H
|
||||
#define IFCDEF_H
|
||||
|
||||
#include <csignal>
|
||||
|
||||
enum class Unit : char { Mm, Cm, Inch };
|
||||
enum class MeasurementsType : char { Standard, Individual };
|
||||
|
||||
static const quint32 null_id = 0;
|
||||
|
||||
#define NULL_ID null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
|
||||
#define NULL_ID_STR "0"
|
||||
|
||||
/*
|
||||
* This macros SCASSERT (for Stop and Continue Assert) will break into the debugger on the line of the assert and allow
|
||||
* you to continue afterwards should you choose to.
|
||||
* idea: Q_ASSERT no longer pauses debugger - http://qt-project.org/forums/viewthread/13148
|
||||
* Usefull links:
|
||||
* 1. What's the difference between __PRETTY_FUNCTION__, __FUNCTION__, __func__? -
|
||||
* https://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func
|
||||
*
|
||||
* 2. Windows Predefined Macros - http://msdn.microsoft.com/library/b0084kay.aspx
|
||||
*
|
||||
* 3. Windows DebugBreak function - http://msdn.microsoft.com/en-us/library/ms679297%28VS.85%29.aspx
|
||||
*
|
||||
* 4. Continue to debug after failed assertion on Linux? [C/C++] -
|
||||
* https://stackoverflow.com/questions/1721543/continue-to-debug-after-failed-assertion-on-linux-c-c
|
||||
*/
|
||||
#ifndef QT_NO_DEBUG
|
||||
#ifdef Q_OS_WIN32
|
||||
#ifdef Q_CC_MSVC
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __FUNCSIG__, __FILE__, __LINE__); \
|
||||
DebugBreak(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\
|
||||
DebugBreak(); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#endif /*Q_CC_MSVC*/
|
||||
#else
|
||||
#define SCASSERT(cond) \
|
||||
{ \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
qDebug("ASSERT: %s in %s (%s:%u)", \
|
||||
#cond, __PRETTY_FUNCTION__, __FILE__, __LINE__);\
|
||||
std::raise(SIGTRAP); \
|
||||
} \
|
||||
} \
|
||||
|
||||
#endif /* Q_OS_WIN32 */
|
||||
#else // define but disable this function if debugging is not set
|
||||
#define SCASSERT(cond) qt_noop();
|
||||
#endif /* QT_NO_DEBUG */
|
||||
|
||||
// Detect whether the compiler supports C++11 noexcept exception specifications.
|
||||
# if defined(__clang__)
|
||||
# if __has_feature(cxx_noexcept)
|
||||
# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept
|
||||
# endif
|
||||
# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114
|
||||
# define QMUP_NOEXCEPT_EXPR(x) noexcept(x)
|
||||
# else
|
||||
# define V_NOEXCEPT_EXPR(x)
|
||||
# endif
|
||||
|
||||
#endif // IFCDEF_H
|
|
@ -1,7 +1,7 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>schema/pattern.xsd</file>
|
||||
<file>schema/individual_measurements.xsd</file>
|
||||
<file>schema/standard_measurements.xsd</file>
|
||||
<file>schema/pattern/v0.1.1.xsd</file>
|
||||
</qresource>
|
||||
</RCC>
|
30
src/libs/ifc/stable.cpp
Normal file
30
src/libs/ifc/stable.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file stable.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 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) 2013 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/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
// Build the precompiled headers.
|
||||
#include "stable.h"
|
67
src/libs/ifc/stable.h
Normal file
67
src/libs/ifc/stable.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file stable.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 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) 2013 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 STABLE_H
|
||||
#define STABLE_H
|
||||
|
||||
/* I like to include this pragma too, so the build log indicates if pre-compiled headers were in use. */
|
||||
#ifndef __clang__
|
||||
#pragma message("Compiling precompiled headers for IFC library.\n")
|
||||
#endif
|
||||
|
||||
/* Add C includes here */
|
||||
|
||||
#if defined __cplusplus
|
||||
/* Add C++ includes here */
|
||||
|
||||
#ifdef QT_CORE_LIB
|
||||
#include <QtCore>
|
||||
#endif
|
||||
|
||||
#ifdef QT_XML_LIB
|
||||
# include <QtXml>
|
||||
#endif
|
||||
|
||||
//In Windows you can't use those headers in all modes.
|
||||
#if !defined(Q_OS_WIN)
|
||||
# ifdef QT_PRINTSUPPORT_LIB
|
||||
# include <QtPrintSupport>
|
||||
# endif
|
||||
|
||||
# ifdef QT_XMLPATTERNS_LIB
|
||||
# include <QtXmlPatterns>
|
||||
# endif
|
||||
|
||||
# ifdef QT_NETWORK_LIB
|
||||
# include <QtNetwork>
|
||||
# endif
|
||||
#endif/*Q_OS_WIN*/
|
||||
|
||||
#endif/*__cplusplus*/
|
||||
|
||||
#endif // STABLE_H
|
160
src/libs/ifc/xml/vabstractconverter.cpp
Normal file
160
src/libs/ifc/xml/vabstractconverter.cpp
Normal file
|
@ -0,0 +1,160 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractconverter.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 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
|
||||
** <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 "vabstractconverter.h"
|
||||
#include "exception/vexception.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
||||
:VDomDocument(), ver(0x0), fileName(fileName)
|
||||
{
|
||||
this->setXMLContent(fileName);
|
||||
const QString version = GetVersionStr();
|
||||
ver = GetVersion(version);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractConverter::~VAbstractConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractConverter::Convert() const
|
||||
{
|
||||
if (ver == MaxVer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString error;
|
||||
const QString backupFileName = fileName +".backup";
|
||||
if (SafeCopy(fileName, backupFileName, error) == false)
|
||||
{
|
||||
const QString errorMsg(tr("Error creation backup file: %1.").arg(error));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
|
||||
ApplyPatches();
|
||||
|
||||
QFile file(backupFileName);
|
||||
file.remove();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractConverter::GetVersionStr() const
|
||||
{
|
||||
const QDomNodeList nodeList = this->elementsByTagName(TagVersion);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
const QString errorMsg(tr("Couldn't get version information."));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
|
||||
if (nodeList.count() > 1)
|
||||
{
|
||||
const QString errorMsg(tr("Too many tags <%1> in file.").arg(TagVersion));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
|
||||
const QDomNode domNode = nodeList.at(0);
|
||||
if (domNode.isNull() == false && domNode.isElement())
|
||||
{
|
||||
const QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
return domElement.text();
|
||||
}
|
||||
}
|
||||
return QString(QStringLiteral("0.0.0"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VAbstractConverter::GetVersion(const QString &version) const
|
||||
{
|
||||
ValidateVersion(version);
|
||||
|
||||
QStringList ver = version.split(".");
|
||||
|
||||
bool ok = false;
|
||||
int major = ver.at(0).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
ok = false;
|
||||
int minor = ver.at(1).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
ok = false;
|
||||
int patch = ver.at(2).toInt(&ok);
|
||||
if (ok == false)
|
||||
{
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
return (major<<16)|(minor<<8)|(patch);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractConverter::ValidateVersion(const QString &version) const
|
||||
{
|
||||
QRegExp rx(QStringLiteral("^(0|([1-9][0-9]*)).(0|([1-9][0-9]*)).(0|([1-9][0-9]*))$"));
|
||||
|
||||
if (rx.exactMatch(version) == false)
|
||||
{
|
||||
const QString errorMsg(tr("Version \"%1\" invalid.").arg(version));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
|
||||
if (version == QLatin1String("0.0.0"))
|
||||
{
|
||||
const QString errorMsg(tr("Version \"0.0.0\" invalid."));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractConverter::CheckVersion(int ver) const
|
||||
{
|
||||
if (ver < MinVer())
|
||||
{
|
||||
const QString errorMsg(tr("Invalid version. Minimum supported version is %1").arg(MinVerStr()));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
|
||||
if (ver > MaxVer())
|
||||
{
|
||||
const QString errorMsg(tr("Invalid version. Maximum supported version is %1").arg(MaxVerStr()));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
}
|
67
src/libs/ifc/xml/vabstractconverter.h
Normal file
67
src/libs/ifc/xml/vabstractconverter.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vabstractconverter.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 10 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
|
||||
** <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 VABSTRACTCONVERTER_H
|
||||
#define VABSTRACTCONVERTER_H
|
||||
|
||||
#include "vdomdocument.h"
|
||||
|
||||
class VAbstractConverter :public VDomDocument
|
||||
{
|
||||
|
||||
public:
|
||||
VAbstractConverter(const QString &fileName);
|
||||
virtual ~VAbstractConverter();
|
||||
|
||||
void Convert() const;
|
||||
|
||||
protected:
|
||||
int ver;
|
||||
QString fileName;
|
||||
|
||||
int GetVersion(const QString &version) const;
|
||||
void CheckVersion(int ver) const;
|
||||
|
||||
virtual int MinVer() const =0;
|
||||
virtual int MaxVer() const =0;
|
||||
|
||||
virtual QString MinVerStr() const =0;
|
||||
virtual QString MaxVerStr() const =0;
|
||||
|
||||
virtual QString XSDSchema(int ver) const =0;
|
||||
virtual void ApplyPatches() const =0;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractConverter)
|
||||
|
||||
QString GetVersionStr() const;
|
||||
|
||||
void ValidateVersion(const QString &version) const;
|
||||
};
|
||||
|
||||
#endif // VABSTRACTCONVERTER_H
|
|
@ -27,11 +27,9 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vdomdocument.h"
|
||||
#include "../exception/vexceptionconversionerror.h"
|
||||
#include "../exception/vexceptionemptyparameter.h"
|
||||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../options.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "exception/vexceptionconversionerror.h"
|
||||
#include "exception/vexceptionemptyparameter.h"
|
||||
#include "exception/vexceptionbadid.h"
|
||||
|
||||
#include <QAbstractMessageHandler>
|
||||
#include <QXmlSchema>
|
||||
|
@ -100,8 +98,8 @@ const QString VDomDocument::UnitINCH = QStringLiteral("inch");
|
|||
const QString VDomDocument::TagVersion = QStringLiteral("version");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VDomDocument::VDomDocument(VContainer *data)
|
||||
: QDomDocument(), data(data), map(QHash<QString, QDomElement>())
|
||||
VDomDocument::VDomDocument()
|
||||
: QDomDocument(), map(QHash<QString, QDomElement>())
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -412,7 +410,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDomDocument::setContent(const QString &fileName)
|
||||
void VDomDocument::setXMLContent(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly) == false)
|
||||
|
@ -536,7 +534,7 @@ bool VDomDocument::SaveDocument(const QString &fileName, QString &error)
|
|||
tempFile.close();
|
||||
}
|
||||
//Copy document to file
|
||||
bool result = VApplication::SafeCopy(temp, fileName, error);
|
||||
bool result = VDomDocument::SafeCopy(temp, fileName, error);
|
||||
tempFile.remove();//Clear temp file
|
||||
|
||||
return result;
|
||||
|
@ -635,3 +633,50 @@ QDomElement VDomDocument::NodeById(const quint32 &nodeId)
|
|||
}
|
||||
return domElement;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VDomDocument::SafeCopy(const QString &source, const QString &destination, QString &error)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
||||
QFile patternFile(destination);
|
||||
patternFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
|
||||
// We need here temporary file because we want restore document after error of copying temp file.
|
||||
QTemporaryFile tempOfPattern;
|
||||
if (tempOfPattern.open())
|
||||
{
|
||||
if (patternFile.exists())
|
||||
{
|
||||
patternFile.copy(tempOfPattern.fileName());
|
||||
}
|
||||
}
|
||||
if ( patternFile.exists() == false || patternFile.remove() )
|
||||
{
|
||||
QFile sourceFile(source);
|
||||
if ( sourceFile.copy(patternFile.fileName()) == false )
|
||||
{
|
||||
error = tr("Could not copy temp file to document file");
|
||||
tempOfPattern.copy(destination);
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = tr("Could not remove document file");
|
||||
result = false;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup--; // turn off check permission again
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
||||
return result;
|
||||
}
|
|
@ -31,8 +31,10 @@
|
|||
|
||||
#include <QDomDocument>
|
||||
#include <QDebug>
|
||||
#include "../container/vcontainer.h"
|
||||
#include <QLoggingCategory>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "ifcdef.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(vXML)
|
||||
|
||||
|
@ -80,7 +82,7 @@ public:
|
|||
/**
|
||||
* @param data container with variables
|
||||
*/
|
||||
VDomDocument(VContainer *data);
|
||||
VDomDocument();
|
||||
virtual ~VDomDocument();
|
||||
QDomElement elementById(const QString& id);
|
||||
void removeAllChilds(QDomElement &element);
|
||||
|
@ -104,7 +106,7 @@ public:
|
|||
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
|
||||
|
||||
static void ValidateXML(const QString &schema, const QString &fileName);
|
||||
void setContent(const QString &fileName);
|
||||
void setXMLContent(const QString &fileName);
|
||||
static Unit StrToUnits(const QString &unit);
|
||||
static QString UnitsToStr(const Unit &unit, const bool translate = false);
|
||||
virtual bool SaveDocument(const QString &fileName, QString &error);
|
||||
|
@ -116,12 +118,12 @@ public:
|
|||
QDomNode ParentNodeById(const quint32 &nodeId);
|
||||
QDomElement CloneNodeById(const quint32 &nodeId);
|
||||
QDomElement NodeById(const quint32 &nodeId);
|
||||
protected:
|
||||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
||||
|
||||
protected:
|
||||
void setTagText(const QString &tag, const QString &text);
|
||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VDomDocument)
|
||||
/** @brief Map used for finding element by id. */
|
122
src/libs/ifc/xml/vpatternconverter.cpp
Normal file
122
src/libs/ifc/xml/vpatternconverter.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vpatternconverter.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <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 "vpatternconverter.h"
|
||||
#include "exception/vexception.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.1");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.1");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.1.xsd");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||
:VAbstractConverter(fileName)
|
||||
{
|
||||
const QString schema = XSDSchema(ver);
|
||||
ValidateXML(schema, fileName);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternConverter::~VPatternConverter()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPatternConverter::MinVer() const
|
||||
{
|
||||
return GetVersion(PatternMinVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPatternConverter::MaxVer() const
|
||||
{
|
||||
return GetVersion(PatternMaxVerStr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::MinVerStr() const
|
||||
{
|
||||
return PatternMinVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::MaxVerStr() const
|
||||
{
|
||||
return PatternMaxVerStr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPatternConverter::XSDSchema(int ver) const
|
||||
{
|
||||
CheckVersion(ver);
|
||||
|
||||
switch(ver)
|
||||
{
|
||||
case (0x000101):
|
||||
return CurrentSchema;
|
||||
default:
|
||||
{
|
||||
const QString errorMsg(tr("Unexpected version \"%1\".").arg(ver, 0, 16));
|
||||
throw VException(errorMsg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ApplyPatches() const
|
||||
{
|
||||
try
|
||||
{
|
||||
switch(ver)
|
||||
{
|
||||
case (0x000101):
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
QString error;
|
||||
const QString backupFileName = fileName +".backup";
|
||||
if (SafeCopy(backupFileName, fileName, error) == false)
|
||||
{
|
||||
const QString errorMsg(tr("Error restoring backup file: %1.").arg(error));
|
||||
VException excep(errorMsg);
|
||||
excep.AddMoreInformation(e.ErrorMessage());
|
||||
throw excep;
|
||||
}
|
||||
|
||||
QFile file(backupFileName);
|
||||
file.remove();
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
58
src/libs/ifc/xml/vpatternconverter.h
Normal file
58
src/libs/ifc/xml/vpatternconverter.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vpatternconverter.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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
|
||||
** <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 VPATTERNCONVERTER_H
|
||||
#define VPATTERNCONVERTER_H
|
||||
|
||||
#include "vabstractconverter.h"
|
||||
|
||||
class VPatternConverter : public VAbstractConverter
|
||||
{
|
||||
public:
|
||||
VPatternConverter(const QString &fileName);
|
||||
virtual ~VPatternConverter();
|
||||
|
||||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const;
|
||||
virtual int MaxVer() const;
|
||||
|
||||
virtual QString MinVerStr() const;
|
||||
virtual QString MaxVerStr() const;
|
||||
|
||||
QString XSDSchema(int ver) const;
|
||||
virtual void ApplyPatches() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPatternConverter)
|
||||
static const QString PatternMinVerStr;
|
||||
};
|
||||
|
||||
#endif // VPATTERNCONVERTER_H
|
12
src/libs/ifc/xml/xml.pri
Normal file
12
src/libs/ifc/xml/xml.pri
Normal file
|
@ -0,0 +1,12 @@
|
|||
# ADD TO EACH PATH $$PWD VARIABLE!!!!!!
|
||||
# This need for corect working file translations.pro
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vabstractconverter.h \
|
||||
$$PWD/vdomdocument.h \
|
||||
$$PWD/vpatternconverter.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vabstractconverter.cpp \
|
||||
$$PWD/vdomdocument.cpp \
|
||||
$$PWD/vpatternconverter.cpp
|
|
@ -1,4 +1,5 @@
|
|||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
SUBDIRS = qmuparser \
|
||||
vpropertyexplorer
|
||||
vpropertyexplorer \
|
||||
ifc
|
||||
|
|
Loading…
Reference in New Issue
Block a user