QElectroTech
0.8-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 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 : More... | |
XmlElementCollection (const QDomElement &dom_element, QETProject *project) | |
XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of dom_element 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 = 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") 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 xml_definition in the directory at path dir_path with the name elmt_name. More... | |
bool | removeElement (const QString &path) |
XmlElementCollection::removeElement Remove the element at path 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 path exist in this collection. More... | |
bool | createDir (const QString &path, const QString &name, const NamesList &name_list) |
XmlElementCollection::createDir Create a child directorie at path path with the name name. Emit directorieAdded if success. More... | |
bool | removeDir (const QString &path) |
XmlElementCollection::removeDir Remove the directory at path 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... | |
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. 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... | |
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 élément defintion 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 directorie 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 directorie name. |
|
signal |
directorieAdded This signal is emited when a directorie is added to this collection
collection_path | : the path of the new directorie |
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 emited when a directory is removed to 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 emited when a element is added to this collection
collection_path | : the path of element in this collection |
|
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 |
|
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 |
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 to 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 |