valentina_old/xml/vdomdocument.h

122 lines
5.9 KiB
C
Raw Normal View History

/****************************************************************************
**
** 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.
**
** Tox 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 <QHash>
2013-07-13 12:51:31 +02:00
#include <QComboBox>
#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 {
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
2013-08-20 12:26:02 +02:00
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
class VDomDocument : public QObject, public QDomDocument{
2013-07-13 12:51:31 +02:00
Q_OBJECT
public:
VDomDocument(VContainer *data,QComboBox *comboBoxDraws, Draw::Draws *mode);
2013-08-29 12:31:50 +02:00
VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
2013-08-29 12:31:50 +02:00
VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
Draw::Draws *mode);
~VDomDocument();
2013-07-13 12:51:31 +02:00
QDomElement elementById(const QString& id);
void CreateEmptyFile();
void ChangeActivDraw(const QString& name, Document::Documents parse = Document::FullParse);
2013-07-13 12:51:31 +02:00
QString GetNameActivDraw() const;
bool GetActivDrawElement(QDomElement &element);
bool GetActivCalculationElement(QDomElement &element);
bool GetActivModelingElement(QDomElement &element);
2013-08-28 10:55:11 +02:00
bool GetActivDetailsElement(QDomElement &element);
2013-07-13 12:51:31 +02:00
bool appendDraw(const QString& name);
bool SetNameDraw(const QString& name);
void Parse(Document::Documents parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail);
QHash<qint64, VDataTool*>* getTools();
2013-08-15 22:39:00 +02:00
QVector<VToolRecord> *getHistory();
2013-08-28 10:55:11 +02:00
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;
2013-07-13 12:51:31 +02:00
signals:
void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName);
void FullUpdateFromFile();
void haveChange();
2013-08-15 22:39:00 +02:00
void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
void ChangedCursor(qint64 id);
2013-07-13 12:51:31 +02:00
public slots:
void FullUpdateTree();
void haveLiteChange();
2013-08-15 22:39:00 +02:00
void ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable);
2013-07-13 12:51:31 +02:00
private:
Q_DISABLE_COPY(VDomDocument)
QHash<QString, QDomElement> map;
2013-07-13 12:51:31 +02:00
QString nameActivDraw;
VContainer *data;
QHash<qint64, VDataTool*> tools;
2013-08-15 22:39:00 +02:00
QVector<VToolRecord> history;
qint64 cursor;
QComboBox *comboBoxDraws;
Draw::Draws *mode;
2013-07-13 12:51:31 +02:00
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);
2013-08-28 10:55:11 +02:00
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse);
2013-08-28 10:55:11 +02:00
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse, Draw::Draws mode);
2013-08-28 10:55:11 +02:00
void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
2013-08-28 10:55:11 +02:00
void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement,
const Document::Documents &parse);
2013-07-13 12:51:31 +02:00
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString &type, Draw::Draws mode);
2013-07-25 20:39:51 +02:00
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, Draw::Draws mode);
2013-08-05 10:37:56 +02:00
void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode);
2013-08-06 09:56:09 +02:00
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
const Document::Documents &parse, const QString& type, Draw::Draws mode);
2013-07-17 13:38:11 +02: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-08-20 12:26:02 +02:00
#pragma GCC diagnostic pop
2013-07-13 12:51:31 +02:00
#endif // VDOMDOCUMENT_H