Remove old Backward compatibility: prior to version 0.3

This commit is contained in:
Claveau Joshua
2020-10-02 17:39:07 +02:00
parent cbdbdd0ec6
commit e0201a8027
4 changed files with 9 additions and 59 deletions

View File

@@ -64,7 +64,6 @@ QColor Diagram::background_color = Qt::white;
Diagram::Diagram(QETProject *project) : Diagram::Diagram(QETProject *project) :
QGraphicsScene (project), QGraphicsScene (project),
m_project (project), m_project (project),
diagram_qet_version_ (-1),
draw_grid_ (true), draw_grid_ (true),
use_border_ (true), use_border_ (true),
draw_terminals_ (true), draw_terminals_ (true),
@@ -733,9 +732,6 @@ QDomDocument Diagram::toXml(bool whole_content) {
// racine de l'arbre XML // racine de l'arbre XML
auto dom_root = document.createElement("diagram"); auto dom_root = document.createElement("diagram");
// add the application version number
dom_root.setAttribute("version", QET::version);
// schema properties // schema properties
// proprietes du schema // proprietes du schema
if (whole_content) { if (whole_content) {
@@ -1192,15 +1188,9 @@ bool Diagram::fromXml(QDomElement &document,
// The first element must be a diagram // The first element must be a diagram
if (root.tagName() != "diagram") return(false); if (root.tagName() != "diagram") return(false);
// Read attributes of this diagram // Read attributes of this diagram
if (consider_informations) { if (consider_informations)
// Version of diagram {
bool conv_ok;
qreal version_value = root.attribute("version").toDouble(&conv_ok);
if (conv_ok) {
diagram_qet_version_ = version_value;
}
// Load border and titleblock // Load border and titleblock
border_and_titleblock.titleBlockFromXml(root); border_and_titleblock.titleBlockFromXml(root);
border_and_titleblock.borderFromXml(root); border_and_titleblock.borderFromXml(root);
@@ -1262,19 +1252,6 @@ bool Diagram::fromXml(QDomElement &document,
return(true); return(true);
} }
/* Backward compatibility: prior to version 0.3, we need to compensate,
* at diagram-opening time, the rotation of the element for each of its
* textfields having the "FollowParentRotation" option disabled.
* After 0.3, elements textfields get userx,
* usery and userrotation attributes that explicitly specify
* their position and orientation.
*/
qreal project_qet_version = declaredQElectroTechVersion(true);
bool handle_inputs_rotation = (
project_qet_version != -1 && project_qet_version < 0.3 &&
m_project -> state() == QETProject::ProjectParsingRunning
);
//If paste from another project //If paste from another project
if (root.hasAttribute("projectId")) { if (root.hasAttribute("projectId")) {
QETProject *other_project = QETApp::project( QETProject *other_project = QETApp::project(
@@ -1343,9 +1320,7 @@ bool Diagram::fromXml(QDomElement &document,
addItem(nvel_elmt); addItem(nvel_elmt);
//Loading fail, remove item from the diagram //Loading fail, remove item from the diagram
if (!nvel_elmt->fromXml(element_xml, if (!nvel_elmt->fromXml(element_xml, table_adr_id))
table_adr_id,
handle_inputs_rotation))
{ {
removeItem(nvel_elmt); removeItem(nvel_elmt);
delete nvel_elmt; delete nvel_elmt;
@@ -2363,25 +2338,6 @@ int Diagram::folioIndex() const
return(m_project -> folioIndex(this)); return(m_project -> folioIndex(this));
} }
/**
@brief Diagram::declaredQElectroTechVersion
@param fallback_to_project :
When a diagram does not have a declared version,
this method will use the one declared by its parent project only if
fallback_to_project is true.
@return the declared QElectroTech version of this diagram
*/
qreal Diagram::declaredQElectroTechVersion(bool fallback_to_project) const
{
if (diagram_qet_version_ != -1) {
return diagram_qet_version_;
}
if (fallback_to_project && m_project) {
return(m_project -> declaredQElectroTechVersion());
}
return(-1);
}
/** /**
@brief Diagram::isReadOnly @brief Diagram::isReadOnly
@return true if this diagram is read only. @return true if this diagram is read only.

View File

@@ -157,7 +157,6 @@ class Diagram : public QGraphicsScene
// methods related to parent project // methods related to parent project
QETProject *project() const; QETProject *project() const;
int folioIndex() const; int folioIndex() const;
qreal declaredQElectroTechVersion(bool = true) const;
void showMe() {emit showDiagram(this);} void showMe() {emit showDiagram(this);}
bool isReadOnly() const; bool isReadOnly() const;

View File

@@ -694,14 +694,12 @@ bool Element::valideXml(QDomElement &e) {
@param e : the dom element where the parameter is stored @param e : the dom element where the parameter is stored
@param table_id_adr : Reference to the mapping table between IDs of the XML file @param table_id_adr : Reference to the mapping table between IDs of the XML file
and the addresses in memory. If the import succeeds, it must be add the right couples (id, address). and the addresses in memory. If the import succeeds, it must be add the right couples (id, address).
@param handle_inputs_rotation : apply the rotation of this element to his child text
@return @return
*/ */
bool Element::fromXml( bool Element::fromXml(
QDomElement &e, QDomElement &e,
QHash<int, QHash<int,
Terminal *> &table_id_adr, Terminal *> &table_id_adr)
bool handle_inputs_rotation)
{ {
m_state = QET::GILoadingFromXml; m_state = QET::GILoadingFromXml;
/* /*
@@ -797,12 +795,10 @@ bool Element::fromXml(
// orientation // orientation
bool conv_ok; bool conv_ok;
int read_ori = e.attribute("orientation").toInt(&conv_ok); int read_ori = e.attribute("orientation").toInt(&conv_ok);
if (!conv_ok || read_ori < 0 || read_ori > 3) read_ori = 0; if (!conv_ok || read_ori < 0 || read_ori > 3) {
if (handle_inputs_rotation) { read_ori = 0;
setRotation(rotation() + (90*read_ori));
} else {
setRotation(90*read_ori);
} }
setRotation(90*read_ori);
//Befor load the dynamic text field, //Befor load the dynamic text field,
//we remove the dynamic text field created from the description of this element, to avoid doublons. //we remove the dynamic text field created from the description of this element, to avoid doublons.

View File

@@ -133,8 +133,7 @@ class Element : public QetGraphicsItem
virtual bool fromXml( virtual bool fromXml(
QDomElement &, QDomElement &,
QHash<int, QHash<int,
Terminal *> &, Terminal *> &);
bool = false);
virtual QDomElement toXml( virtual QDomElement toXml(
QDomDocument &, QDomDocument &,
QHash<Terminal *, QHash<Terminal *,