2013-09-18 21:16:19 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Valentina project All Rights Reserved.
|
|
|
|
**
|
|
|
|
** This file is part of Valentina.
|
|
|
|
**
|
|
|
|
** Tox 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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>
|
2013-11-06 16:49:07 +01:00
|
|
|
#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
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
namespace Document
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
enum Document { LiteParse, FullParse};
|
|
|
|
Q_DECLARE_FLAGS(Documents, Document)
|
2013-07-13 12:51:31 +02:00
|
|
|
}
|
2013-09-27 11:17:00 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
|
2013-07-13 12:51:31 +02:00
|
|
|
|
2013-11-06 18:59:20 +01:00
|
|
|
#ifdef Q_CC_GNU
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Weffc++"
|
|
|
|
#endif
|
2013-11-04 21:35:15 +01:00
|
|
|
class VDomDocument : public QObject, public QDomDocument
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-11-04 21:35:15 +01:00
|
|
|
VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode);
|
|
|
|
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode);
|
2013-10-27 08:47:01 +01:00
|
|
|
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;
|
2013-07-13 12:51:31 +02:00
|
|
|
signals:
|
2013-10-27 08:47:01 +01:00
|
|
|
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);
|
2013-07-13 12:51:31 +02:00
|
|
|
public slots:
|
2013-10-27 08:47:01 +01:00
|
|
|
void FullUpdateTree();
|
|
|
|
void haveLiteChange();
|
|
|
|
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
|
2013-07-13 12:51:31 +02:00
|
|
|
private:
|
2013-09-26 20:50:52 +02:00
|
|
|
Q_DISABLE_COPY(VDomDocument)
|
2013-10-04 13:32:42 +02:00
|
|
|
QHash<QString, QDomElement> map;
|
2013-10-27 08:47:01 +01:00
|
|
|
QString nameActivDraw;
|
|
|
|
VContainer *data;
|
2013-10-04 13:32:42 +02:00
|
|
|
QHash<qint64, VDataTool*> tools;
|
2013-08-15 22:39:00 +02:00
|
|
|
QVector<VToolRecord> history;
|
2013-10-27 08:47:01 +01:00
|
|
|
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,
|
2013-09-27 11:17:00 +02:00
|
|
|
const Document::Documents &parse, const QString& type, Draw::Draws mode);
|
2013-10-27 08:47:01 +01:00
|
|
|
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;
|
2013-07-13 12:51:31 +02:00
|
|
|
};
|
|
|
|
|
2013-11-06 18:59:20 +01: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
|