Overridden properties of terminal elements are now saved/loaded from project

The overridden properties of terminal elements made in the terminal
strip dialog are now saved and loaded from/to the project file.
This commit is contained in:
joshua
2021-09-20 18:34:48 +02:00
parent 67dbc798aa
commit 377f8b1521
10 changed files with 125 additions and 29 deletions

View File

@@ -33,6 +33,7 @@
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "iostream"
#include "../qetxml.h"
#include <QDomElement>
#include <utility>
@@ -846,6 +847,28 @@ bool Element::fromXml(QDomElement &e,
dc.fromXml(e.firstChildElement(QStringLiteral("elementInformations")),
QStringLiteral("elementInformation"));
//Load override properties (For now, only used when the element is a terminal)
if (m_data.m_type == ElementData::Terminale)
{
if (auto elmt_type_list = QETXML::subChild(e, QStringLiteral("properties"), QStringLiteral("element_type")) ;
elmt_type_list.size())
{
auto elmt_type = elmt_type_list.first();
m_data.setTerminalType(
m_data.terminalTypeFromString(
elmt_type.attribute(QStringLiteral("terminal_type"))));
m_data.setTerminalFunction(
m_data.terminalFunctionFromString(
elmt_type.attribute(QStringLiteral("terminal_function"))));
m_data.setTerminalLED(
QETXML::boolFromString(
elmt_type.attribute(QStringLiteral("terminal_led")), false));
}
}
//We must to block the update of the alignment when load the information
//otherwise the pos of the text will not be the same as it was at save time.
for(DynamicElementTextItem *deti : m_dynamic_text_list)
@@ -955,6 +978,23 @@ QDomElement Element::toXml(
element.appendChild(infos);
}
//Save override properties (For now, only used when the element is a terminal)
if (m_data.m_type == ElementData::Terminale)
{
QDomElement properties = document.createElement(QStringLiteral("properties"));
QDomElement element_type = document.createElement(QStringLiteral("element_type"));
element_type.setAttribute(QStringLiteral("terminal_type"),
m_data.terminalTypeToString(m_data.terminalType()));
element_type.setAttribute(QStringLiteral("terminal_function"),
m_data.terminalFunctionToString(m_data.terminalFunction()));
element_type.setAttribute(QStringLiteral("terminal_led"),
QETXML::boolToString(m_data.terminalLed()));
properties.appendChild(element_type);
element.appendChild(properties);
}
//Dynamic texts
QDomElement dyn_text = document.createElement(QStringLiteral("dynamic_texts"));
for (DynamicElementTextItem *deti : m_dynamic_text_list)