Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-27 09:47:01 +02:00
parent f0a9bdf4d2
commit f2860076ee
4 changed files with 94 additions and 147 deletions

View File

@ -20,21 +20,19 @@
****************************************************************************/
#include "vdomdocument.h"
#include <QDebug>
#include "tools/drawTools/drawtools.h"
#include "tools/nodeDetails/nodedetails.h"
#include "tools/modelingTools/modelingtools.h"
#include "tools/vtooldetail.h"
#include "options.h"
#include "container/calculator.h"
#include "geometry/vsplinepoint.h"
#include "exception/vexceptionwrongparameterid.h"
#include "exception/vexceptionconversionerror.h"
#include "exception/vexceptionemptyparameter.h"
#include "exception/vexceptionbadid.h"
#include "exception/vexceptionobjecterror.h"
#include "exception/vexceptionuniqueid.h"
#include <QMessageBox>
#include <exception/vexceptionwrongparameterid.h>
#include <exception/vexceptionconversionerror.h>
#include <exception/vexceptionemptyparameter.h>
#include <exception/vexceptionuniqueid.h>
#include <tools/vtooldetail.h>
#include <exception/vexceptionobjecterror.h>
#include <exception/vexceptionbadid.h>
#include <tools/drawTools/drawtools.h>
#include <tools/modelingTools/modelingtools.h>
#include <tools/nodeDetails/vnodepoint.h>
#include <tools/nodeDetails/vnodespline.h>
#include <tools/nodeDetails/vnodesplinepath.h>
#include <tools/nodeDetails/vnodearc.h>
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode) : QDomDocument(),
map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
@ -56,9 +54,6 @@ VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QC
comboBoxDraws(comboBoxDraws), mode(mode){
}
VDomDocument::~VDomDocument(){
}
QDomElement VDomDocument::elementById(const QString& id){
if (map.contains(id)) {
QDomElement e = map[id];
@ -190,10 +185,6 @@ void VDomDocument::SetActivDraw(const QString& name){
this->nameActivDraw = name;
}
QString VDomDocument::GetNameActivDraw() const{
return nameActivDraw;
}
bool VDomDocument::GetActivDrawElement(QDomElement &element){
if(!nameActivDraw.isEmpty()){
QDomNodeList elements = this->documentElement().elementsByTagName( "draw" );
@ -307,14 +298,6 @@ void VDomDocument::Parse(Document::Documents parse, VMainGraphicsScene *sceneDra
}
}
QHash<qint64, VDataTool *> *VDomDocument::getTools(){
return &tools;
}
QVector<VToolRecord> *VDomDocument::getHistory(){
return &history;
}
void VDomDocument::ParseIncrementsElement(const QDomNode &node){
QDomNode domNode = node.firstChild();
while(!domNode.isNull()){
@ -1134,10 +1117,6 @@ void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable
emit ShowTool(id, color, enable);
}
qint64 VDomDocument::getCursor() const{
return cursor;
}
void VDomDocument::setCursor(const qint64 &value){
cursor = value;
emit ChangedCursor(cursor);

View File

@ -23,10 +23,9 @@
#define VDOMDOCUMENT_H
#include <QDomDocument>
#include <QHash>
#include <QComboBox>
#include "widgets/vmaingraphicsscene.h"
#include "tools/vdatatool.h"
#include <container/vcontainer.h>
#include <widgets/vmaingraphicsscene.h>
#include <tools/vdatatool.h>
#include "vtoolrecord.h"
namespace Document {
@ -40,80 +39,80 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
class VDomDocument : public QObject, public QDomDocument{
Q_OBJECT
public:
VDomDocument(VContainer *data,QComboBox *comboBoxDraws, Draw::Draws *mode);
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
~VDomDocument();
QDomElement elementById(const QString& id);
void CreateEmptyFile();
void ChangeActivDraw(const QString& name, Document::Documents parse = Document::FullParse);
QString GetNameActivDraw() const;
bool GetActivDrawElement(QDomElement &element);
bool GetActivCalculationElement(QDomElement &element);
bool GetActivModelingElement(QDomElement &element);
bool GetActivDetailsElement(QDomElement &element);
bool appendDraw(const QString& name);
bool SetNameDraw(const QString& name);
void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail);
QHash<qint64, VDataTool*>* getTools();
QVector<VToolRecord> *getHistory();
qint64 getCursor() const;
void setCursor(const qint64 &value);
void setCurrentData();
void AddTool(const qint64 &id, VDataTool *tool);
void UpdateToolData(const qint64 &id, VContainer *data);
void IncrementReferens(qint64 id) const;
void DecrementReferens(qint64 id) const;
void TestUniqueId() const;
VDomDocument(VContainer *data,QComboBox *comboBoxDraws, Draw::Draws *mode);
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
~VDomDocument(){}
QDomElement elementById(const QString& id);
void CreateEmptyFile();
void ChangeActivDraw(const QString& name, Document::Documents parse = Document::FullParse);
inline QString GetNameActivDraw() const {return nameActivDraw;}
bool GetActivDrawElement(QDomElement &element);
bool GetActivCalculationElement(QDomElement &element);
bool GetActivModelingElement(QDomElement &element);
bool GetActivDetailsElement(QDomElement &element);
bool appendDraw(const QString& name);
bool SetNameDraw(const QString& name);
void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail);
inline QHash<qint64, VDataTool*>* getTools() {return &tools;}
inline QVector<VToolRecord> *getHistory() {return &history;}
inline qint64 getCursor() const {return cursor;}
void setCursor(const qint64 &value);
void setCurrentData();
void AddTool(const qint64 &id, VDataTool *tool);
void UpdateToolData(const qint64 &id, VContainer *data);
void IncrementReferens(qint64 id) const;
void DecrementReferens(qint64 id) const;
void TestUniqueId() const;
signals:
void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName);
void FullUpdateFromFile();
void haveChange();
void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
void ChangedCursor(qint64 id);
void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName);
void FullUpdateFromFile();
void haveChange();
void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
void ChangedCursor(qint64 id);
public slots:
void FullUpdateTree();
void haveLiteChange();
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
void FullUpdateTree();
void haveLiteChange();
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
private:
Q_DISABLE_COPY(VDomDocument)
QHash<QString, QDomElement> map;
QString nameActivDraw;
VContainer *data;
QString nameActivDraw;
VContainer *data;
QHash<qint64, VDataTool*> tools;
QVector<VToolRecord> history;
qint64 cursor;
QComboBox *comboBoxDraws;
Draw::Draws *mode;
bool find(QDomElement node, const QString& id);
bool CheckNameDraw(const QString& name) const;
void SetActivDraw(const QString& name);
bool GetActivNodeElement(const QString& name, QDomElement& element);
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse);
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, Draw::Draws mode);
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString &type, Draw::Draws mode);
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, Draw::Draws mode);
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
qint64 cursor;
QComboBox *comboBoxDraws;
Draw::Draws *mode;
bool find(QDomElement node, const QString& id);
bool CheckNameDraw(const QString& name) const;
void SetActivDraw(const QString& name);
bool GetActivNodeElement(const QString& name, QDomElement& element);
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse);
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, Draw::Draws mode);
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString &type, Draw::Draws mode);
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, Draw::Draws mode);
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode);
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode);
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode);
void ParseIncrementsElement(const QDomNode& node);
qint64 GetParametrId(const QDomElement& domElement) const;
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name) const;
QString GetParametrString(const QDomElement& domElement, const QString &name) const;
qreal GetParametrDouble(const QDomElement& domElement, const QString &name) const;
void CollectId(QDomElement node, QVector<qint64> &vector)const;
void ParseIncrementsElement(const QDomNode& node);
qint64 GetParametrId(const QDomElement& domElement) const;
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name) const;
QString GetParametrString(const QDomElement& domElement, const QString &name) const;
qreal GetParametrDouble(const QDomElement& domElement, const QString &name) const;
void CollectId(QDomElement node, QVector<qint64> &vector)const;
};
#pragma GCC diagnostic pop

