QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
XmlElementCollection Class Reference

The XmlElementCollection class This class represent a collection of elements stored to xml. More...

#include <xmlelementcollection.h>

Inherits QObject.

Collaboration diagram for XmlElementCollection:
Collaboration graph

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< ElementsLocationelementsLocation (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
 
QETProjectm_project = nullptr
 

Detailed Description

The XmlElementCollection class This class represent a collection of elements stored to xml.

Constructor & Destructor Documentation

◆ XmlElementCollection() [1/2]

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>

Parameters
project: the project of this collection
Here is the call graph for this function:

◆ XmlElementCollection() [2/2]

XmlElementCollection::XmlElementCollection ( const QDomElement &  dom_element,
QETProject project 
)

XmlElementCollection::XmlElementCollection Constructor with an collection. The tagName of dom_element must be "collection".

Parameters
dom_element: -the collection in a dom_element (the dom element in cloned)
project: the project of this collection

Member Function Documentation

◆ addElement()

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.

Parameters
location: location of the element
Returns
the collection path of the added item or a null QString if element can't be added.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addElementDefinition()

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.

Parameters
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".
Returns
True if the element is added with success.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ child() [1/2]

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")

Parameters
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.
Returns
The child QDomElement or a null QDomElement if not found
Here is the caller graph for this function:

◆ child() [2/2]

QDomElement XmlElementCollection::child ( const QString &  path) const

XmlElementCollection::child.

Parameters
path
Returns
the DomElement at path if exist, else return a null QDomElement
Here is the call graph for this function:

◆ childs()

QDomNodeList XmlElementCollection::childs ( const QDomElement &  parent_element) const

XmlElementCollection::childs.

Parameters
parent_element
Returns
All childs element in the parent_element tree
Here is the caller graph for this function:

◆ cleanUnusedDirectory()

void XmlElementCollection::cleanUnusedDirectory ( )

XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanUnusedElement()

void XmlElementCollection::cleanUnusedElement ( )

XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the owner project.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy()

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.

Parameters
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)
Returns
the ElementLocation that represent the copy, if copy failed return a null ElementLocation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyDirectory()

ElementsLocation XmlElementCollection::copyDirectory ( ElementsLocation source,
ElementsLocation destination,
const QString &  rename = QString(),
bool  deep_copy = true 
)
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.

Parameters
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
Returns
the ElementLocation that represent the copy, if copy failed return a null ElementLocation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyElement()

ElementsLocation XmlElementCollection::copyElement ( ElementsLocation source,
ElementsLocation destination,
const QString &  rename = QString() 
)
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.

Parameters
source: element to copy
destination: destination of the copy
rename: rename the copy with rename else use the name of source
Returns
The ElementsLocation of the copy
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDir()

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.

Parameters
path: path of parent diectorie
name: name of the directori to create.
name_list: translation of the directory name.
Returns
true if creation success, if directory already exists, return true.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ directorieAdded

void XmlElementCollection::directorieAdded ( QString  collection_path)
signal

directorieAdded This signal is emitted when a directory is added to this collection

Parameters
collection_path: the path of the new directory
Here is the caller graph for this function:

◆ directories()

QList< QDomElement > XmlElementCollection::directories ( const QDomElement &  parent_element) const

XmlElementCollection::directories.

Parameters
parent_element
Returns
A list of directory stored in parent_element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ directoriesNames()

QStringList XmlElementCollection::directoriesNames ( const QDomElement &  parent_element) const

XmlElementCollection::directoriesNames.

Parameters
parent_element
Returns
a list of names for every child directories of parent_element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ directory()

QDomElement XmlElementCollection::directory ( const QString &  path) const

XmlElementCollection::directory.

Parameters
path: path of the directory in this collection
Returns
the QDomElement that represent the directory at path path or a null QDomElement if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ directoryRemoved

void XmlElementCollection::directoryRemoved ( QString  collection_path)
signal

directoryRemoved This signal is emitted when a directory is removed from this collection

Parameters
collection_path: the path of the removed directory
Here is the caller graph for this function:

◆ domToLocation()

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.

Parameters
dom_element: the dom_element of this collection that represent an element. The tag name of dom_element must be "element"
Returns
the element location, location can be null if fail.
Here is the caller graph for this function:

◆ element()

QDomElement XmlElementCollection::element ( const QString &  path) const

XmlElementCollection::element.

Parameters
path: path of the element in this collection
Returns
the QDomElement that represent the element at path path or a null QDomElement if not found or doesn't represent an element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ elementAdded

void XmlElementCollection::elementAdded ( QString  collection_path)
signal

elementAdded This signal is emitted when a element is added to this collection

Parameters
collection_path: the path of element in this collection
Here is the caller graph for this function:

◆ elementChanged

void XmlElementCollection::elementChanged ( QString  collection_path)
signal

elementChanged This signal is emitted when the definition of the element at path was changed

Parameters
collection_path: the path of this element in this collection
Here is the caller graph for this function:

◆ elementRemoved

void XmlElementCollection::elementRemoved ( QString  collection_path)
signal

elementRemoved This signal is emitted when an element is removed from this collection

Parameters
collection_path: the path of the removed element in this collection
Here is the caller graph for this function:

◆ elements()

QList< QDomElement > XmlElementCollection::elements ( const QDomElement &  parent_element) const

XmlElementCollection::elements.

Parameters
parent_element
Returns
A list of element stored in parent_element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ elementsLocation()

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.

Parameters
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.
Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ elementsNames()

QStringList XmlElementCollection::elementsNames ( const QDomElement &  parent_element) const

XmlElementCollection::elementsNames.

Parameters
parent_element
Returns
A list of names fr every childs element of parent_element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exist()

bool XmlElementCollection::exist ( const QString &  path) const

XmlElementCollection::exist Return true if the path path exist in this collection.

Parameters
path
Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ importCategory()

QDomElement XmlElementCollection::importCategory ( ) const

XmlElementCollection::importCategory.

Returns
The QDomElement import (the beginning of an xml collection) or a null QDomElement if doesn't exist.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeDir()

bool XmlElementCollection::removeDir ( const QString &  path)

XmlElementCollection::removeDir Remove the directory at path path.

Parameters
path
Returns
true if successfully removed and emit directoryRemoved(QString), else false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeElement()

bool XmlElementCollection::removeElement ( const QString &  path)

XmlElementCollection::removeElement Remove the element at path path.

Parameters
path
Returns
True if element is removed and emit the signal elementRemoved. else false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ root()

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.

Returns
The root QDomElement of the collection
Here is the caller graph for this function:

Member Data Documentation

◆ m_dom_document

QDomDocument XmlElementCollection::m_dom_document
private

◆ m_project

QETProject* XmlElementCollection::m_project = nullptr
private

The documentation for this class was generated from the following files: