diff --git a/sources/bordertitleblock.cpp b/sources/bordertitleblock.cpp index 9ac9bcb13..f041af066 100644 --- a/sources/bordertitleblock.cpp +++ b/sources/bordertitleblock.cpp @@ -65,8 +65,6 @@ BorderTitleBlock::BorderTitleBlock(QObject *parent) : // contenu par defaut du cartouche importTitleBlock(TitleBlockProperties()); - display_titleblock_ = true; - display_border_ = true; setFolioData(1, 1); updateRectangles(); } @@ -217,9 +215,23 @@ QDomElement BorderTitleBlock::titleBlockToXml(QDomDocument& doc) { @param xml_elmt the XML element values will be read from */ void BorderTitleBlock::titleBlockFromXml(const QDomElement &xml_elmt) { - TitleBlockProperties tbp; - tbp.fromXml(xml_elmt); - importTitleBlock(tbp); + + TitleBlockProperties tbp; + QString tagname = tbp.tagName(); + QDomElement titleBlockProperties = xml_elmt.firstChildElement(tagname); + + if (!titleBlockProperties.isNull()) + { + tbp.fromXml(titleBlockProperties); + importTitleBlock(tbp); + } + else + { + // legacy + // Remove this part in a later step + tbp.fromXml(xml_elmt); + importTitleBlock(tbp); + } } /** diff --git a/sources/bordertitleblock.h b/sources/bordertitleblock.h index 36c7952ae..56fb12069 100644 --- a/sources/bordertitleblock.h +++ b/sources/bordertitleblock.h @@ -286,10 +286,10 @@ class BorderTitleBlock : public QObject QRectF diagram_rect_; // display options - bool display_titleblock_; + bool display_titleblock_{true}; bool display_columns_; bool display_rows_; - bool display_border_; + bool display_border_{true}; TitleBlockTemplateRenderer *m_titleblock_template_renderer; }; #endif diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 66cd1f7ef..fbdf0d459 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -1196,6 +1196,7 @@ bool Diagram::fromXml(QDomElement &document, if (consider_informations) { // Load border and titleblock + border_and_titleblock.titleBlockFromXml(root); border_and_titleblock.borderFromXml(root); diff --git a/sources/properties/propertiesinterface.cpp b/sources/properties/propertiesinterface.cpp index 67fc0c969..a1579b3a3 100644 --- a/sources/properties/propertiesinterface.cpp +++ b/sources/properties/propertiesinterface.cpp @@ -60,6 +60,11 @@ void PropertiesInterface::setTagName(const QString& tagname) mTagName = tagname; } +QString PropertiesInterface::tagName() const +{ + return mTagName; +} + QDomElement PropertiesInterface::toXml (QDomDocument &xml_document) const { QDomElement element = xml_document.createElement(mTagName); @@ -76,6 +81,8 @@ bool PropertiesInterface::fromXml (const QDomElement &xml_element) if (!propertiesFromXml(xml_element)) return false; + + return true; } bool PropertiesInterface::valideXml(QDomElement& element) { @@ -403,7 +410,10 @@ QString PropertiesInterface::orientationToString(Qet::Orientation o) { * \param e */ void PropertiesInterface::propertiesToXml(QDomElement& e) const -{ +{ + if (properties.count() == 0) + return; + QDomDocument doc = e.ownerDocument(); auto up = doc.createElement(userPropertiesS); for (auto i = properties.begin(); i != properties.end(); ++i) @@ -418,9 +428,8 @@ void PropertiesInterface::propertiesToXml(QDomElement& e) const up.appendChild(createXmlProperty(i.key(), i.value().toDouble())); break; case QVariant::Type::Bool: up.appendChild(createXmlProperty(i.key(), i.value().toBool())); break; -// case QVariant::Type::Color: -// // TODO: correct? -// up.appendChild(createXmlProperty(i.key(), i.value().toString())); break; + case QVariant::Type::Color: + up.appendChild(createXmlProperty(i.key(), QColor(i.value().value()))); break; default: break; } @@ -502,4 +511,6 @@ bool PropertiesInterface::propertiesFromXml(const QDomElement& e) } } } + + return true; } diff --git a/sources/properties/propertiesinterface.h b/sources/properties/propertiesinterface.h index c2d526d35..9a6f71f04 100644 --- a/sources/properties/propertiesinterface.h +++ b/sources/properties/propertiesinterface.h @@ -154,6 +154,7 @@ class PropertiesInterface QVariant XmlProperty(const QDomElement& element); void setTagName(const QString& tagname); + QString tagName() const; /** Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w") diff --git a/sources/titleblockproperties.cpp b/sources/titleblockproperties.cpp index ea5711c64..9b75032e0 100644 --- a/sources/titleblockproperties.cpp +++ b/sources/titleblockproperties.cpp @@ -25,6 +25,7 @@ */ TitleBlockProperties::TitleBlockProperties() { + setTagName("titleblock"); } /**