diff --git a/sources/factory/elementpicturefactory.cpp b/sources/factory/elementpicturefactory.cpp index a00f011f9..4754d92d3 100644 --- a/sources/factory/elementpicturefactory.cpp +++ b/sources/factory/elementpicturefactory.cpp @@ -156,9 +156,9 @@ bool ElementPictureFactory::build(const ElementsLocation &location, //Check if the current version can read the xml description if (dom.hasAttribute("version")) { - bool conv_ok; - qreal element_version = dom.attribute("version").toDouble(&conv_ok); - if (conv_ok && QET::version.toDouble() < element_version) + QVersionNumber qet_version = QVersionNumber::fromString(QET::version); + QVersionNumber element_version = QVersionNumber::fromString(dom.attribute("version")); + if (qet_version < element_version) { std::cerr << qPrintable( QObject::tr("Avertissement : l'élément " diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 5f5315444..5800a3072 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -429,10 +429,9 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state) //Check if the current version can read the xml description if (xml_def_elmt.hasAttribute(QStringLiteral("version"))) { - bool conv_ok; - qreal element_version = xml_def_elmt.attribute( - QStringLiteral("version")).toDouble(&conv_ok); - if (conv_ok && QET::version.toDouble() < element_version) + QVersionNumber qet_version = QVersionNumber::fromString(QET::version); + QVersionNumber element_version = QVersionNumber::fromString(xml_def_elmt.attribute(QStringLiteral("version"))); + if (qet_version < element_version) { std::cerr << qPrintable( QObject::tr("Avertissement : l'élément " diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index d7ded3bad..31914841a 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -436,7 +436,7 @@ QString QETProject::title() const celui-ci a ete ouvert ; si ce projet n'a jamais ete enregistre / ouvert depuis un fichier, cette methode retourne -1. */ -qreal QETProject::declaredQElectroTechVersion() +QVersionNumber QETProject::declaredQElectroTechVersion() { return(m_project_qet_version); } @@ -1340,11 +1340,14 @@ void QETProject::readProjectXml(QDomDocument &xml_project) if (root_elmt.hasAttribute(QStringLiteral("version"))) { bool conv_ok; - m_project_qet_version = root_elmt.attribute(QStringLiteral("version")).toDouble(&conv_ok); + qreal r_project_qet_version = root_elmt.attribute(QStringLiteral("version")).toDouble(&conv_ok); + QVersionNumber qet_version = QVersionNumber::fromString(QET::version); + m_project_qet_version = QVersionNumber::fromString(root_elmt.attribute(QStringLiteral("version"))); + #if TODO_LIST #pragma message("@TODO use of version convert") #endif - if (conv_ok && QET::version.toDouble() < m_project_qet_version) + if (qet_version < m_project_qet_version) { int ret = QET::QetMessageBox::warning( nullptr, @@ -1365,9 +1368,11 @@ void QETProject::readProjectXml(QDomDocument &xml_project) return; } } + //Since QElectrotech 0.9 the compatibility with project made with //Qet 0.6 or lower is break; - if (conv_ok && m_project_qet_version <= 0.6 ) + //keep float here for very old version + if (conv_ok && r_project_qet_version <= 0.6) { auto ret = QET::QetMessageBox::warning( nullptr, diff --git a/sources/qetproject.h b/sources/qetproject.h index ca160837a..687bdf6af 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -98,7 +98,7 @@ class QETProject : public QObject QString currentDir() const; QString pathNameTitle() const; QString title() const; - qreal declaredQElectroTechVersion(); + QVersionNumber declaredQElectroTechVersion(); void setTitle(const QString &); ///DEFAULT PROPERTIES @@ -247,7 +247,7 @@ class QETProject : public QObject /// Project title QString project_title_; /// QElectroTech version declared in the XML document at opening time - qreal m_project_qet_version = -1; + QVersionNumber m_project_qet_version; /// Whether options were modified bool m_modified = false; /// Whether the project is read only