diff --git a/sources/diagramcontext.cpp b/sources/diagramcontext.cpp index 5a1f74744..864ad9b3a 100644 --- a/sources/diagramcontext.cpp +++ b/sources/diagramcontext.cpp @@ -151,10 +151,14 @@ bool DiagramContext::operator!=(const DiagramContext &dc) const void DiagramContext::toXml(QDomElement &e, const QString &tag_name) const { foreach (QString key, keys()) { + if (m_content[key].toString().trimmed().isEmpty()) { continue; } QDomElement property = e.ownerDocument().createElement(tag_name); + // try to sort attributes by removing and re-adding + property.removeAttribute("show"); + property.removeAttribute("name"); + property.setAttribute("show", m_content_show[key]); property.setAttribute("name", key); - property.setAttribute("show",m_content_show[key]); - QDomText value = e.ownerDocument().createTextNode(m_content[key].toString()); + QDomText value = e.ownerDocument().createTextNode(m_content[key].toString().trimmed()); property.appendChild(value); e.appendChild(property); } diff --git a/sources/diagramcontext.h b/sources/diagramcontext.h index be3d19932..d04104345 100644 --- a/sources/diagramcontext.h +++ b/sources/diagramcontext.h @@ -99,7 +99,7 @@ class DiagramContext void add(DiagramContext other); void remove(const QString &key); - QList keys(KeyOrder = None) const; + QList keys(KeyOrder = Alphabetical) const; bool contains(const QString &) const; const QVariant operator[](const QString &) const; bool addValue(const QString &, const QVariant &, bool show = true);