mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Revert "Merge branch 'XMLPropertiesNew'"
**Break a lot of thing.** This reverts commit1db1800572, reversing changes made to4c563821e8.
This commit is contained in:
@@ -20,16 +20,14 @@
|
||||
#include <QMetaEnum>
|
||||
#include <QRegularExpression>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "qetxml.h"
|
||||
|
||||
namespace {
|
||||
const QString conductorPropertiesXmlName = "conductorProperties";
|
||||
}
|
||||
/**
|
||||
Constructeur par defaut
|
||||
*/
|
||||
SingleLineProperties::SingleLineProperties(): PropertiesInterface("SingleLine")
|
||||
SingleLineProperties::SingleLineProperties() :
|
||||
hasGround(true),
|
||||
hasNeutral(true),
|
||||
is_pen(false),
|
||||
phases(1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -125,9 +123,9 @@ void SingleLineProperties::draw(QPainter *painter,
|
||||
@param size taille du segment
|
||||
*/
|
||||
void SingleLineProperties::drawGround(QPainter *painter,
|
||||
QET::ConductorSegmentType direction,
|
||||
QPointF center,
|
||||
qreal size) {
|
||||
QET::ConductorSegmentType direction,
|
||||
QPointF center,
|
||||
qreal size) {
|
||||
painter -> save();
|
||||
|
||||
// prepare le QPainter
|
||||
@@ -217,12 +215,12 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
||||
ajoutes a l'element e.
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
void SingleLineProperties::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
e.setAttribute("ground", hasGround ? "true" : "false");
|
||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
||||
e.setAttribute("phase", phases);
|
||||
if (isPen()) e.setAttribute("pen", "true");
|
||||
void SingleLineProperties::toXml(QDomElement &e) const
|
||||
{
|
||||
e.setAttribute("ground", hasGround ? "true" : "false");
|
||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
||||
e.setAttribute("phase", phases);
|
||||
if (isPen()) e.setAttribute("pen", "true");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,36 +228,11 @@ void SingleLineProperties::toXmlPriv(QDomElement& e) const {
|
||||
de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
bool SingleLineProperties::fromXmlPriv(const QDomElement &e) {
|
||||
if (QETXML::propertyBool(e, "ground", &hasGround) != QETXML::PropertyFlags::Success ||
|
||||
QETXML::propertyBool(e, "neutral", &hasNeutral) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
int phase;
|
||||
if (QETXML::propertyInteger(e, "phase", &phase) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
setPhasesCount(phase);
|
||||
|
||||
bool pen;
|
||||
if (QETXML::propertyBool(e, "pen", &pen) != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
is_pen = (hasGround && hasNeutral && pen);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SingleLineProperties::valideXml(QDomElement& e) {
|
||||
if (QETXML::propertyBool(e, "ground") != QETXML::PropertyFlags::Success ||
|
||||
QETXML::propertyBool(e, "neutral") != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyInteger(e, "phase") != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
if (QETXML::propertyBool(e, "pen") != QETXML::PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
void SingleLineProperties::fromXml(QDomElement &e) {
|
||||
hasGround = e.attribute("ground") == "true";
|
||||
hasNeutral = e.attribute("neutral") == "true";
|
||||
setPhasesCount(e.attribute("phase").toInt());
|
||||
is_pen = (hasGround && hasNeutral && e.attribute("pen", "false") == "true");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +240,17 @@ bool SingleLineProperties::valideXml(QDomElement& e) {
|
||||
multifilaire noir dont le texte est "_"
|
||||
*/
|
||||
ConductorProperties::ConductorProperties() :
|
||||
PropertiesInterface(xmlTagName())
|
||||
type(Multi),
|
||||
color(Qt::black),
|
||||
text_color(Qt::black),
|
||||
text("_"),
|
||||
text_size(9),
|
||||
cond_size(1),
|
||||
verti_rotate_text(270),
|
||||
horiz_rotate_text(0),
|
||||
m_show_text(true),
|
||||
m_one_text_per_folio(false),
|
||||
style(Qt::SolidLine)
|
||||
{}
|
||||
|
||||
/**
|
||||
@@ -283,143 +266,108 @@ ConductorProperties::~ConductorProperties()
|
||||
Export conductor propertie, in the XML element 'e'
|
||||
@param e the xml element
|
||||
*/
|
||||
void ConductorProperties::toXmlPriv(QDomElement& e) const
|
||||
void ConductorProperties::toXml(QDomElement &e) const
|
||||
{
|
||||
e.setAttribute("type", typeToString(type));
|
||||
|
||||
e.setAttribute("type", typeToString(type));
|
||||
if (color != QColor(Qt::black))
|
||||
e.setAttribute("color", color.name());
|
||||
|
||||
if (color != QColor(Qt::black))
|
||||
e.setAttribute("color", color.name());
|
||||
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
||||
e.setAttribute("color2", m_color_2.name());
|
||||
e.setAttribute("dash-size", QString::number(m_dash_size));
|
||||
|
||||
e.setAttribute("bicolor", m_bicolor? "true" : "false");
|
||||
e.setAttribute("color2", m_color_2.name());
|
||||
e.setAttribute("dash-size", QString::number(m_dash_size));
|
||||
if (type == Single)
|
||||
singleLineProperties.toXml(e);
|
||||
|
||||
if (type == Single)
|
||||
{
|
||||
QDomDocument doc = e.ownerDocument();
|
||||
singleLineProperties.toXml(doc);
|
||||
}
|
||||
e.setAttribute("num", text);
|
||||
e.setAttribute("text_color", text_color.name());
|
||||
e.setAttribute("formula", m_formula);
|
||||
e.setAttribute("cable", m_cable);
|
||||
e.setAttribute("bus", m_bus);
|
||||
e.setAttribute("function", m_function);
|
||||
e.setAttribute("tension_protocol", m_tension_protocol);
|
||||
e.setAttribute("conductor_color", m_wire_color);
|
||||
e.setAttribute("conductor_section", m_wire_section);
|
||||
e.setAttribute("numsize", QString::number(text_size));
|
||||
e.setAttribute("condsize", QString::number(cond_size));
|
||||
e.setAttribute("displaytext", m_show_text);
|
||||
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
||||
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
||||
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
||||
|
||||
e.setAttribute("num", text);
|
||||
e.setAttribute("text_color", text_color.name());
|
||||
e.setAttribute("formula", m_formula);
|
||||
e.setAttribute("cable", m_cable);
|
||||
e.setAttribute("bus", m_bus);
|
||||
e.setAttribute("function", m_function);
|
||||
e.setAttribute("tension_protocol", m_tension_protocol);
|
||||
e.setAttribute("conductor_color", m_wire_color);
|
||||
e.setAttribute("conductor_section", m_wire_section);
|
||||
e.setAttribute("numsize", QString::number(text_size));
|
||||
e.setAttribute("condsize", QString::number(cond_size));
|
||||
e.setAttribute("displaytext", m_show_text);
|
||||
e.setAttribute("onetextperfolio", m_one_text_per_folio);
|
||||
e.setAttribute("vertirotatetext", QString::number(verti_rotate_text));
|
||||
e.setAttribute("horizrotatetext", QString::number(horiz_rotate_text));
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
e.setAttribute("horizontal-alignment", me.valueToKey(m_horizontal_alignment));
|
||||
e.setAttribute("vertical-alignment", me.valueToKey(m_vertical_alignment));
|
||||
|
||||
QString conductor_style = writeStyle();
|
||||
if (!conductor_style.isEmpty())
|
||||
e.setAttribute("style", conductor_style);
|
||||
QString conductor_style = writeStyle();
|
||||
if (!conductor_style.isEmpty())
|
||||
e.setAttribute("style", conductor_style);
|
||||
}
|
||||
|
||||
|
||||
/** RETURNS True
|
||||
/**
|
||||
@brief ConductorProperties::fromXml
|
||||
Import conductor propertie, from the attribute of the xml element 'e'
|
||||
@param e the xml document
|
||||
*/
|
||||
bool ConductorProperties::fromXmlPriv(const QDomElement &e)
|
||||
void ConductorProperties::fromXml(QDomElement &e)
|
||||
{
|
||||
// get conductor color
|
||||
QETXML::propertyColor(e, "color", &color);
|
||||
QETXML::propertyBool(e, "bicolor", &m_bicolor);
|
||||
QETXML::propertyColor(e, "color2", &m_color_2);
|
||||
QETXML::propertyInteger(e, "dash-size", &m_dash_size);
|
||||
QColor xml_color= QColor(e.attribute("color"));
|
||||
color = (xml_color.isValid()? xml_color : QColor(Qt::black));
|
||||
|
||||
QString bicolor_str = e.attribute("bicolor", "false");
|
||||
m_bicolor = bicolor_str == "true"? true : false;
|
||||
|
||||
QColor xml_color_2 = QColor(e.attribute("color2"));
|
||||
m_color_2 = xml_color_2.isValid()? xml_color_2 : QColor(Qt::black);
|
||||
|
||||
m_dash_size = e.attribute("dash-size", QString::number(1)).toInt();
|
||||
|
||||
// read style of conductor
|
||||
QString style_string;
|
||||
QETXML::propertyString(e, "style", &style_string);
|
||||
readStyle(style_string);
|
||||
readStyle(e.attribute("style"));
|
||||
|
||||
QString type_t;
|
||||
if (QETXML::propertyString(e, "type", &type_t) == QETXML::PropertyFlags::Success) {
|
||||
if (type_t == typeToString(Single))
|
||||
if (e.attribute("type") == typeToString(Single))
|
||||
{
|
||||
// get specific properties for single conductor
|
||||
singleLineProperties.fromXml(e);
|
||||
type = Single;
|
||||
}
|
||||
else if (type_t == typeToString(Multi))
|
||||
else
|
||||
type = Multi;
|
||||
else {
|
||||
//Keep retrocompatible with version older than 0,4
|
||||
//If the propertie @type is simple (removed since QET 0,4), we set text no visible.
|
||||
//@TODO remove this code for qet 0.6 or later
|
||||
|
||||
if (type_t == "simple") m_show_text = false;
|
||||
}
|
||||
}
|
||||
|
||||
QETXML::propertyString(e, "num", &text);
|
||||
// TODO: implement:
|
||||
//m_cable = e.attribute("cable");
|
||||
//m_bus = e.attribute("bus");
|
||||
text = e.attribute("num");
|
||||
// get text color
|
||||
QETXML::propertyColor(e, "text_color", &text_color);
|
||||
QETXML::propertyString(e, "formula", &m_formula);
|
||||
QETXML::propertyString(e, "function", &m_function);
|
||||
QETXML::propertyString(e, "tension_protocol", &m_tension_protocol);
|
||||
QETXML::propertyString(e, "conductor_color", &m_wire_color);
|
||||
QETXML::propertyString(e, "conductor_section", &m_wire_section);
|
||||
QETXML::propertyInteger(e, "numsize", &text_size);
|
||||
QETXML::propertyDouble(e, "condsize", &cond_size);
|
||||
QETXML::propertyBool(e, "displaytext", &m_show_text);
|
||||
QETXML::propertyBool(e, "onetextperfolio", &m_one_text_per_folio);
|
||||
QETXML::propertyDouble(e, "vertirotatetext", &verti_rotate_text);
|
||||
QETXML::propertyDouble(e, "horizrotatetext", &horiz_rotate_text);
|
||||
QColor xml_text_color= QColor(e.attribute("text_color"));
|
||||
text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black));
|
||||
m_formula = e.attribute("formula");
|
||||
m_cable = e.attribute("cable");
|
||||
m_bus = e.attribute("bus");
|
||||
m_function = e.attribute("function");
|
||||
m_tension_protocol = e.attribute("tension_protocol");
|
||||
m_wire_color = e.attribute("conductor_color");
|
||||
m_wire_section = e.attribute("conductor_section");
|
||||
text_size = e.attribute("numsize", QString::number(9)).toInt();
|
||||
cond_size = e.attribute("condsize", QString::number(1)).toDouble();
|
||||
m_show_text = e.attribute("displaytext", QString::number(1)).toInt();
|
||||
m_one_text_per_folio = e.attribute("onetextperfolio", QString::number(0)).toInt();
|
||||
verti_rotate_text = e.attribute("vertirotatetext").toDouble();
|
||||
horiz_rotate_text = e.attribute("horizrotatetext").toDouble();
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
QString alinment_temp;
|
||||
if (QETXML::propertyString(e, "horizontal-alignment", &alinment_temp) == QETXML::PropertyFlags::Success)
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||
if (QETXML::propertyString(e, "vertical-alignment", &alinment_temp) == QETXML::PropertyFlags::Success)
|
||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConductorProperties::valideXml(QDomElement& e) {
|
||||
if (QETXML::propertyColor(e, "color") ||
|
||||
QETXML::propertyBool(e, "bicolor") ||
|
||||
QETXML::propertyColor(e, "color2") ||
|
||||
QETXML::propertyInteger(e, "dash-size") ||
|
||||
QETXML::propertyString(e, "type") ||
|
||||
QETXML::propertyString(e, "num") ||
|
||||
QETXML::propertyColor(e, "text_color") ||
|
||||
QETXML::propertyString(e, "formula") ||
|
||||
QETXML::propertyString(e, "function") ||
|
||||
QETXML::propertyString(e, "tension_protocol") ||
|
||||
QETXML::propertyString(e, "conductor_color") ||
|
||||
QETXML::propertyString(e, "conductor_section") ||
|
||||
QETXML::propertyInteger(e, "numsize") ||
|
||||
QETXML::propertyDouble(e, "condsize") ||
|
||||
QETXML::propertyBool(e, "displaytext") ||
|
||||
QETXML::propertyBool(e, "onetextperfolio") ||
|
||||
QETXML::propertyDouble(e, "vertirotatetext") ||
|
||||
QETXML::propertyDouble(e, "horizrotatetext") ||
|
||||
QETXML::propertyString(e, "horizontal-alignment") ||
|
||||
QETXML::propertyString(e, "vertical-alignment"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ConductorProperties::xmlTagName()
|
||||
{
|
||||
return conductorPropertiesXmlName;
|
||||
m_horizontal_alignment = Qt::Alignment(
|
||||
me.keyToValue(
|
||||
e.attribute(
|
||||
"horizontal-alignment",
|
||||
"AlignBottom"
|
||||
).toStdString().data()));
|
||||
m_vertical_alignment = Qt::Alignment(
|
||||
me.keyToValue(
|
||||
e.attribute(
|
||||
"vertical-alignment",
|
||||
"AlignRight"
|
||||
).toStdString().data()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,22 +425,22 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
|
||||
|
||||
singleLineProperties.fromSettings(settings, prefix);
|
||||
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
text = settings.value(prefix + "text", "_").toString();
|
||||
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
|
||||
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
|
||||
m_formula = settings.value(prefix + "formula", "").toString();
|
||||
m_cable = settings.value(prefix + "cable", "").toString();
|
||||
m_bus = settings.value(prefix + "bus", "").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_formula = settings.value(prefix + "formula", "").toString();
|
||||
m_cable = settings.value(prefix + "cable", "").toString();
|
||||
m_bus = settings.value(prefix + "bus", "").toString();
|
||||
m_function = settings.value(prefix + "function", "").toString();
|
||||
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
|
||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
|
||||
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
|
||||
text_size = settings.value(prefix + "textsize", "7").toInt();
|
||||
cond_size = settings.value(prefix + "size", "1").toInt();
|
||||
m_show_text = settings.value(prefix + "displaytext", true).toBool();
|
||||
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();
|
||||
horiz_rotate_text = settings.value((prefix + "horizrotatetext"), "0").toDouble();
|
||||
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(settings.value(prefix + "horizontal-alignment", "AlignBottom").toString().toStdString().data()));
|
||||
@@ -530,25 +478,25 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
|
||||
if (clist.size() == 1)
|
||||
{
|
||||
ConductorProperties cp = clist.first();
|
||||
color = cp.color;
|
||||
m_bicolor = cp.m_bicolor;
|
||||
m_color_2 = cp.m_color_2;
|
||||
m_dash_size = cp.m_dash_size;
|
||||
text = cp.text;
|
||||
text_color = cp.text_color;
|
||||
m_formula = cp.m_formula;
|
||||
m_cable = cp.m_cable;
|
||||
m_bus = cp.m_bus;
|
||||
m_function = cp.m_function;
|
||||
color = cp.color;
|
||||
m_bicolor = cp.m_bicolor;
|
||||
m_color_2 = cp.m_color_2;
|
||||
m_dash_size = cp.m_dash_size;
|
||||
text = cp.text;
|
||||
text_color = cp.text_color;
|
||||
m_formula = cp.m_formula;
|
||||
m_cable = cp.m_cable;
|
||||
m_bus = cp.m_bus;
|
||||
m_function = cp.m_function;
|
||||
m_tension_protocol = cp.m_tension_protocol;
|
||||
m_wire_color = cp.m_wire_color;
|
||||
m_wire_section = cp.m_wire_section;
|
||||
text_size = cp.text_size;
|
||||
cond_size = cp.cond_size;
|
||||
m_show_text = cp.m_show_text;
|
||||
m_wire_color = cp.m_wire_color;
|
||||
m_wire_section = cp.m_wire_section;
|
||||
text_size = cp.text_size;
|
||||
cond_size = cp.cond_size;
|
||||
m_show_text = cp.m_show_text;
|
||||
m_one_text_per_folio = cp.m_one_text_per_folio;
|
||||
verti_rotate_text = cp.verti_rotate_text;
|
||||
horiz_rotate_text = cp.horiz_rotate_text;
|
||||
verti_rotate_text = cp.verti_rotate_text;
|
||||
horiz_rotate_text = cp.horiz_rotate_text;
|
||||
m_vertical_alignment = cp.m_vertical_alignment;
|
||||
m_horizontal_alignment = cp.m_horizontal_alignment;
|
||||
|
||||
@@ -886,7 +834,7 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
||||
if (!match.hasMatch())
|
||||
{
|
||||
qDebug()<<"no Match"
|
||||
<<style_str;
|
||||
<<style_str;
|
||||
} else {
|
||||
QString style_name = match.captured("name");
|
||||
QString style_value = match.captured("value");
|
||||
@@ -946,12 +894,12 @@ int SingleLineProperties::operator!=(const SingleLineProperties &other) const
|
||||
@param prefix prefix a ajouter devant les noms des parametres
|
||||
*/
|
||||
void SingleLineProperties::toSettings(QSettings &settings,
|
||||
const QString &prefix) const
|
||||
const QString &prefix) const
|
||||
{
|
||||
settings.setValue(prefix + "hasGround", hasGround);
|
||||
settings.setValue(prefix + "hasNeutral", hasNeutral);
|
||||
settings.setValue(prefix + "phases", phases);
|
||||
settings.setValue(prefix + "pen", is_pen);
|
||||
settings.setValue(prefix + "phases", phases);
|
||||
settings.setValue(prefix + "pen", is_pen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -962,6 +910,6 @@ void SingleLineProperties::fromSettings(QSettings &settings,
|
||||
const QString &prefix) {
|
||||
hasGround = settings.value(prefix + "hasGround", true).toBool();
|
||||
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
|
||||
phases = settings.value(prefix + "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||
phases = settings.value(prefix + "phases", 1).toInt();
|
||||
is_pen = settings.value(prefix + "pen", false).toBool();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user