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) :
QGraphicsScene (project),
m_project (project),
diagram_qet_version_ (-1),
draw_grid_ (true),
use_border_ (true),
draw_terminals_ (true),
@ -733,9 +732,6 @@ QDomDocument Diagram::toXml(bool whole_content) {
// racine de l'arbre XML
auto dom_root = document.createElement("diagram");
// add the application version number
dom_root.setAttribute("version", QET::version);
// schema properties
// proprietes du schema
if (whole_content) {
@ -1192,15 +1188,9 @@ bool Diagram::fromXml(QDomElement &document,
// The first element must be a diagram
if (root.tagName() != "diagram") return(false);
// Read attributes of this diagram
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;
}
// Read attributes of this diagram
if (consider_informations)
{
// Load border and titleblock
border_and_titleblock.titleBlockFromXml(root);
border_and_titleblock.borderFromXml(root);
@ -1262,19 +1252,6 @@ bool Diagram::fromXml(QDomElement &document,
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 (root.hasAttribute("projectId")) {
QETProject *other_project = QETApp::project(
@ -1343,9 +1320,7 @@ bool Diagram::fromXml(QDomElement &document,
addItem(nvel_elmt);
//Loading fail, remove item from the diagram
if (!nvel_elmt->fromXml(element_xml,
table_adr_id,
handle_inputs_rotation))
if (!nvel_elmt->fromXml(element_xml, table_adr_id))
{
removeItem(nvel_elmt);
delete nvel_elmt;
@ -2363,25 +2338,6 @@ int Diagram::folioIndex() const
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
@return true if this diagram is read only.

View File

@ -157,7 +157,6 @@ class Diagram : public QGraphicsScene
// methods related to parent project
QETProject *project() const;
int folioIndex() const;
qreal declaredQElectroTechVersion(bool = true) const;
void showMe() {emit showDiagram(this);}
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 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).
@param handle_inputs_rotation : apply the rotation of this element to his child text
@return
*/
bool Element::fromXml(
QDomElement &e,
QHash<int,
Terminal *> &table_id_adr,
bool handle_inputs_rotation)
Terminal *> &table_id_adr)
{
m_state = QET::GILoadingFromXml;
/*
@ -797,12 +795,10 @@ bool Element::fromXml(
// orientation
bool conv_ok;
int read_ori = e.attribute("orientation").toInt(&conv_ok);
if (!conv_ok || read_ori < 0 || read_ori > 3) read_ori = 0;
if (handle_inputs_rotation) {
setRotation(rotation() + (90*read_ori));
} else {
setRotation(90*read_ori);
if (!conv_ok || read_ori < 0 || read_ori > 3) {
read_ori = 0;
}
setRotation(90*read_ori);
//Befor load the dynamic text field,
//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(
QDomElement &,
QHash<int,
Terminal *> &,
bool = false);
Terminal *> &);
virtual QDomElement toXml(
QDomDocument &,
QHash<Terminal *,