39 QDomElement collection =
m_dom_document.createElement(
"collection");
42 import.setAttribute(
"name",
"import");
43 collection.appendChild(
import);
47 const QChar russian_data[24] = { 0x0418, 0x043C, 0x043F, 0x043E, 0x0440, 0x0442, 0x0438, 0x0440, 0x043E, 0x0432, 0x0430, 0x043D, 0x043D, 0x044B, 0x0435, 0x0020, 0x044D, 0x043B, 0x0435, 0x043C, 0x0435, 0x043D, 0x0442, 0x044B };
48 const QChar greek_data[18] = { 0x0395, 0x03b9, 0x03c3, 0x03b7, 0x03b3, 0x03bc, 0x03ad, 0x03bd, 0x03b1, 0x0020, 0x03c3, 0x03c4, 0x03bf, 0x03b9, 0x03c7, 0x03b5, 0x03af, 0x03b1 };
49 const QChar turkish_data[12] ={ 0x0130, 0x0074, 0x0068, 0x0061, 0x006C, 0x0020, 0x00F6, 0x011F, 0x0065, 0x006C, 0x0065, 0x0072 };
50 names.
addName(
"fr",
"Éléments importés");
51 names.
addName(
"en",
"Imported elements");
52 names.
addName(
"de",
"Importierte elemente");
53 names.
addName(
"es",
"Elementos importados");
54 names.
addName(
"ru", QString(russian_data, 24));
55 names.
addName(
"cs",
"Zavedené prvky");
56 names.
addName(
"pl",
"Elementy importowane");
57 names.
addName(
"pt",
"elementos importados");
58 names.
addName(
"it",
"Elementi importati");
59 names.
addName(
"el", QString(greek_data, 18));
60 names.
addName(
"nl",
"Elementen geïmporteerd");
61 names.
addName(
"hr",
"Uvezeni elementi");
62 names.
addName(
"ca",
"Elements importats");
63 names.
addName(
"ro",
"Elemente importate");
64 names.
addName(
"tr", QString(turkish_data, 12));
65 names.
addName(
"da",
"Importerede elementer");
66 names.
addName(
"hr",
"Uvezeni elementi");
67 names.
addName(
"sl",
"Uvoženi elementi");
83 if (dom_element.tagName() ==
"collection")
86 qDebug() <<
"XmlElementCollection : tagName of dom_element is not collection";
105 return root().firstChildElement(
"category");
115 if (parent_element.ownerDocument() !=
m_dom_document)
return QDomNodeList();
116 return parent_element.childNodes();
130 if (parent_element.ownerDocument() !=
m_dom_document)
return QDomElement();
133 QDomNodeList child_list = parent_element.childNodes();
134 QString tag_name(child_name.endsWith(
".elmt")?
"element" :
"category");
135 QList <QDomElement> found_dom_element;
136 for (
int i=0 ; i<child_list.length() ; i++)
138 QDomElement child_element = child_list.item(i).toElement();
139 if (child_element.tagName() == tag_name) found_dom_element << child_element;
142 if (found_dom_element.isEmpty())
return QDomElement();
144 foreach (QDomElement elmt, found_dom_element)
145 if (elmt.attribute(
"name") == child_name)
148 return QDomElement();
158 QStringList path_list = path.split(
"/");
159 if (path_list.isEmpty())
return QDomElement();
161 QDomElement parent_element =
root();
162 foreach (QString str, path_list)
164 QDomElement child_element =
child(parent_element, str);
166 if (child_element.isNull())
167 return QDomElement();
169 parent_element = child_element;
172 return parent_element;
182 QList <QDomElement> directory_list;
183 QDomNodeList node_list =
childs(parent_element);
184 if (node_list.isEmpty())
return directory_list;
186 for (
int i=0 ; i < node_list.count() ; i++)
188 QDomNode node = node_list.at(i);
189 if (node.isElement() && node.toElement().tagName() ==
"category")
190 directory_list << node.toElement();
193 return directory_list;
208 QString name =
child.attribute(
"name");
223 QList <QDomElement> element_list;
224 QDomNodeList node_list =
childs(parent_element);
225 if (node_list.isEmpty())
return element_list;
227 for (
int i=0 ; i < node_list.count() ; i++)
229 QDomNode node = node_list.at(i);
230 if (node.isElement() && node.toElement().tagName() ==
"element")
231 element_list << node.toElement();
249 QString name =
child.attribute(
"name");
265 if (!path.endsWith(
".elmt"))
return QDomElement();
269 if (
element.tagName() ==
"element")
272 return QDomElement();
288 return QDomElement();
317 if (parent_element.isNull())
320 QString integrated_path = parent_element.attribute(
"name");
323 QStringList splitted_path = location.
collectionPath(
false).split(
"/");
324 if (splitted_path.isEmpty())
333 foreach(QString str, splitted_path) {
334 QDomElement child_element =
child(parent_element, str);
337 if (child_element.isNull()) {
338 QDomElement created_child;
341 if (str.endsWith(
".elmt")) {
342 QFile element_file(dir.filePath(str));
343 if (!element_file.exists())
358 if(created_child.isNull())
361 parent_element.appendChild(created_child);
362 parent_element = created_child;
369 parent_element = child_element;
372 integrated_path.append(
"/"+str);
377 foreach(QString str, splitted_path) {
381 path = path +
"/" + str;
383 QDomElement child_element =
child(parent_element, str);
386 if (child_element.isNull()) {
387 QDomElement created_child;
390 if (str.endsWith(
".elmt")) {
392 created_child.setAttribute(
"name", str);
394 created_child.appendChild(location.
xml().cloneNode(
true));
400 created_child.setAttribute(
"name", str);
404 created_child.appendChild(names_element);
407 if(created_child.isNull())
410 parent_element.appendChild(created_child);
411 parent_element = created_child;
415 parent_element = child_element;
417 integrated_path.append(
"/"+str);
422 return integrated_path;
437 QDomElement dom_dir =
directory(dir_path);
438 if (dom_dir.isNull()) {
439 qDebug() <<
"XmlElementCollection::addElementDefinition : No directory at path : " << dir_path;
443 if (xml_definition.tagName() !=
"definition") {
444 qDebug() <<
"XmlElementCollection::addElementDefinition : xml_defintion tag name is not \"definition\"";
448 QString name = elmt_name;
449 if (!name.endsWith(
".elmt")) {
454 dom_elmt.setAttribute(
"name", name);
455 dom_elmt.appendChild(xml_definition.cloneNode(
true));
456 dom_dir.appendChild(dom_elmt);
472 QDomElement elmt =
element(path);
474 if (!elmt.isNull()) {
475 elmt.parentNode().removeChild(elmt);
502 return copyDirectory(source, destination, rename, deep_copy);
513 if (
child(path).isNull())
530 QString new_dir_path = path +
"/" + name;
536 QDomElement parent_dir =
directory(path);
537 if (parent_dir.isNull()) {
538 qDebug() <<
"XmlElementCollection::createDir : directorie at path doesn't exist";
543 new_dir.setAttribute(
"name", name);
546 parent_dir.appendChild(new_dir);
564 dir.parentNode().removeChild(dir);
582 QList <ElementsLocation> location_list;
584 if (dom_element.isNull())
588 return location_list;
591 QList <QDomElement> element_list =
elements(dom_element);
593 foreach (QDomElement elmt, element_list) {
595 if (location.
exist())
596 location_list << location;
600 QList <QDomElement> directory_list =
directories(dom_element);
602 foreach (QDomElement dir, directory_list) {
604 if (location.
exist())
605 location_list << location;
611 return location_list;
625 QString path = dom_element.attribute(
"name");
627 while (!dom_element.parentNode().isNull() && dom_element.parentNode().isElement()) {
628 dom_element = dom_element.parentNode().toElement();
630 if (dom_element.tagName() ==
"category")
631 path.prepend(dom_element.attribute(
"name") +
"/");
656 QDomNodeList lst =
importCategory().elementsByTagName(
"category");
658 for(
int i=0 ; i<lst.size() ; i++) {
659 QDomElement dir = lst.item(i).toElement();
661 if (dir.elementsByTagName(
"element").isEmpty() && dir.elementsByTagName(
"category").isEmpty()) {
680 QString new_dir_name = rename.isEmpty() ? source.
fileName() : rename;
706 parent_dir_dom.appendChild(elmt_dom);
713 foreach(QString str, source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
720 source_dir.setNameFilters(QStringList() <<
"*.elmt");
721 foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
739 if (!names.isNull() && names.isElement())
740 other_collection_node.appendChild(names.cloneNode(
true));
745 QDomElement other_collection_dom_dir = other_collection_node.toElement();
746 other_collection_dom_dir.setAttribute(
"name", new_dir_name);
747 parent_dir_dom.appendChild(other_collection_dom_dir);
753 return created_location;
767 QString new_elmt_name = rename.isEmpty() ? source.
fileName() : rename;
769 QDomElement elmt_dom;
781 QDomElement other_collection = source.
xml();
783 elmt_dom.setAttribute(
"name", new_elmt_name);
784 elmt_dom.appendChild(other_collection.cloneNode());
790 bool removed =
false;
799 dir_dom.appendChild(elmt_dom);
QStringList directoriesNames(const QDomElement &parent_element) const
XmlElementCollection::directoriesNames.
QString projectCollectionPath() const
ElementsLocation::projectCollectionPath.
bool removeDir(const QString &path)
XmlElementCollection::removeDir Remove the directory at path .
QList< ElementsLocation > unusedElements() const
QETProject::unusedElements.
bool isProject() const
ElementsLocation::isProject.
NamesList nameList()
ElementsLocation::nameList.
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 dest...
void directorieAdded(QString collection_path)
directorieAdded This signal is emited when a directorie is added to this collection ...
bool createDir(const QString &path, const QString &name, const NamesList &name_list)
ElementsLocation domToLocation(QDomElement dom_element) const
XmlElementCollection::domToLocation Return the element location who represent the xml element : dom_e...
bool isFileSystem() const
ElementsLocation::isFileSystem.
QDomElement child(const QDomElement &parent_element, const QString &child_name) const
XmlElementCollection::child If parent_element have child element with an attribute name = ...
void elementAdded(QString collection_path)
elementAdded This signal is emited when a element is added to this collection
QDomDocument m_dom_document
QString fileName() const
ElementLocation::fileName.
QDomElement root() const
XmlElementCollection::root The root is the first DOM-Element the xml collection, the tag name of the ...
QDomElement toXml(QDomDocument &, const QHash< QString, QString > &=QHash< QString, QString >()) const
void cleanUnusedDirectory()
XmlElementCollection::cleanUnusedDirectory Remove the empty directories of this collection.
QStringList elementsNames(const QDomElement &parent_element) const
XmlElementCollection::elementsNames.
QDomElement element(const QString &path) const
XmlElementCollection::element.
void addName(const QString &, const QString &)
bool exist(const QString &path) const
XmlElementCollection::exist Return true if the path exist in this collection.
QList< QDomElement > directories(const QDomElement &parent_element) const
XmlElementCollection::directories.
XmlElementCollection * projectCollection() const
ElementsLocation::projectCollection.
QList< ElementsLocation > elementsLocation(QDomElement dom_element=QDomElement(), bool childs=true) const
XmlElementCollection::elementsLocation Return all locations stored in dom_element (element and direct...
QList< QDomElement > elements(const QDomElement &parent_element) const
XmlElementCollection::elements.
void elementChanged(QString collection_path)
elementChanged This signal is emited when the defintion of the element at path was changed ...
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString &rename=QString())
XmlElementCollection::copyElement Copy the element represented by source to destination (must be a di...
void setPath(const QString &path)
ElementsLocation::setPath Set the path of this item. The path can be relative to a collection (start ...
QDomElement directory(const QString &path) const
XmlElementCollection::directory.
QETProject * project() const
QString collectionPath(bool protocol=true) const
void elementRemoved(QString collection_path)
elementRemoved This signal is emited when an element is removed to this collection ...
void cleanUnusedElement()
XmlElementCollection::cleanUnusedElement Remove elements in this collection which is not used in the ...
QDomElement xml() const
ElementsLocation::xml.
QDomElement fileSystemDirToXmlCollectionDir(QDomDocument &document, const QDir &dir, const QString &rename=QString())
bool removeElement(const QString &path)
XmlElementCollection::removeElement Remove the element at path .
bool exist() const
ElementsLocation::exist.
QString fileSystemPath() const
ElementsLocation::fileSystemPath.
QString addElement(ElementsLocation &location)
XmlElementCollection::addElement Add the element at location to this collection. The element is copie...
bool isDirectory() const
ElementsLocation::isDirectory.
void directoryRemoved(QString collection_path)
directoryRemoved This signal is emited when a directory is removed to this collection ...
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 ...
QDomElement fileSystemElementToXmlCollectionElement(QDomDocument &document, QFile &file, const QString &rename=QString())
bool isElement() const
ElementsLocation::isElement.
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.
QDomNodeList childs(const QDomElement &parent_element) const
XmlElementCollection::childs.
XmlElementCollection(QETProject *project)
XmlElementCollection::XmlElementCollection Build an empty collection. The collection start by : <coll...
QDomElement importCategory() const
XmlElementCollection::importCategory.