View File

@ -27,27 +27,3 @@ VToolRecord::VToolRecord():id(0), typeTool(Tool::ArrowTool), nameDraw(QString())
VToolRecord::VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw):id(id),
typeTool(typeTool), nameDraw(nameDraw){
}
QString VToolRecord::getNameDraw() const{
return nameDraw;
}
void VToolRecord::setNameDraw(const QString &value){
nameDraw = value;
}
Tool::Tools VToolRecord::getTypeTool() const{
return typeTool;
}
void VToolRecord::setTypeTool(const Tool::Tools &value){
typeTool = value;
}
qint64 VToolRecord::getId() const{
return id;
}
void VToolRecord::setId(const qint64 &value){
id = value;
}

View File

@ -22,27 +22,20 @@
#ifndef VTOOLRECORD_H
#define VTOOLRECORD_H
#include <QString>
#include "options.h"
class VToolRecord
{
class VToolRecord{
public:
VToolRecord();
VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw);
qint64 getId() const;
void setId(const qint64 &value);
Tool::Tools getTypeTool() const;
void setTypeTool(const Tool::Tools &value);
QString getNameDraw() const;
void setNameDraw(const QString &value);
VToolRecord();
VToolRecord(const qint64 &id, const Tool::Tools &typeTool, const QString &nameDraw);
inline qint64 getId() const {return id;}
inline void setId(const qint64 &value) {id = value;}
inline Tool::Tools getTypeTool() const {return typeTool;}
inline void setTypeTool(const Tool::Tools &value) {typeTool = value;}
inline QString getNameDraw() const {return nameDraw;}
inline void setNameDraw(const QString &value) {nameDraw = value;}
private:
qint64 id;
Tool::Tools typeTool;
QString nameDraw;
qint64 id;
Tool::Tools typeTool;
QString nameDraw;
};
#endif // VTOOLRECORD_H