mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Improve and simplify the use of versions
This commit is contained in:
parent
ad4e263198
commit
a0970b37b9
@ -22,9 +22,11 @@
|
||||
#include "diagramposition.h"
|
||||
#include "math.h"
|
||||
#include "qetapp.h"
|
||||
#include "qetversion.h"
|
||||
#include "titleblocktemplate.h"
|
||||
#include "titleblocktemplaterenderer.h"
|
||||
|
||||
|
||||
#include <QLocale>
|
||||
#include <QPainter>
|
||||
#include <utility>
|
||||
@ -317,7 +319,7 @@ void BorderTitleBlock::importTitleBlock(const TitleBlockProperties &ip) {
|
||||
setPlant(ip.plant);
|
||||
setLocMach(ip.locmach);
|
||||
setIndicerev(ip.indexrev);
|
||||
setVersion(QET::displayedVersion);
|
||||
setVersion(QetVersion::displayedVersion());
|
||||
setFolio(ip.folio);
|
||||
setAutoPageNum(ip.auto_page_num);
|
||||
if (m_edge != ip.display_at)
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "graphicspart/parttext.h"
|
||||
#include "ui/qetelementeditor.h"
|
||||
#include "ui/elementpropertieseditorwidget.h"
|
||||
#include "../qetversion.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <algorithm>
|
||||
@ -448,7 +449,7 @@ const QDomDocument ElementScene::toXml(bool all_parts)
|
||||
root.setAttribute("hotspot_y", QString("%1").arg(
|
||||
-(qRound(size.y() - (ymargin/2)))));
|
||||
|
||||
root.setAttribute("version", QET::version);
|
||||
QetVersion::toXmlAttribute(root);
|
||||
root.setAttribute("link_type", m_element_data.typeToString(m_element_data.m_type));
|
||||
|
||||
//Uuid used to compare two elements
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#include "../ElementsCollection/elementslocation.h"
|
||||
#include "../editor/graphicspart/partline.h"
|
||||
#include "../qet.h"
|
||||
#include "../qetapp.h"
|
||||
#include "../qetversion.h"
|
||||
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QDomElement>
|
||||
@ -154,19 +154,16 @@ bool ElementPictureFactory::build(const ElementsLocation &location,
|
||||
QDomElement dom = location.xml();
|
||||
|
||||
//Check if the current version can read the xml description
|
||||
if (dom.hasAttribute("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 "
|
||||
" a été enregistré avec une version"
|
||||
" ultérieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
}
|
||||
}
|
||||
const auto elmt_version = QetVersion::fromXmlAttribute(dom);
|
||||
if (!elmt_version.isNull()
|
||||
&& QetVersion::currentVersion() < elmt_version)
|
||||
{
|
||||
std::cerr << qPrintable(
|
||||
QObject::tr("Avertissement : l'élément "
|
||||
" a été enregistré avec une version"
|
||||
" ultérieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
}
|
||||
|
||||
//This attributes must be present and valid
|
||||
int w, h, hot_x, hot_y;
|
||||
|
@ -16,6 +16,9 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "machine_info.h"
|
||||
|
||||
#include "qetversion.h"
|
||||
|
||||
#include <QScreen>
|
||||
#include <QProcess>
|
||||
#include <QApplication>
|
||||
@ -28,7 +31,6 @@
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "qet.h"
|
||||
|
||||
MachineInfo *MachineInfo::m_instance = nullptr;
|
||||
/**
|
||||
@ -121,7 +123,7 @@ void MachineInfo::send_info_to_debug()
|
||||
#endif
|
||||
#endif
|
||||
qInfo() << "GitRevision " + QString(GIT_COMMIT_SHA);
|
||||
qInfo()<< "QElectroTech V " + QET::displayedVersion;
|
||||
qInfo()<< "QElectroTech V " + QetVersion::displayedVersion();
|
||||
qInfo()<< QObject::tr("Compilation : ") + pc.built.version;
|
||||
qInfo()<< "Built with Qt " + pc.built.QT
|
||||
+ " - " + pc.built.arch
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "../diagram.h"
|
||||
#include "../qeticons.h"
|
||||
#include "../qetproject.h"
|
||||
#include "../qetversion.h"
|
||||
|
||||
#include "ui_projectprintwindow.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||
@ -84,7 +86,7 @@ void ProjectPrintWindow::launchDialog(QETProject *project, QPrinter::OutputForma
|
||||
if (!file_name.endsWith(".pdf")) {
|
||||
file_name.append(".pdf");
|
||||
}
|
||||
printer_->setCreator(QString("QElectroTech %1").arg(QET::displayedVersion));
|
||||
printer_->setCreator(QString("QElectroTech %1").arg(QetVersion::displayedVersion()));
|
||||
printer_->setOutputFileName(file_name);
|
||||
printer_->setOutputFormat(QPrinter::PdfFormat);
|
||||
}
|
||||
|
@ -28,10 +28,6 @@ class QActionGroup;
|
||||
anywhere else within the QElectroTech application.
|
||||
*/
|
||||
namespace QET {
|
||||
/// QElectroTech version (as string, used to mark projects and elements XML documents)
|
||||
const QString version = "0.100";
|
||||
/// QElectroTech displayed version
|
||||
const QString displayedVersion = "0.100-DEV";
|
||||
QString license();
|
||||
|
||||
//Describe the current state of a graphic item
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "ui/configpage/generalconfigurationpage.h"
|
||||
#include "machine_info.h"
|
||||
#include "TerminalStrip/ui/terminalstripeditorwindow.h"
|
||||
#include "qetversion.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
@ -2314,7 +2315,7 @@ void QETApp::printHelp()
|
||||
*/
|
||||
void QETApp::printVersion()
|
||||
{
|
||||
std::cout << qPrintable(QET::displayedVersion) << std::endl;
|
||||
std::cout << qPrintable(QetVersion::displayedVersion()) << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "elementtextitemgroup.h"
|
||||
#include "iostream"
|
||||
#include "../qetxml.h"
|
||||
#include "../qetversion.h"
|
||||
|
||||
#include <QDomElement>
|
||||
#include <utility>
|
||||
@ -426,20 +427,17 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
return(false);
|
||||
}
|
||||
|
||||
//Check if the current version can read the xml description
|
||||
if (xml_def_elmt.hasAttribute(QStringLiteral("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 "
|
||||
" a été enregistré avec une version"
|
||||
" ultérieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
}
|
||||
}
|
||||
//Check if the current version can read the xml description
|
||||
const auto elmt_version = QetVersion::fromXmlAttribute(xml_def_elmt);
|
||||
if (!elmt_version.isNull()
|
||||
&& QetVersion::currentVersion() < elmt_version)
|
||||
{
|
||||
std::cerr << qPrintable(
|
||||
QObject::tr("Avertissement : l'élément "
|
||||
" a été enregistré avec une version"
|
||||
" ultérieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
}
|
||||
|
||||
//This attribute must be present and valid
|
||||
int w = 0, h = 0, hot_x = 0, hot_y = 0;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "ui/importelementdialog.h"
|
||||
#include "TerminalStrip/terminalstrip.h"
|
||||
#include "qetxml.h"
|
||||
#include "qetversion.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QStandardPaths>
|
||||
@ -907,7 +908,7 @@ QDomDocument QETProject::toXml()
|
||||
// racine du projet
|
||||
QDomDocument xml_doc;
|
||||
QDomElement project_root = xml_doc.createElement("project");
|
||||
project_root.setAttribute("version", QET::version);
|
||||
QetVersion::toXmlAttribute(project_root);
|
||||
if (project_title_.isEmpty())
|
||||
{
|
||||
// if project_title_is Empty add title from m_file_path
|
||||
@ -1337,18 +1338,11 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
if (root_elmt.tagName() == QLatin1String("project"))
|
||||
{
|
||||
//Normal opening mode
|
||||
if (root_elmt.hasAttribute(QStringLiteral("version")))
|
||||
m_project_qet_version = QetVersion::fromXmlAttribute(root_elmt);
|
||||
if (!m_project_qet_version.isNull())
|
||||
{
|
||||
bool 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 (qet_version < m_project_qet_version)
|
||||
if (QetVersion::currentVersion() < m_project_qet_version)
|
||||
{
|
||||
|
||||
int ret = QET::QetMessageBox::warning(
|
||||
nullptr,
|
||||
tr("Avertissement",
|
||||
@ -1357,7 +1351,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
"\n qui est ultérieure à votre version !"
|
||||
" \n"
|
||||
"Vous utilisez actuellement QElectroTech en version %2")
|
||||
.arg(root_elmt.attribute(QStringLiteral("version")), QET::version +
|
||||
.arg(root_elmt.attribute(QStringLiteral("version")), QetVersion::currentVersion().toString() +
|
||||
tr(".\n Il est alors possible que l'ouverture de tout ou partie de ce "
|
||||
"document échoue.\n"
|
||||
"Que désirez vous faire ?"),
|
||||
@ -1374,16 +1368,14 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
|
||||
//Since QElectrotech 0.9 the compatibility with project made with
|
||||
//Qet 0.6 or lower is break;
|
||||
//keep float here for very old version
|
||||
qreal r_project_qet_version = root_elmt.attribute(QStringLiteral("version")).toDouble(&conv_ok);
|
||||
if (conv_ok && m_project_qet_version < QVersionNumber(0, 100) && r_project_qet_version <= 0.6)
|
||||
if (m_project_qet_version <= QetVersion::versionZeroDotSix())
|
||||
{
|
||||
auto ret = QET::QetMessageBox::warning(
|
||||
nullptr,
|
||||
tr("Avertissement ", "message box title"),
|
||||
tr("Le projet que vous tentez d'ouvrir est partiellement "
|
||||
"compatible avec votre version %1 de QElectroTech.\n")
|
||||
.arg(QET::version) +
|
||||
.arg(QetVersion::currentVersion().toString()) +
|
||||
tr("Afin de le rendre totalement compatible veuillez ouvrir ce même projet "
|
||||
"avec la version 0.8, ou 0.80 de QElectroTech et sauvegarder le projet "
|
||||
"et l'ouvrir à nouveau avec cette version.\n"
|
||||
|
85
sources/qetversion.cpp
Normal file
85
sources/qetversion.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qetversion.h"
|
||||
|
||||
namespace QetVersion
|
||||
{
|
||||
QetVersion::VersionType VERSION_TYPE = QetVersion::dev;
|
||||
|
||||
QVersionNumber currentVersion()
|
||||
{
|
||||
return QVersionNumber{ 0, 100, 0 };
|
||||
}
|
||||
|
||||
QString displayedVersion()
|
||||
{
|
||||
auto str = currentVersion().toString();
|
||||
|
||||
switch (VERSION_TYPE) {
|
||||
case dev:
|
||||
str.append(QStringLiteral("-dev"));
|
||||
break;
|
||||
case alpha1:
|
||||
str.append(QStringLiteral("-alpha 1 "));
|
||||
break;
|
||||
case alpha2:
|
||||
str.append(QStringLiteral("-alpha 2 "));
|
||||
break;
|
||||
case alpha3:
|
||||
str.append(QStringLiteral("-alpha 3 "));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief toXmlAttribute
|
||||
* Write @a version as an attribute of @a xml
|
||||
* @param xml
|
||||
* @param version
|
||||
*/
|
||||
void toXmlAttribute(QDomElement &xml)
|
||||
{
|
||||
xml.setAttribute(QStringLiteral("version"), currentVersion().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief fromXmlAttribute
|
||||
* Read and return a QVersionNumber
|
||||
* stored as attribute of @a xml
|
||||
* @param xml
|
||||
* @return the version stored in @a xml.
|
||||
* Note that the returned version can be null
|
||||
*/
|
||||
QVersionNumber fromXmlAttribute(const QDomElement &xml)
|
||||
{
|
||||
if (xml.hasAttribute(QStringLiteral("version"))) {
|
||||
return QVersionNumber::fromString(xml.attribute(QStringLiteral("version")));
|
||||
} else {
|
||||
return QVersionNumber{};
|
||||
}
|
||||
}
|
||||
|
||||
QVersionNumber versionZeroDotSix()
|
||||
{
|
||||
return QVersionNumber{ 0, 60 };
|
||||
}
|
||||
}
|
43
sources/qetversion.h
Normal file
43
sources/qetversion.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2006-2023 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QETVERSION_H
|
||||
#define QETVERSION_H
|
||||
|
||||
#include <QVersionNumber>
|
||||
#include <QDomElement>
|
||||
|
||||
namespace QetVersion
|
||||
{
|
||||
enum VersionType {
|
||||
dev = 0,
|
||||
alpha1 = 1,
|
||||
alpha2 = 2,
|
||||
alpha3 = 3,
|
||||
stable = 4
|
||||
};
|
||||
|
||||
QVersionNumber currentVersion();
|
||||
QString displayedVersion();
|
||||
|
||||
QVersionNumber versionZeroDotSix();
|
||||
|
||||
void toXmlAttribute(QDomElement &xml);
|
||||
QVersionNumber fromXmlAttribute(const QDomElement &xml);
|
||||
}
|
||||
|
||||
#endif // QETVERSION_H
|
@ -21,6 +21,7 @@
|
||||
#include "../qet.h"
|
||||
#include "../qetapp.h"
|
||||
#include "ui_aboutqetdialog.h"
|
||||
#include "../qetversion.h"
|
||||
|
||||
#include <QDate>
|
||||
|
||||
@ -165,7 +166,7 @@ void AboutQETDialog::setContributors()
|
||||
void AboutQETDialog::setVersion()
|
||||
{
|
||||
QString str = "<span style=\"font-weight:bold;font-size:16pt;\">QElectroTech V "
|
||||
+ QET::displayedVersion
|
||||
+ QetVersion::displayedVersion()
|
||||
+ "</span>";
|
||||
ui->m_version_label->setText(str + MachineInfo::instance()->compilation_info());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user