mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-07-31 08:34:13 +02:00
Feature: Add terminal name label display in element editor
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "terminaldata.h"
|
||||
|
||||
#include <QGraphicsObject>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
TerminalData::TerminalData():
|
||||
@@ -110,6 +111,20 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
|
||||
xml_element.setAttribute("type", typeToString(m_type));
|
||||
|
||||
if (m_show_name) {
|
||||
xml_element.setAttribute("show_name", "true");
|
||||
xml_element.setAttribute("label_x", QString::number(m_label_pos.x()));
|
||||
xml_element.setAttribute("label_y", QString::number(m_label_pos.y()));
|
||||
xml_element.setAttribute("label_font", m_label_font.toString());
|
||||
xml_element.setAttribute("label_rotation", QString::number(m_label_rotation));
|
||||
xml_element.setAttribute("label_halign", static_cast<int>(m_label_halignment));
|
||||
xml_element.setAttribute("label_valign", static_cast<int>(m_label_valignment));
|
||||
if (m_label_frame)
|
||||
xml_element.setAttribute("label_frame", "true");
|
||||
if (m_label_color != QColor(Qt::black))
|
||||
xml_element.setAttribute("label_color", m_label_color.name());
|
||||
}
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
@@ -157,6 +172,31 @@ bool TerminalData::fromXml (const QDomElement &xml_element)
|
||||
|
||||
m_type = typeFromString(xml_element.attribute("type"));
|
||||
|
||||
m_show_name = (xml_element.attribute("show_name") == QLatin1String("true"));
|
||||
if (m_show_name) {
|
||||
qreal lx = xml_element.attribute("label_x", "0").toDouble();
|
||||
qreal ly = xml_element.attribute("label_y", "0").toDouble();
|
||||
m_label_pos = QPointF(lx, ly);
|
||||
|
||||
QString font_str = xml_element.attribute("label_font");
|
||||
if (!font_str.isEmpty())
|
||||
m_label_font.fromString(font_str);
|
||||
|
||||
m_label_rotation = xml_element.attribute("label_rotation", "0").toDouble();
|
||||
|
||||
int ha = xml_element.attribute("label_halign", "0").toInt();
|
||||
m_label_halignment = static_cast<Qt::Alignment>(ha);
|
||||
|
||||
int va = xml_element.attribute("label_valign", "0").toInt();
|
||||
m_label_valignment = static_cast<Qt::Alignment>(va);
|
||||
|
||||
m_label_frame = (xml_element.attribute("label_frame") == QLatin1String("true"));
|
||||
|
||||
QString color_str = xml_element.attribute("label_color");
|
||||
if (!color_str.isEmpty())
|
||||
m_label_color = QColor(color_str);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user