QElectroTech
0.70
|
The XmlElementCollection class This class represent a collection of elements stored to xml. More...
#include <xmlelementcollection.h>
Signals | |
void | elementAdded (QString collection_path) |
elementAdded This signal is emited when a element is added to this collection More... | |
void | elementChanged (QString collection_path) |
elementChanged This signal is emited when the defintion of the element at path was changed More... | |
void | elementRemoved (QString collection_path) |
elementRemoved This signal is emited when an element is removed to this collection More... | |
void | directorieAdded (QString collection_path) |
directorieAdded This signal is emited when a directorie is added to this collection More... | |
void | directoryRemoved (QString collection_path) |
directoryRemoved This signal is emited when a directory is removed to this collection More... | |
Public Member Functions | |
XmlElementCollection (QETProject *project) | |
XmlElementCollection::XmlElementCollection Build an empty collection. The collection start by : <collection> <category name="import> </category> </collection> All elements and category are stored as child of <category name="import> More... | |
XmlElementCollection (const QDomElement &dom_element, QETProject *project) | |
XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of must be "collection". More... | |
QDomElement | root () const |
XmlElementCollection::root The root is the first DOM-Element the xml collection, the tag name of the dom element is : collection. More... | |
QDomElement | importCategory () const |
XmlElementCollection::importCategory. More... | |
QDomNodeList | childs (const QDomElement &parent_element) const |
XmlElementCollection::childs. More... | |
QDomElement | child (const QDomElement &parent_element, const QString &child_name) const |
XmlElementCollection::child If parent_element have child element with an attribute name = , return it, else return a null QDomElement. Only search for element with tag-name "category" and "element" (if child_name end with ".elmt") More... | |
QDomElement | child (const QString &path) const |
XmlElementCollection::child. More... | |
QList< QDomElement > | directories (const QDomElement &parent_element) const |
XmlElementCollection::directories. More... | |
QStringList | directoriesNames (const QDomElement &parent_element) const |
XmlElementCollection::directoriesNames. More... | |
QList< QDomElement > | elements (const QDomElement &parent_element) const |
XmlElementCollection::elements. More... | |
QStringList | elementsNames (const QDomElement &parent_element) const |
XmlElementCollection::elementsNames. More... | |
QDomElement | element (const QString &path) const |
XmlElementCollection::element. More... | |
QDomElement | directory (const QString &path) const |
XmlElementCollection::directory. More... | |
QString | addElement (ElementsLocation &location) |
XmlElementCollection::addElement Add the element at location to this collection. The element is copied in this collection in "import" dir with the same path, in other word if the path is dir1/dir2/dir3/myElement.elmt, myElement is copied to this collection at the path : import/dir1/dir2/dir3/myElement.elmt If the path doesn't exist, he was created. If the element already exist, do nothing. More... | |
bool | addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition) |
XmlElementCollection::addElementDefinition Add the élément defintion in the directory at path with the name . More... | |
bool | removeElement (const QString &path) |
XmlElementCollection::removeElement Remove the element at path . More... | |
ElementsLocation | copy (ElementsLocation &source, ElementsLocation &destination, const QString &rename=QString(), bool deep_copy=true) |
XmlElementCollection::copy Copy the content represented by source (an element or a directory) to destination. Destination must be a directory of this collection. If the destination already have an item at the same path of source, he will be replaced by source. More... | |
bool | exist (const QString &path) const |
XmlElementCollection::exist Return true if the path exist in this collection. More... | |
Private Attributes | |
QDomDocument | m_dom_document |
QETProject * | m_project = nullptr |
. | |||||||
XmlElementCollection::createDir Create a child directorie at path with the name Emit directorieAdded if success.
| |||||||
bool | createDir (const QString &path, const QString &name, const NamesList &name_list) | ||||||
bool | removeDir (const QString &path) | ||||||
XmlElementCollection::removeDir Remove the directory at path . More... | |||||||
QList< ElementsLocation > | elementsLocation (QDomElement dom_element=QDomElement(), bool childs=true) const | ||||||
XmlElementCollection::elementsLocation Return all locations stored in dom_element (element and directory). If dom_element is null, return all location owned by this collection dom_element must be a child of this collection. More... | |||||||
ElementsLocation | domToLocation (QDomElement dom_element) const | ||||||
XmlElementCollection::domToLocation Return the element location who represent the xml element : dom_element dom_element must be owned by this collection. More... | |||||||
void | cleanUnusedElement () | ||||||
XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the owner project. More... | |||||||
void | cleanUnusedDirectory () | ||||||
XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection. More... | |||||||
ElementsLocation | copyDirectory (ElementsLocation &source, ElementsLocation &destination, const QString &rename=QString(), bool deep_copy=true) | ||||||
XmlElementCollection::copyDirectory Copy the directory represented by source to destination. if destination have a directory with the same name as source, then this directory is removed. More... | |||||||
ElementsLocation | copyElement (ElementsLocation &source, ElementsLocation &destination, const QString &rename=QString()) | ||||||
XmlElementCollection::copyElement Copy the element represented by source to destination (must be a directory) If element already exist in destination he will be replaced by the new. More... | |||||||
The XmlElementCollection class This class represent a collection of elements stored to xml.
Definition at line 33 of file xmlelementcollection.h.
XmlElementCollection::XmlElementCollection | ( | QETProject * | project | ) |
XmlElementCollection::XmlElementCollection Build an empty collection. The collection start by : <collection> <category name="import> </category> </collection> All elements and category are stored as child of <category name="import>
project | : the project of this collection |
Definition at line 35 of file xmlelementcollection.cpp.
References NamesList::addName(), m_dom_document, and NamesList::toXml().
XmlElementCollection::XmlElementCollection | ( | const QDomElement & | dom_element, |
QETProject * | project | ||
) |
XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of must be "collection".
dom_element | -the collection in a dom_element (the dom element in cloned) |
project | : the project of this collection |
Definition at line 79 of file xmlelementcollection.cpp.
References m_dom_document.
QString XmlElementCollection::addElement | ( | ElementsLocation & | location | ) |
XmlElementCollection::addElement Add the element at location to this collection. The element is copied in this collection in "import" dir with the same path, in other word if the path is dir1/dir2/dir3/myElement.elmt, myElement is copied to this collection at the path : import/dir1/dir2/dir3/myElement.elmt If the path doesn't exist, he was created. If the element already exist, do nothing.
location,location | of the element |
Definition at line 301 of file xmlelementcollection.cpp.
References child(), ElementsLocation::collectionPath(), elementAdded(), exist(), ElementsLocation::exist(), QETXML::fileSystemDirToXmlCollectionDir(), QETXML::fileSystemElementToXmlCollectionElement(), ElementsLocation::fileSystemPath(), importCategory(), ElementsLocation::isElement(), ElementsLocation::isFileSystem(), ElementsLocation::isProject(), m_dom_document, ElementsLocation::nameList(), ElementsLocation::project(), ElementsLocation::projectCollection(), NamesList::toXml(), and ElementsLocation::xml().
Referenced by QETProject::importElement().
bool XmlElementCollection::addElementDefinition | ( | const QString & | dir_path, |
const QString & | elmt_name, | ||
const QDomElement & | xml_definition | ||
) |
XmlElementCollection::addElementDefinition Add the élément defintion in the directory at path with the name .
dir_path | : the path of the directory where we must add the element. The path must be an existing directory of this collection. |
elmt_name | : The name used to store the element (the name must end with .elmt, if not, .elmt will be append to ) |
xml_definition | : The xml definition of the element. The tag name of must be "definition". |
Definition at line 435 of file xmlelementcollection.cpp.
References directory(), elementAdded(), and m_dom_document.
Referenced by ElementsLocation::setXml().
QDomElement XmlElementCollection::child | ( | const QDomElement & | parent_element, |
const QString & | child_name | ||
) | const |
XmlElementCollection::child If parent_element have child element with an attribute name = , return it, else return a null QDomElement. Only search for element with tag-name "category" and "element" (if child_name end with ".elmt")
parent_element | : the parent DomElement where we search for child. must be a child node of this XmlElementCollection. |
child_name | : name of child to search. |
Definition at line 128 of file xmlelementcollection.cpp.
References m_dom_document.
Referenced by addElement(), child(), copyDirectory(), copyElement(), directoriesNames(), directory(), element(), elementsNames(), and exist().
QDomElement XmlElementCollection::child | ( | const QString & | path | ) | const |
path |
Definition at line 156 of file xmlelementcollection.cpp.
QDomNodeList XmlElementCollection::childs | ( | const QDomElement & | parent_element | ) | const |
parent_element |
Definition at line 113 of file xmlelementcollection.cpp.
References m_dom_document.
Referenced by directories(), directoriesNames(), elements(), elementsLocation(), and elementsNames().
void XmlElementCollection::cleanUnusedDirectory | ( | ) |
XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection.
Definition at line 654 of file xmlelementcollection.cpp.
References domToLocation(), importCategory(), and removeDir().
Referenced by ProjectView::cleanProject().
void XmlElementCollection::cleanUnusedElement | ( | ) |
XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the owner project.
Definition at line 644 of file xmlelementcollection.cpp.
References ElementsLocation::collectionPath(), m_project, removeElement(), and QETProject::unusedElements().
Referenced by ProjectView::cleanProject().
ElementsLocation XmlElementCollection::copy | ( | ElementsLocation & | source, |
ElementsLocation & | destination, | ||
const QString & | rename = QString() , |
||
bool | deep_copy = true |
||
) |
XmlElementCollection::copy Copy the content represented by source (an element or a directory) to destination. Destination must be a directory of this collection. If the destination already have an item at the same path of source, he will be replaced by source.
source | : content to copy |
destination | : destination of the copy, must be a directory of this collection |
rename | : rename the copy with else use the name of source |
deep_copy | : if true copy all childs of source (only if source is directory) |
Definition at line 494 of file xmlelementcollection.cpp.
References copyDirectory(), copyElement(), ElementsLocation::exist(), ElementsLocation::isDirectory(), ElementsLocation::isElement(), ElementsLocation::isProject(), and ElementsLocation::projectCollection().
Referenced by ECHSToXml::copy(), QETProject::importElement(), and ElementCollectionHandler::importFromProject().
|
private |
XmlElementCollection::copyDirectory Copy the directory represented by source to destination. if destination have a directory with the same name as source, then this directory is removed.
source | : directory to copy |
destination | : destination of the copy |
rename | : rename the copy with else use the name of source |
deep_copy | :if true copy all childs of source |
Definition at line 678 of file xmlelementcollection.cpp.
References child(), ElementsLocation::collectionPath(), copyElement(), directorieAdded(), directory(), directoryRemoved(), element(), ElementsLocation::fileName(), QETXML::fileSystemDirToXmlCollectionDir(), ElementsLocation::fileSystemPath(), ElementsLocation::isFileSystem(), m_dom_document, ElementsLocation::projectCollection(), ElementsLocation::projectCollectionPath(), and ElementsLocation::setPath().
Referenced by copy().
|
private |
XmlElementCollection::copyElement Copy the element represented by source to destination (must be a directory) If element already exist in destination he will be replaced by the new.
source | : element to copy |
destination | : destination of the copy |
rename | : rename the copy with else use the name of source |
Definition at line 765 of file xmlelementcollection.cpp.
References child(), ElementsLocation::collectionPath(), directory(), element(), elementAdded(), elementChanged(), ElementsLocation::fileName(), QETXML::fileSystemElementToXmlCollectionElement(), ElementsLocation::fileSystemPath(), ElementsLocation::isFileSystem(), m_dom_document, ElementsLocation::projectCollectionPath(), and ElementsLocation::xml().
Referenced by copy(), and copyDirectory().
bool XmlElementCollection::createDir | ( | const QString & | path, |
const QString & | name, | ||
const NamesList & | name_list | ||
) |
Definition at line 528 of file xmlelementcollection.cpp.
References directorieAdded(), directory(), m_dom_document, and NamesList::toXml().
Referenced by ElementCollectionHandler::createDir().
|
signal |
directorieAdded This signal is emited when a directorie is added to this collection
collection_path,the | path of the new directorie |
Referenced by copyDirectory(), and createDir().
QList< QDomElement > XmlElementCollection::directories | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::directories.
parent_element |
Definition at line 180 of file xmlelementcollection.cpp.
References childs().
Referenced by directoriesNames(), elementsLocation(), and XmlProjectElementCollectionItem::populate().
QStringList XmlElementCollection::directoriesNames | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::directoriesNames.
parent_element |
Definition at line 201 of file xmlelementcollection.cpp.
References child(), childs(), and directories().
Referenced by ECHSXmlToFile::copyDirectory().
QDomElement XmlElementCollection::directory | ( | const QString & | path | ) | const |
XmlElementCollection::directory.
path | : path of the directory in this collection |
Definition at line 281 of file xmlelementcollection.cpp.
References child().
Referenced by addElementDefinition(), ECHSXmlToFile::copyDirectory(), copyDirectory(), copyElement(), createDir(), ElementsLocation::nameList(), removeDir(), and ElementsLocation::xml().
|
signal |
directoryRemoved This signal is emited when a directory is removed to this collection
collection_path,the | path of the removed directory |
Referenced by ElementsCollectionModel::addProject(), copyDirectory(), removeDir(), and ElementsCollectionModel::removeProject().
ElementsLocation XmlElementCollection::domToLocation | ( | QDomElement | dom_element | ) | const |
XmlElementCollection::domToLocation Return the element location who represent the xml element : dom_element dom_element must be owned by this collection.
dom_element | : the dom_element of this collection that represent an element. The tag name of dom_element must be "element" |
Definition at line 622 of file xmlelementcollection.cpp.
References m_dom_document, and m_project.
Referenced by cleanUnusedDirectory(), and elementsLocation().
QDomElement XmlElementCollection::element | ( | const QString & | path | ) | const |
XmlElementCollection::element.
path | : path of the element in this collection |
Definition at line 263 of file xmlelementcollection.cpp.
References child().
Referenced by copyDirectory(), copyElement(), removeElement(), and ElementsLocation::xml().
|
signal |
elementAdded This signal is emited when a element is added to this collection
collection_path,the | path of element in this collection |
Referenced by addElement(), addElementDefinition(), ElementsCollectionModel::addProject(), copyElement(), and ElementsCollectionModel::removeProject().
|
signal |
elementChanged This signal is emited when the defintion of the element at path was changed
collection_path,the | path of this element in this collection |
Referenced by ElementsCollectionModel::addProject(), copyElement(), and ElementsCollectionModel::removeProject().
|
signal |
elementRemoved This signal is emited when an element is removed to this collection
collection_path,the | path of the removed element in this collection |
Referenced by ElementsCollectionModel::addProject(), removeElement(), and ElementsCollectionModel::removeProject().
QList< QDomElement > XmlElementCollection::elements | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::elements.
parent_element |
Definition at line 221 of file xmlelementcollection.cpp.
References childs().
Referenced by elementsLocation(), elementsNames(), and XmlProjectElementCollectionItem::populate().
QList< ElementsLocation > XmlElementCollection::elementsLocation | ( | QDomElement | dom_element = QDomElement() , |
bool | childs = true |
||
) | const |
XmlElementCollection::elementsLocation Return all locations stored in dom_element (element and directory). If dom_element is null, return all location owned by this collection dom_element must be a child of this collection.
dom_element | : dom_element where we must to search location. |
childs | = if true return all childs location of dom_element, if false, only return the direct childs location of dom_element. |
Definition at line 580 of file xmlelementcollection.cpp.
References childs(), directories(), domToLocation(), elements(), ElementsLocation::exist(), and m_dom_document.
Referenced by QETProject::unusedElements().
QStringList XmlElementCollection::elementsNames | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::elementsNames.
parent_element |
Definition at line 242 of file xmlelementcollection.cpp.
References child(), childs(), and elements().
Referenced by ECHSXmlToFile::copyDirectory().
bool XmlElementCollection::exist | ( | const QString & | path | ) | const |
XmlElementCollection::exist Return true if the path exist in this collection.
path |
Definition at line 511 of file xmlelementcollection.cpp.
References child().
Referenced by addElement(), ElementsLocation::exist(), and QETProject::importElement().
QDomElement XmlElementCollection::importCategory | ( | ) | const |
XmlElementCollection::importCategory.
Definition at line 104 of file xmlelementcollection.cpp.
References root().
Referenced by addElement(), and cleanUnusedDirectory().
bool XmlElementCollection::removeDir | ( | const QString & | path | ) |
XmlElementCollection::removeDir Remove the directory at path .
path |
Definition at line 560 of file xmlelementcollection.cpp.
References directory(), and directoryRemoved().
Referenced by cleanUnusedDirectory().
bool XmlElementCollection::removeElement | ( | const QString & | path | ) |
XmlElementCollection::removeElement Remove the element at path .
path |
Definition at line 470 of file xmlelementcollection.cpp.
References element(), and elementRemoved().
Referenced by cleanUnusedElement().
QDomElement XmlElementCollection::root | ( | ) | const |
XmlElementCollection::root The root is the first DOM-Element the xml collection, the tag name of the dom element is : collection.
Definition at line 95 of file xmlelementcollection.cpp.
References m_dom_document.
Referenced by child(), importCategory(), XmlProjectElementCollectionItem::setProject(), and QETProject::toXml().
|
private |
Definition at line 102 of file xmlelementcollection.h.
Referenced by addElement(), addElementDefinition(), child(), childs(), copyDirectory(), copyElement(), createDir(), domToLocation(), elementsLocation(), root(), and XmlElementCollection().
|
private |
Definition at line 103 of file xmlelementcollection.h.
Referenced by cleanUnusedElement(), and domToLocation().