From eb7ff07feb54247726cb2d8f46cf997530b4491f Mon Sep 17 00:00:00 2001 From: blacksun Date: Sun, 3 Apr 2016 17:01:44 +0000 Subject: [PATCH] Fix regression with embedded element collection git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4420 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- .../xmlelementcollection.cpp | 92 +++++++------------ 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/sources/ElementsCollection/xmlelementcollection.cpp b/sources/ElementsCollection/xmlelementcollection.cpp index 04b0e08d5..608837736 100644 --- a/sources/ElementsCollection/xmlelementcollection.cpp +++ b/sources/ElementsCollection/xmlelementcollection.cpp @@ -72,9 +72,10 @@ XmlElementCollection::XmlElementCollection(QObject *parent) : XmlElementCollection::XmlElementCollection(const QDomElement &dom_element, QObject *parent) : QObject(parent) { - QDomElement collection = m_dom_document.createElement("collection"); - m_dom_document.appendChild(collection); - collection.appendChild(dom_element.firstChildElement("category").cloneNode(true)); + if (dom_element.tagName() == "collection") + m_dom_document.appendChild(m_dom_document.importNode(dom_element, true)); + else + qDebug() << "XmlElementCollection : tagName of dom_element is not collection"; } /** @@ -142,20 +143,25 @@ QDomElement XmlElementCollection::child(const QDomElement &parent_element, const /** * @brief XmlElementCollection::child * @param path - * @return the DomElement at path if exist. Else return a null QDomElement + * @return the DomElement at path if exist, else return a null QDomElement */ QDomElement XmlElementCollection::child(const QString &path) const { QStringList path_list = path.split("/"); - if (path_list.first() != "import") return QDomElement(); - path_list.removeFirst(); + if (path_list.isEmpty()) return QDomElement(); - QDomElement dom_element = importCategory(); + QDomElement parent_element = root(); + foreach (QString str, path_list) + { + QDomElement child_element = child(parent_element, str); - for (int i=0 ; i