This commit is contained in:
Martin Marmsoler
2020-08-24 20:34:18 +02:00
parent 385d0ffd69
commit a10709157d
27 changed files with 276 additions and 167 deletions

View File

@@ -94,13 +94,17 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
- XML element to which attributes will be added
- Element XML auquel seront ajoutes des attributs
*/
void BorderProperties::toXml(QDomElement &e) const {
e.setAttribute("cols", columns_count);
e.setAttribute("colsize", QString("%1").arg(columns_width));
e.setAttribute("rows", rows_count);
e.setAttribute("rowsize", QString("%1").arg(rows_height));
e.setAttribute("displaycols", display_columns ? "true" : "false");
e.setAttribute("displayrows", display_rows ? "true" : "false");
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
QDomElement e = dom_doc.createElement("border");
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
return e;
}
/**
@@ -111,13 +115,28 @@ void BorderProperties::toXml(QDomElement &e) const {
- XML element whose attributes will be read
- Element XML dont les attributs seront lus
*/
void BorderProperties::fromXml(QDomElement &e) {
if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
bool BorderProperties::fromXml(const QDomElement &e) {
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
propertyInteger(e, "rows", &rows_count) == PropertyFlags::NoValidConversion ||
propertyDouble(e, "rowsize", &rows_height) == PropertyFlags::NoValidConversion ||
propertyBool(e, "displaycols", &display_columns) == PropertyFlags::NoValidConversion ||
propertyBool(e, "displayrows", &display_rows) == PropertyFlags::NoValidConversion)
return false;
return true;
}
bool BorderProperties::valideXml(QDomElement& e) const {
if (propertyInteger(e, "cols") == PropertyFlags::Success &&
propertyDouble(e, "colsize") == PropertyFlags::Success &&
propertyInteger(e, "rows") == PropertyFlags::Success &&
propertyDouble(e, "rowsize") == PropertyFlags::Success &&
propertyBool(e, "displaycols") == PropertyFlags::Success &&
propertyBool(e, "displayrows") == PropertyFlags::Success)
return true;
}
/**
@@ -151,7 +170,7 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
- prefix to be added before the names of the parameters
- prefixe a ajouter devant les noms des parametres
*/
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) {
columns_count = settings.value(prefix + "cols", columns_count).toInt();
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();