valentina_old/xml/vdomdocument.h

426 lines
12 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vdomdocument.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date November 15, 2013
**
** @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/>.
**
*************************************************************************/
2013-07-13 12:51:31 +02:00
#ifndef VDOMDOCUMENT_H
#define VDOMDOCUMENT_H
#include <QDomDocument>
#include "../container/vcontainer.h"
#include "../widgets/vmaingraphicsscene.h"
#include "../tools/vdatatool.h"
2013-08-15 22:39:00 +02:00
#include "vtoolrecord.h"
2013-07-13 12:51:31 +02:00
namespace Document
{
/**
* @brief The Document enum
*/
enum Document { LiteParse, FullParse};
Q_DECLARE_FLAGS(Documents, Document)
2013-07-13 12:51:31 +02:00
}
Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
2013-07-13 12:51:31 +02:00
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
/**
* @brief The VDomDocument class
*/
class VDomDocument : public QObject, public QDomDocument
{
2013-07-13 12:51:31 +02:00
Q_OBJECT
public:
/**
* @brief VDomDocument
* @param data
* @param comboBoxDraws
* @param mode
*/
VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode);
/**
* @brief VDomDocument
* @param name
* @param data
* @param comboBoxDraws
* @param mode
*/
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode);
/**
* @brief VDomDocument
* @param doc dom document containertype
* @param data
* @param comboBoxDraws
* @param mode
*/
2013-10-27 08:47:01 +01:00
VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
~VDomDocument(){}
/**
* @brief elementById
* @param id
* @return
*/
2013-10-27 08:47:01 +01:00
QDomElement elementById(const QString& id);
/**
* @brief CreateEmptyFile
*/
2013-10-27 08:47:01 +01:00
void CreateEmptyFile();
/**
* @brief ChangeActivDraw
* @param name
* @param parse
*/
void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse);
/**
* @brief GetNameActivDraw
* @return
*/
2013-10-27 08:47:01 +01:00
inline QString GetNameActivDraw() const {return nameActivDraw;}
/**
* @brief GetActivDrawElement
* @param element
* @return
*/
2013-10-27 08:47:01 +01:00
bool GetActivDrawElement(QDomElement &element);
/**
* @brief GetActivCalculationElement
* @param element
* @return
*/
2013-10-27 08:47:01 +01:00
bool GetActivCalculationElement(QDomElement &element);
/**
* @brief GetActivModelingElement
* @param element
* @return
*/
2013-10-27 08:47:01 +01:00
bool GetActivModelingElement(QDomElement &element);
/**
* @brief GetActivDetailsElement
* @param element
* @return
*/
2013-10-27 08:47:01 +01:00
bool GetActivDetailsElement(QDomElement &element);
/**
* @brief appendDraw
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
bool appendDraw(const QString& name);
/**
* @brief SetNameDraw
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
bool SetNameDraw(const QString& name);
/**
* @brief Parse
* @param parse
* @param sceneDraw
* @param sceneDetail
*/
void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail);
/**
* @brief getTools
* @return
*/
2013-10-27 08:47:01 +01:00
inline QHash<qint64, VDataTool*>* getTools() {return &tools;}
/**
* @brief getHistory
* @return
*/
2013-10-27 08:47:01 +01:00
inline QVector<VToolRecord> *getHistory() {return &history;}
/**
* @brief getCursor
* @return
*/
2013-10-27 08:47:01 +01:00
inline qint64 getCursor() const {return cursor;}
/**
* @brief setCursor
* @param value
*/
2013-10-27 08:47:01 +01:00
void setCursor(const qint64 &value);
/**
* @brief setCurrentData
*/
2013-10-27 08:47:01 +01:00
void setCurrentData();
/**
* @brief AddTool
* @param id
* @param tool
*/
2013-10-27 08:47:01 +01:00
void AddTool(const qint64 &id, VDataTool *tool);
/**
* @brief UpdateToolData
* @param id
* @param data
*/
2013-10-27 08:47:01 +01:00
void UpdateToolData(const qint64 &id, VContainer *data);
/**
* @brief IncrementReferens
* @param id
*/
2013-10-27 08:47:01 +01:00
void IncrementReferens(qint64 id) const;
/**
* @brief DecrementReferens
* @param id
*/
2013-10-27 08:47:01 +01:00
void DecrementReferens(qint64 id) const;
/**
* @brief TestUniqueId
*/
2013-10-27 08:47:01 +01:00
void TestUniqueId() const;
2013-07-13 12:51:31 +02:00
signals:
/**
* @brief ChangedActivDraw
* @param newName
*/
void ChangedActivDraw(const QString &newName);
/**
* @brief ChangedNameDraw
* @param oldName
* @param newName
*/
2013-10-27 08:47:01 +01:00
void ChangedNameDraw(const QString oldName, const QString newName);
/**
* @brief FullUpdateFromFile
*/
2013-10-27 08:47:01 +01:00
void FullUpdateFromFile();
/**
* @brief haveChange
*/
2013-10-27 08:47:01 +01:00
void haveChange();
/**
* @brief ShowTool
* @param id
* @param color
* @param enable
*/
2013-10-27 08:47:01 +01:00
void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
/**
* @brief ChangedCursor
* @param id
*/
2013-10-27 08:47:01 +01:00
void ChangedCursor(qint64 id);
2013-07-13 12:51:31 +02:00
public slots:
/**
* @brief FullUpdateTree
*/
2013-10-27 08:47:01 +01:00
void FullUpdateTree();
/**
* @brief haveLiteChange
*/
2013-10-27 08:47:01 +01:00
void haveLiteChange();
/**
* @brief ShowHistoryTool
* @param id
* @param color
* @param enable
*/
2013-10-27 08:47:01 +01:00
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
2013-07-13 12:51:31 +02:00
private:
Q_DISABLE_COPY(VDomDocument)
/**
* @brief map
*/
QHash<QString, QDomElement> map;
/**
* @brief nameActivDraw
*/
2013-10-27 08:47:01 +01:00
QString nameActivDraw;
/**
* @brief data container with data
*/
2013-10-27 08:47:01 +01:00
VContainer *data;
/**
* @brief tools
*/
QHash<qint64, VDataTool*> tools;
/**
* @brief history
*/
2013-08-15 22:39:00 +02:00
QVector<VToolRecord> history;
/**
* @brief cursor
*/
2013-10-27 08:47:01 +01:00
qint64 cursor;
/**
* @brief comboBoxDraws
*/
2013-10-27 08:47:01 +01:00
QComboBox *comboBoxDraws;
/**
* @brief mode
*/
2013-10-27 08:47:01 +01:00
Draw::Draws *mode;
/**
* @brief find
* @param node
* @param id
* @return
*/
bool find(const QDomElement &node, const QString& id);
/**
* @brief CheckNameDraw
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
bool CheckNameDraw(const QString& name) const;
/**
* @brief SetActivDraw
* @param name
*/
2013-10-27 08:47:01 +01:00
void SetActivDraw(const QString& name);
/**
* @brief GetActivNodeElement
* @param name
* @param element
* @return
*/
2013-10-27 08:47:01 +01:00
bool GetActivNodeElement(const QString& name, QDomElement& element);
/**
* @brief ParseDrawElement
* @param sceneDraw
* @param sceneDetail
* @param node
* @param parse
*/
2013-10-27 08:47:01 +01:00
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse);
/**
* @brief ParseDrawMode
* @param sceneDraw
* @param sceneDetail
* @param node
* @param parse
* @param mode
*/
2013-10-27 08:47:01 +01:00
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, const Draw::Draws &mode);
/**
* @brief ParseDetailElement
* @param sceneDetail
* @param domElement
* @param parse
*/
2013-10-27 08:47:01 +01:00
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
/**
* @brief ParseDetails
* @param sceneDetail
* @param domElement
* @param parse
*/
2013-10-27 08:47:01 +01:00
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
/**
* @brief ParsePointElement
* @param scene
* @param domElement
* @param parse
* @param type
* @param mode
*/
2013-10-27 08:47:01 +01:00
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString &type, const Draw::Draws &mode);
/**
* @brief ParseLineElement
* @param scene
* @param domElement
* @param parse
* @param mode
*/
2013-10-27 08:47:01 +01:00
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const Draw::Draws &mode);
/**
* @brief ParseSplineElement
* @param scene
* @param domElement
* @param parse
* @param type
* @param mode
*/
2013-10-27 08:47:01 +01:00
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, const Draw::Draws &mode);
/**
* @brief ParseArcElement
* @param scene
* @param domElement
* @param parse
* @param type
* @param mode
*/
2013-10-27 08:47:01 +01:00
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, const Draw::Draws &mode);
/**
* @brief ParseIncrementsElement
* @param node
*/
2013-10-27 08:47:01 +01:00
void ParseIncrementsElement(const QDomNode& node);
/**
* @brief GetParametrId
* @param domElement
* @return
*/
2013-10-27 08:47:01 +01:00
qint64 GetParametrId(const QDomElement& domElement) const;
/**
* @brief GetParametrLongLong
* @param domElement
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
qint64 GetParametrLongLong(const QDomElement& domElement, const QString &name) const;
/**
* @brief GetParametrString
* @param domElement
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
QString GetParametrString(const QDomElement& domElement, const QString &name) const;
/**
* @brief GetParametrDouble
* @param domElement
* @param name
* @return
*/
2013-10-27 08:47:01 +01:00
qreal GetParametrDouble(const QDomElement& domElement, const QString &name) const;
/**
* @brief CollectId
* @param node
* @param vector
*/
void CollectId(const QDomElement &node, QVector<qint64> &vector)const;
2013-07-13 12:51:31 +02:00
};
#ifdef Q_CC_GNU
#pragma GCC diagnostic pop
#endif
2013-08-20 12:26:02 +02:00
2013-07-13 12:51:31 +02:00
#endif // VDOMDOCUMENT_H