From 408481a023b92440bf0067f9922412d42256d12d Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:11:37 +0100 Subject: [PATCH] =?UTF-8?q?some=20clean-up=20for=20"elementInformations"?= =?UTF-8?q?=20in=20element-file=20-=20for=20some=20time=20now=20and=20for?= =?UTF-8?q?=20whatever=20reason,=20element-editor=20=20=20sometimes=20adds?= =?UTF-8?q?=20element-information=20without=20content=20=E2=80=93>=20do=20?= =?UTF-8?q?not=20=20=20save=20info-lines=20without=20any=20content=20-=20s?= =?UTF-8?q?ort=20element-information=20alphabetically=20by=20name=20in=20e?= =?UTF-8?q?lement-file=20-=20use=20trimmed=20strings=20for=20element-infor?= =?UTF-8?q?mation=20to=20remove=20leading=20=20=20and=20trailing=20whitest?= =?UTF-8?q?pace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/diagramcontext.cpp | 8 ++++++-- sources/diagramcontext.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) 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);