Refactoring. Use tag names from class VAbstractPattern.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-05-16 20:59:04 +03:00
parent 7dbba35919
commit ac49d298f8
26 changed files with 31 additions and 49 deletions

View File

@ -305,8 +305,7 @@ quint32 VPattern::SPointActiveDraw()
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == VToolSinglePoint::TagName &&
domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
if (domElement.tagName() == TagPoint && domElement.attribute(AttrType, "") == VToolBasePoint::ToolType)
{
return GetParametrId(domElement);
}
@ -658,7 +657,7 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == VToolDetail::TagName)
if (domElement.tagName() == TagDetail)
{
ParseDetailElement(domElement, parse);
}

View File

@ -38,6 +38,7 @@ const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");

View File

@ -132,6 +132,7 @@ public:
static const QString TagCalculation;
static const QString TagModeling;
static const QString TagDetails;
static const QString TagDetail;
static const QString TagAuthor;
static const QString TagDescription;
static const QString TagImage;

View File

@ -32,8 +32,6 @@
#include <QKeyEvent>
const QString VAbstractSpline::TagName = QStringLiteral("spline");
//---------------------------------------------------------------------------------------------------------------------
VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
@ -49,7 +47,7 @@ VAbstractSpline::~VAbstractSpline()
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::getTagName() const
{
return VAbstractSpline::TagName;
return VAbstractPattern::TagSpline;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -42,8 +42,7 @@ class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
public:
VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
virtual ~VAbstractSpline() Q_DECL_OVERRIDE;
// cppcheck-suppress duplInheritedMember
static const QString TagName;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)};
virtual QString getTagName() const Q_DECL_OVERRIDE;

View File

@ -36,7 +36,6 @@
#include <QKeyEvent>
const QString VToolArc::TagName = QStringLiteral("arc");
const QString VToolArc::ToolType = QStringLiteral("simple");
//---------------------------------------------------------------------------------------------------------------------
@ -165,7 +164,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
//---------------------------------------------------------------------------------------------------------------------
QString VToolArc::getTagName() const
{
return VToolArc::TagName;
return VAbstractPattern::TagArc;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -45,7 +45,7 @@ public:
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Arc)};

View File

@ -36,7 +36,6 @@
#include <QKeyEvent>
const QString VToolArcWithLength::TagName = QStringLiteral("arc");
const QString VToolArcWithLength::ToolType = QStringLiteral("arcWithLength");
//---------------------------------------------------------------------------------------------------------------------
@ -134,7 +133,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32
//---------------------------------------------------------------------------------------------------------------------
QString VToolArcWithLength::getTagName() const
{
return VToolArcWithLength::TagName;
return VAbstractPattern::TagArc;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -44,7 +44,7 @@ public:
QString &length, const QString &color, VMainGraphicsScene *scene,
VAbstractPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::ArcWithLength)};

View File

@ -125,7 +125,7 @@ void VToolBasePoint::AddToFile()
{
Q_ASSERT_X(not namePP.isEmpty(), Q_FUNC_INFO, "name pattern piece is empty");
QDomElement sPoint = doc->createElement(TagName);
QDomElement sPoint = doc->createElement(getTagName());
// Create SPoint tag
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);

View File

@ -29,8 +29,6 @@
#include "vabstractpoint.h"
#include "../vgeometry/vpointf.h"
const QString VAbstractPoint::TagName = QStringLiteral("point");
//---------------------------------------------------------------------------------------------------------------------
VAbstractPoint::VAbstractPoint(VAbstractPattern *doc, VContainer *data, quint32 id)
:VDrawTool(doc, data, id)
@ -43,7 +41,7 @@ VAbstractPoint::~VAbstractPoint()
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPoint::getTagName() const
{
return VAbstractPoint::TagName;
return VAbstractPattern::TagPoint;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -40,7 +40,6 @@ public:
virtual ~VAbstractPoint() Q_DECL_OVERRIDE;
virtual QString getTagName() const Q_DECL_OVERRIDE;
static const QString TagName;
template <typename T>
void ShowToolVisualization(bool show);

View File

@ -33,8 +33,6 @@
#include "../../dialogs/tools/dialogline.h"
#include "../../visualization/line/vistoolline.h"
const QString VToolLine::TagName = QStringLiteral("line");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VToolLine constructor.
@ -167,7 +165,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
//---------------------------------------------------------------------------------------------------------------------
QString VToolLine::getTagName() const
{
return VToolLine::TagName;
return VAbstractPattern::TagLine;
}
//---------------------------------------------------------------------------------------------------------------------
@ -249,7 +247,7 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
*/
void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
AddToCalculation(domElement);

View File

@ -45,7 +45,6 @@ public:
const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString TagName;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Line)};

View File

@ -31,7 +31,6 @@
#include <QGraphicsSceneMouseEvent>
#include <QPen>
const QString VNodeArc::TagName = QStringLiteral("arc");
const QString VNodeArc::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------
@ -94,7 +93,7 @@ void VNodeArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint
//---------------------------------------------------------------------------------------------------------------------
QString VNodeArc::getTagName() const
{
return VNodeArc::TagName;
return VAbstractPattern::TagArc;
}
//---------------------------------------------------------------------------------------------------------------------
@ -117,7 +116,7 @@ void VNodeArc::AllowSelecting(bool enabled)
*/
void VNodeArc::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);

