mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
remove default parameter, because it leads only to confusion and errors
This commit is contained in:
@@ -369,9 +369,9 @@ bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
|
||||
QString alinment_temp;
|
||||
if (propertyString(e, "horizontal-alignment", &alinment_temp, "AlignBottom") == PropertyFlags::Success)
|
||||
if (propertyString(e, "horizontal-alignment", &alinment_temp) == PropertyFlags::Success)
|
||||
m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||
if (propertyString(e, "vertical-alignment", &alinment_temp, "AlignRight") == PropertyFlags::Success)
|
||||
if (propertyString(e, "vertical-alignment", &alinment_temp) == PropertyFlags::Success)
|
||||
m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||
|
||||
return true;
|
||||
|
||||
@@ -121,11 +121,11 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||
bool PartArc::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
|
||||
double x, y, w, h;
|
||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "height", &h, true, 0) == PropertyFlags::NoValidConversion)
|
||||
double x=0, y=0, w=0, h=0;
|
||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||
|
||||
@@ -186,8 +186,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
bool frame;
|
||||
propertyBool(dom_elmt, "frame", &frame);
|
||||
|
||||
double text_width;
|
||||
propertyDouble(dom_elmt, "text_width", &text_width, true, -1);
|
||||
double text_width=-1;
|
||||
propertyDouble(dom_elmt, "text_width", &text_width);
|
||||
setTextWidth(text_width);
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
|
||||
@@ -108,23 +108,23 @@ QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
double x, y, width, height;
|
||||
double x=0, y=0, width=0, height=0;
|
||||
|
||||
if (qde.tagName() == "ellipse")
|
||||
{
|
||||
if (propertyDouble(qde, "width", &width, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "height", &height, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (propertyDouble(qde, "diameter", &width, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(qde, "diameter", &width) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
height = width;
|
||||
}
|
||||
|
||||
|
||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||
|
||||
@@ -116,23 +116,23 @@ bool PartRectangle::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
double x, y, w, h, rx, ry;
|
||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
||||
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
||||
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
setPos(mapFromScene(x, y));
|
||||
|
||||
if (propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "width", &h, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
||||
|
||||
setRect(rect.normalized());
|
||||
|
||||
if (propertyDouble(qde, "rx", &rx, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "ry", &ry, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(qde, "ry", &ry) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
setXRadius(rx);
|
||||
|
||||
@@ -87,13 +87,13 @@ bool PartText::fromXml(const QDomElement &xml_element)
|
||||
propertyString(xml_element, "text", &text);
|
||||
setPlainText(text);
|
||||
|
||||
double x, y, rot;
|
||||
if (propertyDouble(xml_element, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(xml_element, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
||||
double x=0, y=0, rot=0;
|
||||
if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
setPos(x, y);
|
||||
|
||||
if (propertyDouble(xml_element, "rotation", &rot, true, 0) == PropertyFlags::NoValidConversion)
|
||||
if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
setRotation(rot);
|
||||
|
||||
|
||||
@@ -150,13 +150,11 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
|
||||
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||
* \p entier is not valid and the return value is False
|
||||
*/
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier, bool setDefaultValue, int defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||
if (entier && setDefaultValue)
|
||||
*entier = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -174,13 +172,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel, bool setDefaultValue, double defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||
if (reel && setDefaultValue)
|
||||
*reel = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -198,13 +194,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool setDefaultValue, bool defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||
if (boolean && setDefaultValue)
|
||||
*boolean = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -228,13 +222,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, bool setDefaultValue, QColor defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||
if (color && setDefaultValue)
|
||||
*color = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -251,12 +243,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, bool setDefaultValue, QUuid defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) {
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||
if (uuid && setDefaultValue)
|
||||
*uuid = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -272,12 +262,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomE
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string, bool setDefaultValue, QString defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string) {
|
||||
|
||||
QString attr;
|
||||
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||
if (string && setDefaultValue)
|
||||
*string = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,12 +66,12 @@ class PropertiesInterface
|
||||
/*!
|
||||
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
|
||||
*/
|
||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, bool setDefaultValue = false, int defaultValue = std::numeric_limits<int>::quiet_NaN());
|
||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, bool setDefaultValue = false, double defaultValue = std::numeric_limits<double>::quiet_NaN());
|
||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, bool setDefaultValue = false, QString defaultValue = QString());
|
||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool setDefaultValue = false, bool defaultValue = false);
|
||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, bool setDefaultValue = false, QUuid defaultValue = QUuid());
|
||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr, bool setDefaultValue = false, QColor defaultValue = QColor());
|
||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||
|
||||
|
||||
static bool validXmlProperty(const QDomElement& e);
|
||||
|
||||
@@ -966,7 +966,7 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
else
|
||||
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
||||
|
||||
propertyBool(dom_element, "freezeLabel", &m_freeze_label, false);
|
||||
propertyBool(dom_element, "freezeLabel", &m_freeze_label);
|
||||
setProperties(pr);
|
||||
|
||||
return return_;
|
||||
@@ -1022,7 +1022,7 @@ QDomElement Conductor::toXml(QDomDocument & doc) const {
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement dom_seq = m_autoNum_seq.toXml(doc);
|
||||
QDomElement dom_seq = m_autoNum_seq.toXml(doc); // swquentialNumbers tag
|
||||
dom_element.appendChild(dom_seq);
|
||||
|
||||
// Export the properties and text
|
||||
|
||||
Reference in New Issue
Block a user