2015-12-16 17:16:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2006-2015 The QElectroTech Team
|
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech 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 QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef XMLELEMENTCOLLECTION_H
|
|
|
|
#define XMLELEMENTCOLLECTION_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDomElement>
|
2016-03-15 15:48:17 +00:00
|
|
|
#include "elementslocation.h"
|
2015-12-16 17:16:15 +00:00
|
|
|
|
|
|
|
class QDomElement;
|
2016-01-08 17:01:51 +00:00
|
|
|
class QFile;
|
2015-12-16 17:16:15 +00:00
|
|
|
|
2015-12-30 09:39:22 +00:00
|
|
|
/**
|
|
|
|
* @brief The XmlElementCollection class
|
|
|
|
* This class represent a collection of elements stored to xml
|
|
|
|
*/
|
2015-12-16 17:16:15 +00:00
|
|
|
class XmlElementCollection : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
XmlElementCollection (QObject *parent = nullptr);
|
|
|
|
XmlElementCollection (const QDomElement &dom_element, QObject *parent = nullptr);
|
|
|
|
QDomElement root() const;
|
2016-01-08 17:01:51 +00:00
|
|
|
QDomElement importCategory() const;
|
|
|
|
QDomNodeList childs(const QDomElement &parent_element) const;
|
|
|
|
QDomElement child(const QDomElement &parent_element, const QString &child_name) const;
|
2016-02-21 18:53:40 +00:00
|
|
|
QDomElement child(const QString &path) const;
|
2016-01-08 17:01:51 +00:00
|
|
|
QList<QDomElement> directories(const QDomElement &parent_element);
|
2016-03-09 10:17:28 +00:00
|
|
|
QStringList directoriesNames(const QDomElement &parent_element);
|
2015-12-16 17:16:15 +00:00
|
|
|
QList<QDomElement> elements(const QDomElement &parent_element);
|
2016-03-09 10:17:28 +00:00
|
|
|
QStringList elementsNames(const QDomElement &parent_element);
|
2015-12-30 09:39:22 +00:00
|
|
|
QDomElement element(const QString &path);
|
|
|
|
QDomElement directory(const QString &path);
|
2016-03-19 14:18:00 +00:00
|
|
|
QString addElement (ElementsLocation &location);
|
2016-04-19 09:29:40 +00:00
|
|
|
bool addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition);
|
2016-03-15 15:23:11 +00:00
|
|
|
ElementsLocation copy (ElementsLocation &source, ElementsLocation &destination, QString rename = QString(), bool deep_copy = true);
|
2016-01-08 17:01:51 +00:00
|
|
|
bool exist (const QString &path);
|
2015-12-16 17:16:15 +00:00
|
|
|
|
2016-02-21 18:53:40 +00:00
|
|
|
private:
|
2016-03-15 15:23:11 +00:00
|
|
|
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, QString rename = QString(), bool deep_copy = true);
|
|
|
|
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, QString rename = QString());
|
2016-02-21 18:53:40 +00:00
|
|
|
|
2015-12-16 17:16:15 +00:00
|
|
|
signals:
|
2016-01-08 17:01:51 +00:00
|
|
|
/**
|
|
|
|
* @brief elementAdded
|
|
|
|
* This signal is emited when a element is added to this collection
|
|
|
|
* @param collection_path, the path of element in this collection
|
|
|
|
*/
|
|
|
|
void elementAdded(QString collection_path);
|
2016-05-05 13:31:04 +00:00
|
|
|
/**
|
|
|
|
* @brief elementChanged
|
|
|
|
* This signal is emited when the defintion of the element at path was changed
|
|
|
|
* @param collection_path, the path of this element in this collection
|
|
|
|
*/
|
|
|
|
void elementChanged (QString collection_path);
|
2015-12-16 17:16:15 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
private:
|
|
|
|
QDomDocument m_dom_document;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // XMLELEMENTCOLLECTION_H
|