View File

@ -41,7 +41,7 @@ class VNodeArc :public VAbstractNode
public:
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:

View File

@ -33,7 +33,6 @@
#include <QBrush>
#include <QGraphicsSceneMouseEvent>
const QString VNodePoint::TagName = QStringLiteral("point");
const QString VNodePoint::ToolType = QStringLiteral("modeling");
//---------------------------------------------------------------------------------------------------------------------
@ -119,7 +118,7 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc
//---------------------------------------------------------------------------------------------------------------------
QString VNodePoint::getTagName() const
{
return VNodePoint::TagName;
return VAbstractPattern::TagPoint;
}
//---------------------------------------------------------------------------------------------------------------------
@ -195,7 +194,7 @@ void VNodePoint::FullUpdateFromFile()
void VNodePoint::AddToFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);

View File

@ -47,7 +47,7 @@ public:
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::NodePoint)};

View File

@ -31,7 +31,6 @@
#include <QGraphicsSceneMouseEvent>
#include <QPen>
const QString VNodeSpline::TagName = QStringLiteral("spline");
const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline");
//---------------------------------------------------------------------------------------------------------------------
@ -98,7 +97,7 @@ VNodeSpline *VNodeSpline::Create(VAbstractPattern *doc, VContainer *data, quint3
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSpline::getTagName() const
{
return VNodeSpline::TagName;
return VAbstractPattern::TagSpline;
}
//---------------------------------------------------------------------------------------------------------------------
@ -121,7 +120,7 @@ void VNodeSpline::AllowSelecting(bool enabled)
*/
void VNodeSpline::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);

View File

@ -42,7 +42,7 @@ public:
static VNodeSpline *Create(VAbstractPattern *doc, VContainer *data, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:

View File

@ -32,7 +32,6 @@
#include <QGraphicsSceneMouseEvent>
#include <QPen>
const QString VNodeSplinePath::TagName = QStringLiteral("spline");
const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
//---------------------------------------------------------------------------------------------------------------------
@ -95,7 +94,7 @@ void VNodeSplinePath::Create(VAbstractPattern *doc, VContainer *data, quint32 id
//---------------------------------------------------------------------------------------------------------------------
QString VNodeSplinePath::getTagName() const
{
return VNodeSplinePath::TagName;
return VAbstractPattern::TagSpline;
}
//---------------------------------------------------------------------------------------------------------------------
@ -118,7 +117,7 @@ void VNodeSplinePath::AllowSelecting(bool enabled)
*/
void VNodeSplinePath::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);

View File

@ -42,7 +42,7 @@ public:
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id,
quint32 idSpline, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0);
static const QString TagName;
static const QString ToolType;
virtual QString getTagName() const Q_DECL_OVERRIDE;
public slots:

View File

@ -47,8 +47,6 @@
#include <QGraphicsView>
#include <QMessageBox>
const QString VToolDetail::TagName = QStringLiteral("detail");
const QString VToolDetail::TagNode = QStringLiteral("node");
const QString VToolDetail::AttrSupplement = QStringLiteral("supplement");
@ -315,7 +313,7 @@ void VToolDetail::FullUpdateFromGuiOk(int result)
void VToolDetail::AddToFile()
{
VDetail detail = VAbstractTool::data.GetDetail(id);
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrName, detail.getName());
@ -619,7 +617,7 @@ void VToolDetail::AddNode(VAbstractPattern *doc, QDomElement &domElement, const
//---------------------------------------------------------------------------------------------------------------------
QString VToolDetail::getTagName() const
{
return VToolDetail::TagName;
return VAbstractPattern::TagDetail;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -64,7 +64,6 @@ public:
static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation, const QString &drawName = QString());
static const QString TagName;
static const QString TagNode;
static const QString AttrSupplement;
static const QString AttrClosed;

View File

@ -36,7 +36,6 @@
#include <QUndoStack>
const QString VToolUnionDetails::TagName = QStringLiteral("tools");
const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails");
const QString VToolUnionDetails::TagDetail = QStringLiteral("det");
const QString VToolUnionDetails::TagNode = QStringLiteral("node");
@ -439,7 +438,7 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q
//---------------------------------------------------------------------------------------------------------------------
QString VToolUnionDetails::getTagName() const
{
return VToolUnionDetails::TagName;
return VAbstractPattern::TagTools;
}
//---------------------------------------------------------------------------------------------------------------------
@ -778,7 +777,7 @@ QVector<VDetail> VToolUnionDetails::GetDetailFromFile(VAbstractPattern *doc, con
*/
void VToolUnionDetails::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);

View File

@ -56,7 +56,7 @@ public:
static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data);
static void FindIndexJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j);
static QVector<VDetail> GetDetailFromFile(VAbstractPattern *doc, const QDomElement &domElement);
static const QString TagName;
static const QString ToolType;
static const QString TagDetail;
static const QString TagNode;