QElectroTech 0.100.0-dev
|
The XmlElementCollection class This class represent a collection of elements stored to xml. More...
#include <xmlelementcollection.h>
Inherits QObject.
Signals | |
void | elementAdded (QString collection_path) |
elementAdded This signal is emitted when a element is added to this collection | |
void | elementChanged (QString collection_path) |
elementChanged This signal is emitted when the definition of the element at path was changed | |
void | elementRemoved (QString collection_path) |
elementRemoved This signal is emitted when an element is removed from this collection | |
void | directorieAdded (QString collection_path) |
directorieAdded This signal is emitted when a directory is added to this collection | |
void | directoryRemoved (QString collection_path) |
directoryRemoved This signal is emitted when a directory is removed from this collection | |
Public Member Functions | |
XmlElementCollection (QETProject *project) | |
XmlElementCollection::XmlElementCollection Build an empty collection. The collection start by : | |
XmlElementCollection (const QDomElement &dom_element, QETProject *project) | |
XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of dom_element must be "collection". | |
QDomElement | root () const |
XmlElementCollection::root The root is the first DOM-Element the xml collection, the tag name of the dom element is : collection. | |
QDomElement | importCategory () const |
XmlElementCollection::importCategory. | |
QDomNodeList | childs (const QDomElement &parent_element) const |
XmlElementCollection::childs. | |
QDomElement | child (const QDomElement &parent_element, const QString &child_name) const |
XmlElementCollection::child If parent_element have child element with an attribute name = child_name, return it, else return a null QDomElement. Only search for element with tag-name "category" and "element" (if child_name end with ".elmt") | |
QDomElement | child (const QString &path) const |
XmlElementCollection::child. | |
QList< QDomElement > | directories (const QDomElement &parent_element) const |
XmlElementCollection::directories. | |
QStringList | directoriesNames (const QDomElement &parent_element) const |
XmlElementCollection::directoriesNames. | |
QList< QDomElement > | elements (const QDomElement &parent_element) const |
XmlElementCollection::elements. | |
QStringList | elementsNames (const QDomElement &parent_element) const |
XmlElementCollection::elementsNames. | |
QDomElement | element (const QString &path) const |
XmlElementCollection::element. | |
QDomElement | directory (const QString &path) const |
XmlElementCollection::directory. | |
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. | |
bool | addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition) |
XmlElementCollection::addElementDefinition Add the element definition xml_definition in the directory at path dir_path with the name elmt_name. | |
bool | removeElement (const QString &path) |
XmlElementCollection::removeElement Remove the element at path path. | |
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. | |
bool | exist (const QString &path) const |
XmlElementCollection::exist Return true if the path path exist in this collection. | |
bool | createDir (const QString &path, const QString &name, const NamesList &name_list) |
XmlElementCollection::createDir Create a child directory at path path with the name name. Emit directorieAdded if success. | |
bool | removeDir (const QString &path) |
XmlElementCollection::removeDir Remove the directory at path path. | |
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. | |
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. | |
void | cleanUnusedElement () |
XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the owner project. | |
void | cleanUnusedDirectory () |
XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection. | |
Private Member Functions | |
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. | |
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. | |
Private Attributes | |
QDomDocument | m_dom_document |
QETProject * | m_project = nullptr |
The XmlElementCollection class This class represent a collection of elements stored to xml.
XmlElementCollection::XmlElementCollection | ( | QETProject * | project | ) |
XmlElementCollection::XmlElementCollection Build an empty collection. The collection start by :
All elements and category are stored as child of <category name="import>
project | : the project of this collection |
XmlElementCollection::XmlElementCollection | ( | const QDomElement & | dom_element, |
QETProject * | project | ||
) |
XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of dom_element must be "collection".
dom_element | : -the collection in a dom_element (the dom element in cloned) |
project | : the project of this collection |
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 |
bool XmlElementCollection::addElementDefinition | ( | const QString & | dir_path, |
const QString & | elmt_name, | ||
const QDomElement & | xml_definition | ||
) |
XmlElementCollection::addElementDefinition Add the element definition xml_definition in the directory at path dir_path with the name elmt_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 elmt_name) |
xml_definition | : The xml definition of the element. The tag name of xml_definition must be "definition". |
QDomElement XmlElementCollection::child | ( | const QDomElement & | parent_element, |
const QString & | child_name | ||
) | const |
XmlElementCollection::child If parent_element have child element with an attribute name = child_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. parent_element must be a child node of this XmlElementCollection. |
child_name | : name of child to search. |
QDomElement XmlElementCollection::child | ( | const QString & | path | ) | const |
path |
QDomNodeList XmlElementCollection::childs | ( | const QDomElement & | parent_element | ) | const |
parent_element |
void XmlElementCollection::cleanUnusedDirectory | ( | ) |
XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection.
void XmlElementCollection::cleanUnusedElement | ( | ) |
XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the owner project.
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 rename else use the name of source |
deep_copy | : if true copy all childs of source (only if source is directory) |
|
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 rename else use the name of source |
deep_copy | :if true copy all childs of source |
|
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 rename else use the name of source |
bool XmlElementCollection::createDir | ( | const QString & | path, |
const QString & | name, | ||
const NamesList & | name_list | ||
) |
XmlElementCollection::createDir Create a child directory at path path with the name name. Emit directorieAdded if success.
path | : path of parent diectorie |
name | : name of the directori to create. |
name_list | : translation of the directory name. |
|
signal |
directorieAdded This signal is emitted when a directory is added to this collection
collection_path | : the path of the new directory |
QList< QDomElement > XmlElementCollection::directories | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::directories.
parent_element |
QStringList XmlElementCollection::directoriesNames | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::directoriesNames.
parent_element |
QDomElement XmlElementCollection::directory | ( | const QString & | path | ) | const |
XmlElementCollection::directory.
path | : path of the directory in this collection |
|
signal |
directoryRemoved This signal is emitted when a directory is removed from this collection
collection_path | : the path of the removed directory |
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" |
QDomElement XmlElementCollection::element | ( | const QString & | path | ) | const |
XmlElementCollection::element.
path | : path of the element in this collection |
|
signal |
elementAdded This signal is emitted when a element is added to this collection
collection_path | : the path of element in this collection |
|
signal |
elementChanged This signal is emitted when the definition of the element at path was changed
collection_path | : the path of this element in this collection |
|
signal |
elementRemoved This signal is emitted when an element is removed from this collection
collection_path | : the path of the removed element in this collection |
QList< QDomElement > XmlElementCollection::elements | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::elements.
parent_element |
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 search location. |
childs | = if true return all childs location of dom_element, if false, only return the direct childs location of dom_element. |
QStringList XmlElementCollection::elementsNames | ( | const QDomElement & | parent_element | ) | const |
XmlElementCollection::elementsNames.
parent_element |
bool XmlElementCollection::exist | ( | const QString & | path | ) | const |
XmlElementCollection::exist Return true if the path path exist in this collection.
path |
QDomElement XmlElementCollection::importCategory | ( | ) | const |
XmlElementCollection::importCategory.
bool XmlElementCollection::removeDir | ( | const QString & | path | ) |
XmlElementCollection::removeDir Remove the directory at path path.
path |
bool XmlElementCollection::removeElement | ( | const QString & | path | ) |
XmlElementCollection::removeElement Remove the element at path path.
path |
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.
|
private |
|
private |