Converter inherits class VDomDocument.
--HG-- branch : feature
This commit is contained in:
parent
394d54e9c1
commit
21d1a781fd
|
@ -2039,53 +2039,6 @@ QString VApplication::STDescription(const QString &id) const
|
||||||
return QString();
|
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()
|
void VApplication::StartLogging()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,7 +106,6 @@ public:
|
||||||
|
|
||||||
static QStringList LabelLanguages();
|
static QStringList LabelLanguages();
|
||||||
QString STDescription(const QString &id)const;
|
QString STDescription(const QString &id)const;
|
||||||
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
|
||||||
|
|
||||||
void StartLogging();
|
void StartLogging();
|
||||||
QTextStream *LogFile();
|
QTextStream *LogFile();
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#include "../../geometry/vpointf.h"
|
#include "../../geometry/vpointf.h"
|
||||||
#include "../../container/vcontainer.h"
|
#include "../../container/vcontainer.h"
|
||||||
#include "../../xml/vdomdocument.h"
|
#include "../../libs/ifc/xml/vdomdocument.h"
|
||||||
#include "../../visualization/vistoolarc.h"
|
#include "../../visualization/vistoolarc.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "../../geometry/vpointf.h"
|
#include "../../geometry/vpointf.h"
|
||||||
#include "../../geometry/vsplinepath.h"
|
#include "../../geometry/vsplinepath.h"
|
||||||
#include "../../container/vcontainer.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 "../../../libs/qmuparser/qmuparsererror.h"
|
||||||
#include "../../core/vapplication.h"
|
#include "../../core/vapplication.h"
|
||||||
#include "../../core/vsettings.h"
|
#include "../../core/vsettings.h"
|
||||||
#include "../../xml/vdomdocument.h"
|
#include "../../libs/ifc/xml/vdomdocument.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
|
@ -2483,7 +2483,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
|
||||||
for (int i = 0; i < restoreFiles.size(); ++i)
|
for (int i = 0; i < restoreFiles.size(); ++i)
|
||||||
{
|
{
|
||||||
QString error;
|
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");
|
QFile autoFile(restoreFiles.at(i) +".autosave");
|
||||||
autoFile.remove();
|
autoFile.remove();
|
||||||
|
|
|
@ -118,8 +118,6 @@ enum class Vis : unsigned char
|
||||||
|
|
||||||
enum class Source : char { FromGui, FromFile, FromTool };
|
enum class Source : char { FromGui, FromFile, FromTool };
|
||||||
enum class Draw : char { Calculation, Modeling };
|
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 NodeDetail : char { Contour, Modeling };
|
||||||
enum class Contour : char { OpenContour, CloseContour };
|
enum class Contour : char { OpenContour, CloseContour };
|
||||||
enum class EquidistantType : char { OpenEquidistant, CloseEquidistant };
|
enum class EquidistantType : char { OpenEquidistant, CloseEquidistant };
|
||||||
|
|
|
@ -33,7 +33,7 @@ const QString VAbstractMeasurements::AttrValue = QStringLiteral("value");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractMeasurements::VAbstractMeasurements(VContainer *data)
|
VAbstractMeasurements::VAbstractMeasurements(VContainer *data)
|
||||||
:VDomDocument(data)
|
:VDomDocument(), data(data)
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#ifndef VABSTRACTMEASUREMENTS_H
|
#ifndef VABSTRACTMEASUREMENTS_H
|
||||||
#define VABSTRACTMEASUREMENTS_H
|
#define VABSTRACTMEASUREMENTS_H
|
||||||
|
|
||||||
#include "vdomdocument.h"
|
#include "../libs/ifc/xml/vdomdocument.h"
|
||||||
|
#include "../container/vcontainer.h"
|
||||||
|
|
||||||
class VAbstractMeasurements : public VDomDocument
|
class VAbstractMeasurements : public VDomDocument
|
||||||
{
|
{
|
||||||
|
@ -42,6 +43,9 @@ public:
|
||||||
static const QString AttrValue;
|
static const QString AttrValue;
|
||||||
static qreal UnitConvertor(qreal value, const Unit &from, const Unit &to);
|
static qreal UnitConvertor(qreal value, const Unit &from, const Unit &to);
|
||||||
protected:
|
protected:
|
||||||
|
/** @brief data container with data. */
|
||||||
|
VContainer *data;
|
||||||
|
|
||||||
void Measurement(const QString &tag);
|
void Measurement(const QString &tag);
|
||||||
virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) = 0;
|
virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) = 0;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -121,7 +121,7 @@ const QString VPattern::IncrementDescription = QStringLiteral("description");
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
||||||
VMainGraphicsScene *sceneDetail, QObject *parent)
|
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),
|
history(QVector<VToolRecord>()), cursor(0), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw),
|
||||||
sceneDetail(sceneDetail)
|
sceneDetail(sceneDetail)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,9 @@
|
||||||
#ifndef VPATTERN_H
|
#ifndef VPATTERN_H
|
||||||
#define VPATTERN_H
|
#define VPATTERN_H
|
||||||
|
|
||||||
#include "vdomdocument.h"
|
#include "../libs/ifc/xml/vdomdocument.h"
|
||||||
#include "vtoolrecord.h"
|
#include "vtoolrecord.h"
|
||||||
|
#include "../container/vcontainer.h"
|
||||||
|
|
||||||
class VDataTool;
|
class VDataTool;
|
||||||
class VMainGraphicsScene;
|
class VMainGraphicsScene;
|
||||||
|
@ -233,6 +234,9 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPattern)
|
Q_DISABLE_COPY(VPattern)
|
||||||
|
|
||||||
|
/** @brief data container with data. */
|
||||||
|
VContainer *data;
|
||||||
|
|
||||||
/** @brief nameActivDraw name current pattern peace. */
|
/** @brief nameActivDraw name current pattern peace. */
|
||||||
QString nameActivPP;
|
QString nameActivPP;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/vtoolrecord.h \
|
$$PWD/vtoolrecord.h \
|
||||||
$$PWD/vdomdocument.h \
|
|
||||||
$$PWD/vpattern.h \
|
$$PWD/vpattern.h \
|
||||||
$$PWD/vstandardmeasurements.h \
|
$$PWD/vstandardmeasurements.h \
|
||||||
$$PWD/vindividualmeasurements.h \
|
$$PWD/vindividualmeasurements.h \
|
||||||
|
@ -11,7 +10,6 @@ HEADERS += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vtoolrecord.cpp \
|
$$PWD/vtoolrecord.cpp \
|
||||||
$$PWD/vdomdocument.cpp \
|
|
||||||
$$PWD/vpattern.cpp \
|
$$PWD/vpattern.cpp \
|
||||||
$$PWD/vstandardmeasurements.cpp \
|
$$PWD/vstandardmeasurements.cpp \
|
||||||
$$PWD/vindividualmeasurements.cpp \
|
$$PWD/vindividualmeasurements.cpp \
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
|
enum class Unit : char { Mm, Cm, Inch };
|
||||||
|
enum class MeasurementsType : char { Standard, Individual };
|
||||||
|
|
||||||
static const quint32 null_id = 0;
|
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 null_id//use this value for initialization variables that keeps id values. 0 mean uknown id value.
|
||||||
|
|
|
@ -27,11 +27,9 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vdomdocument.h"
|
#include "vdomdocument.h"
|
||||||
#include "../libs/ifc/exception/vexceptionconversionerror.h"
|
#include "exception/vexceptionconversionerror.h"
|
||||||
#include "../libs/ifc/exception/vexceptionemptyparameter.h"
|
#include "exception/vexceptionemptyparameter.h"
|
||||||
#include "../libs/ifc/exception/vexceptionbadid.h"
|
#include "exception/vexceptionbadid.h"
|
||||||
#include "../options.h"
|
|
||||||
#include "../core/vapplication.h"
|
|
||||||
|
|
||||||
#include <QAbstractMessageHandler>
|
#include <QAbstractMessageHandler>
|
||||||
#include <QXmlSchema>
|
#include <QXmlSchema>
|
||||||
|
@ -100,8 +98,8 @@ const QString VDomDocument::UnitINCH = QStringLiteral("inch");
|
||||||
const QString VDomDocument::TagVersion = QStringLiteral("version");
|
const QString VDomDocument::TagVersion = QStringLiteral("version");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VDomDocument::VDomDocument(VContainer *data)
|
VDomDocument::VDomDocument()
|
||||||
: QDomDocument(), data(data), map(QHash<QString, QDomElement>())
|
: QDomDocument(), map(QHash<QString, QDomElement>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -536,7 +534,7 @@ bool VDomDocument::SaveDocument(const QString &fileName, QString &error)
|
||||||
tempFile.close();
|
tempFile.close();
|
||||||
}
|
}
|
||||||
//Copy document to file
|
//Copy document to file
|
||||||
bool result = VApplication::SafeCopy(temp, fileName, error);
|
bool result = VDomDocument::SafeCopy(temp, fileName, error);
|
||||||
tempFile.remove();//Clear temp file
|
tempFile.remove();//Clear temp file
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -635,3 +633,50 @@ QDomElement VDomDocument::NodeById(const quint32 &nodeId)
|
||||||
}
|
}
|
||||||
return domElement;
|
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 <QDomDocument>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "../container/vcontainer.h"
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include "ifcdef.h"
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(vXML)
|
Q_DECLARE_LOGGING_CATEGORY(vXML)
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @param data container with variables
|
* @param data container with variables
|
||||||
*/
|
*/
|
||||||
VDomDocument(VContainer *data);
|
VDomDocument();
|
||||||
virtual ~VDomDocument();
|
virtual ~VDomDocument();
|
||||||
QDomElement elementById(const QString& id);
|
QDomElement elementById(const QString& id);
|
||||||
void removeAllChilds(QDomElement &element);
|
void removeAllChilds(QDomElement &element);
|
||||||
|
@ -116,12 +118,12 @@ public:
|
||||||
QDomNode ParentNodeById(const quint32 &nodeId);
|
QDomNode ParentNodeById(const quint32 &nodeId);
|
||||||
QDomElement CloneNodeById(const quint32 &nodeId);
|
QDomElement CloneNodeById(const quint32 &nodeId);
|
||||||
QDomElement NodeById(const quint32 &nodeId);
|
QDomElement NodeById(const quint32 &nodeId);
|
||||||
protected:
|
static bool SafeCopy(const QString &source, const QString &destination, QString &error);
|
||||||
/** @brief data container with data. */
|
|
||||||
VContainer *data;
|
|
||||||
|
|
||||||
|
protected:
|
||||||
void setTagText(const QString &tag, const QString &text);
|
void setTagText(const QString &tag, const QString &text);
|
||||||
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VDomDocument)
|
Q_DISABLE_COPY(VDomDocument)
|
||||||
/** @brief Map used for finding element by id. */
|
/** @brief Map used for finding element by id. */
|
|
@ -2,7 +2,9 @@
|
||||||
# This need for corect working file translations.pro
|
# This need for corect working file translations.pro
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/vabstractconverter.h
|
$$PWD/vabstractconverter.h \
|
||||||
|
$$PWD/vdomdocument.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vabstractconverter.cpp
|
$$PWD/vabstractconverter.cpp \
|
||||||
|
$$PWD/vdomdocument.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user