mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
regarding to joshuas email, toXml uses a new structure. So it is changed in the properties interface and xrefproperties
This commit is contained in:
committed by
Laurent Trinques
parent
ca80b3d69f
commit
8c6b4120f5
@@ -34,8 +34,8 @@ class PropertiesInterface
|
||||
virtual void toSettings (QSettings &settings, const QString = QString()) const =0;
|
||||
virtual void fromSettings (const QSettings &settings, const QString = QString()) =0;
|
||||
// Save/load properties to xml element
|
||||
virtual void toXml (QDomElement &xml_element) const =0;
|
||||
virtual void fromXml (const QDomElement &xml_element) =0;
|
||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||
};
|
||||
|
||||
#endif // PROPERTIESINTERFACE_H
|
||||
|
||||
@@ -93,8 +93,12 @@ void XRefProperties::fromSettings(const QSettings &settings, const QString prefi
|
||||
* Save to xml
|
||||
* @param xml_element: QDomElement to use for saving
|
||||
*/
|
||||
void XRefProperties::toXml(QDomElement &xml_element) const {
|
||||
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
||||
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const {
|
||||
|
||||
QDomElement xml_element = xml_document.createElement("xref");
|
||||
xml_element.setAttribute("type", m_key);
|
||||
|
||||
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
||||
QString display = m_display == Cross? "cross" : "contacts";
|
||||
xml_element.setAttribute("displayhas", display);
|
||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||
@@ -114,6 +118,8 @@ void XRefProperties::toXml(QDomElement &xml_element) const {
|
||||
foreach (QString key, m_prefix.keys()) {
|
||||
xml_element.setAttribute(key + "prefix", m_prefix.value(key));
|
||||
}
|
||||
|
||||
return xml_element;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +127,7 @@ void XRefProperties::toXml(QDomElement &xml_element) const {
|
||||
* Load from xml
|
||||
* @param xml_element: QDomElement to use for load
|
||||
*/
|
||||
void XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
|
||||
QString display = xml_element.attribute("displayhas", "cross");
|
||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||
@@ -143,6 +149,7 @@ void XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
foreach (QString key, m_prefix_keys) {
|
||||
m_prefix.insert(key, xml_element.attribute(key + "prefix"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,8 +42,8 @@ class XRefProperties : public PropertiesInterface
|
||||
|
||||
void toSettings (QSettings &settings, const QString = QString()) const override;
|
||||
void fromSettings (const QSettings &settings, const QString = QString()) override;
|
||||
void toXml (QDomElement &xml_element) const override;
|
||||
void fromXml (const QDomElement &xml_element) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static QHash<QString, XRefProperties> defaultProperties();
|
||||
|
||||
@@ -73,6 +73,8 @@ class XRefProperties : public PropertiesInterface
|
||||
void setOffset(const int offset) {m_offset = offset;}
|
||||
int offset() const {return m_offset;}
|
||||
|
||||
void setKey(QString& key) {m_key = key;}
|
||||
|
||||
private:
|
||||
bool m_show_power_ctc;
|
||||
DisplayHas m_display;
|
||||
@@ -83,6 +85,7 @@ class XRefProperties : public PropertiesInterface
|
||||
QString m_master_label;
|
||||
QString m_slave_label;
|
||||
int m_offset;
|
||||
QString m_key;
|
||||
};
|
||||
|
||||
#endif // XREFPROPERTIES_H
|
||||
|
||||
@@ -1582,11 +1582,10 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
|
||||
|
||||
// export default XRef properties
|
||||
QDomElement xrefs_elmt = xml_document.createElement("xrefs");
|
||||
foreach (QString key, defaultXRefProperties().keys()) {
|
||||
QDomElement xref_elmt = xml_document.createElement("xref");
|
||||
xref_elmt.setAttribute("type", key);
|
||||
defaultXRefProperties()[key].toXml(xref_elmt);
|
||||
xrefs_elmt.appendChild(xref_elmt);
|
||||
foreach (QString key, defaultXRefProperties().keys()) {
|
||||
defaultXRefProperties()[key].setKey(key);
|
||||
QDomElement xref_elmt = defaultXRefProperties()[key].toXml(xml_document);
|
||||
xrefs_elmt.appendChild(xref_elmt);
|
||||
}
|
||||
xml_element.appendChild(xrefs_elmt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user