2cbe79c803
--HG-- branch : develop
134 lines
6.6 KiB
C++
134 lines
6.6 KiB
C++
/************************************************************************
|
|
**
|
|
** @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/>.
|
|
**
|
|
*************************************************************************/
|
|
|
|
#ifndef VDOMDOCUMENT_H
|
|
#define VDOMDOCUMENT_H
|
|
|
|
#include <QDomDocument>
|
|
#include "../container/vcontainer.h"
|
|
#include "../widgets/vmaingraphicsscene.h"
|
|
#include "../tools/vdatatool.h"
|
|
#include "vtoolrecord.h"
|
|
|
|
namespace Document
|
|
{
|
|
enum Document { LiteParse, FullParse};
|
|
Q_DECLARE_FLAGS(Documents, Document)
|
|
}
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
|
|
|
|
#ifdef Q_CC_GNU
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Weffc++"
|
|
#endif
|
|
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, const 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(const 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);
|
|
public slots:
|
|
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;
|
|
QHash<qint64, VDataTool*> tools;
|
|
QVector<VToolRecord> history;
|
|
qint64 cursor;
|
|
QComboBox *comboBoxDraws;
|
|
Draw::Draws *mode;
|
|
bool find(const 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, const 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, const Draw::Draws &mode);
|
|
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
|
const Document::Documents &parse, const Draw::Draws &mode);
|
|
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
|
const Document::Documents &parse, const QString& type, const Draw::Draws &mode);
|
|
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
|
const Document::Documents &parse, const QString& type, const 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(const QDomElement &node, QVector<qint64> &vector)const;
|
|
};
|
|
|
|
#ifdef Q_CC_GNU
|
|
#pragma GCC diagnostic pop
|
|
#endif
|
|
|
|
#endif // VDOMDOCUMENT_H
|