mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +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>();
|
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
|
|
||||||
QString alinment_temp;
|
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()));
|
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()));
|
m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -121,11 +121,11 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
|||||||
bool PartArc::fromXml(const QDomElement &qde) {
|
bool PartArc::fromXml(const QDomElement &qde) {
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
double x, y, w, h;
|
double x=0, y=0, w=0, h=0;
|
||||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion ||
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion ||
|
propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &h, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||||
|
|||||||
@@ -186,8 +186,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
|||||||
bool frame;
|
bool frame;
|
||||||
propertyBool(dom_elmt, "frame", &frame);
|
propertyBool(dom_elmt, "frame", &frame);
|
||||||
|
|
||||||
double text_width;
|
double text_width=-1;
|
||||||
propertyDouble(dom_elmt, "text_width", &text_width, true, -1);
|
propertyDouble(dom_elmt, "text_width", &text_width);
|
||||||
setTextWidth(text_width);
|
setTextWidth(text_width);
|
||||||
|
|
||||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||||
|
|||||||
@@ -108,23 +108,23 @@ QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
|||||||
bool PartEllipse::fromXml(const QDomElement &qde)
|
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
double x, y, width, height;
|
double x=0, y=0, width=0, height=0;
|
||||||
|
|
||||||
if (qde.tagName() == "ellipse")
|
if (qde.tagName() == "ellipse")
|
||||||
{
|
{
|
||||||
if (propertyDouble(qde, "width", &width, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &height, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (propertyDouble(qde, "diameter", &width, true, 0) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(qde, "diameter", &width) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
height = width;
|
height = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||||
|
|||||||
@@ -116,23 +116,23 @@ bool PartRectangle::fromXml(const QDomElement &qde)
|
|||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
double x, y, w, h, rx, ry;
|
double x=0, y=0, w=0, h=0, rx=0, ry=0;
|
||||||
if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setPos(mapFromScene(x, y));
|
setPos(mapFromScene(x, y));
|
||||||
|
|
||||||
if (propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "width", &h, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
QRectF rect(QPointF(x,y), QSizeF(w, h));
|
||||||
|
|
||||||
setRect(rect.normalized());
|
setRect(rect.normalized());
|
||||||
|
|
||||||
if (propertyDouble(qde, "rx", &rx, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "ry", &ry, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(qde, "ry", &ry) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setXRadius(rx);
|
setXRadius(rx);
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ bool PartText::fromXml(const QDomElement &xml_element)
|
|||||||
propertyString(xml_element, "text", &text);
|
propertyString(xml_element, "text", &text);
|
||||||
setPlainText(text);
|
setPlainText(text);
|
||||||
|
|
||||||
double x, y, rot;
|
double x=0, y=0, rot=0;
|
||||||
if (propertyDouble(xml_element, "x", &x, true, 0) == PropertyFlags::NoValidConversion ||
|
if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(xml_element, "y", &y, true, 0) == PropertyFlags::NoValidConversion)
|
propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
|
|
||||||
if (propertyDouble(xml_element, "rotation", &rot, true, 0) == PropertyFlags::NoValidConversion)
|
if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||||
return false;
|
return false;
|
||||||
setRotation(rot);
|
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,
|
* \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
|
* \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;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
if (entier && setDefaultValue)
|
|
||||||
*entier = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,13 +172,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD
|
|||||||
return PropertyFlags::Success;
|
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;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||||
if (reel && setDefaultValue)
|
|
||||||
*reel = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,13 +194,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
|
|||||||
return PropertyFlags::Success;
|
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;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, boolS, &attr)) {
|
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||||
if (boolean && setDefaultValue)
|
|
||||||
*boolean = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,13 +222,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
|||||||
return PropertyFlags::Success;
|
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;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||||
if (color && setDefaultValue)
|
|
||||||
*color = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,12 +243,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom
|
|||||||
return PropertyFlags::Success;
|
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;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
if (uuid && setDefaultValue)
|
|
||||||
*uuid = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,12 +262,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomE
|
|||||||
return PropertyFlags::Success;
|
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;
|
QString attr;
|
||||||
if (!attribute(e, attribute_name, stringS, &attr)) {
|
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||||
if (string && setDefaultValue)
|
|
||||||
*string = defaultValue;
|
|
||||||
return PropertyFlags::NotFound;
|
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!
|
* 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 propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||||
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 propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, bool setDefaultValue = false, QString defaultValue = QString());
|
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, bool setDefaultValue = false, bool defaultValue = false);
|
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, bool setDefaultValue = false, QUuid defaultValue = QUuid());
|
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, bool setDefaultValue = false, QColor defaultValue = QColor());
|
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||||
|
|
||||||
|
|
||||||
static bool validXmlProperty(const QDomElement& e);
|
static bool validXmlProperty(const QDomElement& e);
|
||||||
|
|||||||
@@ -966,7 +966,7 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
|||||||
else
|
else
|
||||||
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
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);
|
setProperties(pr);
|
||||||
|
|
||||||
return return_;
|
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);
|
dom_element.appendChild(dom_seq);
|
||||||
|
|
||||||
// Export the properties and text
|
// Export the properties and text
|
||||||
|
|||||||
Reference in New Issue
Block a user