mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Fix Qt 6 deprecated Qt::SystemLocaleShortDate
The format options Qt::SystemLocaleDate, Qt::SystemLocaleShortDate and Qt::SystemLocaleLongDate shall be removed in Qt 6. Their use should be replaced with QLocale::system().toString(date, QLocale::ShortFormat) or QLocale::system().toString(date, QLocale::LongFormat).
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "titleblocktemplate.h"
|
#include "titleblocktemplate.h"
|
||||||
#include "titleblocktemplaterenderer.h"
|
#include "titleblocktemplaterenderer.h"
|
||||||
#include "bordertitleblock.h"
|
#include "bordertitleblock.h"
|
||||||
@@ -934,9 +936,12 @@ void BorderTitleBlock::updateDiagramContextForTitleBlock(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... overridden by the historical and/or dynamically generated fields
|
// ... overridden by the historical and/or dynamically generated fields
|
||||||
|
QLocale var;
|
||||||
|
var.dateFormat(QLocale::ShortFormat);
|
||||||
context.addValue("author", btb_author_);
|
context.addValue("author", btb_author_);
|
||||||
context.addValue("date", btb_date_.toString(
|
context.addValue(
|
||||||
Qt::SystemLocaleShortDate));
|
"date",
|
||||||
|
QLocale::system().toString(btb_date_, QLocale::ShortFormat));
|
||||||
context.addValue("title", btb_title_);
|
context.addValue("title", btb_title_);
|
||||||
context.addValue("filename", btb_filename_);
|
context.addValue("filename", btb_filename_);
|
||||||
context.addValue("plant", btb_plant_);
|
context.addValue("plant", btb_plant_);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
|
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_WINDOWS)
|
||||||
#include <QSqlDriver>
|
#include <QSqlDriver>
|
||||||
@@ -161,7 +162,11 @@ void projectDataBase::addDiagram(Diagram *diagram)
|
|||||||
for (auto key : QETApp::diagramInfoKeys())
|
for (auto key : QETApp::diagramInfoKeys())
|
||||||
{
|
{
|
||||||
if (key == "date") {
|
if (key == "date") {
|
||||||
m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
|
m_insert_diagram_info_query.bindValue(
|
||||||
|
":date",
|
||||||
|
QLocale::system().toString(
|
||||||
|
infos.value("date").toDate(),
|
||||||
|
QLocale::ShortFormat));
|
||||||
} else {
|
} else {
|
||||||
auto value = infos.value(key);
|
auto value = infos.value(key);
|
||||||
auto bind = key.prepend(":");
|
auto bind = key.prepend(":");
|
||||||
@@ -419,7 +424,11 @@ void projectDataBase::populateDiagramInfoTable()
|
|||||||
for (auto key : QETApp::diagramInfoKeys())
|
for (auto key : QETApp::diagramInfoKeys())
|
||||||
{
|
{
|
||||||
if (key == "date") {
|
if (key == "date") {
|
||||||
m_insert_diagram_info_query.bindValue(":date", QDate::fromString(infos.value("date").toString(), Qt::SystemLocaleShortDate));
|
m_insert_diagram_info_query.bindValue(
|
||||||
|
":date",
|
||||||
|
QLocale::system().toString(
|
||||||
|
infos.value("date").toDate(),
|
||||||
|
QLocale::ShortFormat));
|
||||||
} else {
|
} else {
|
||||||
auto value = infos.value(key);
|
auto value = infos.value(key);
|
||||||
auto bind = key.prepend(":");
|
auto bind = key.prepend(":");
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2020 The QElectroTech Team
|
Copyright 2006-2020 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
QElectroTech is distributed in the hope that it will be useful,
|
QElectroTech is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
@@ -279,7 +279,7 @@ void QETProject::setFilePath(const QString &filepath)
|
|||||||
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
|
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
|
||||||
|
|
||||||
m_file_path = filepath;
|
m_file_path = filepath;
|
||||||
|
|
||||||
QFileInfo fi(m_file_path);
|
QFileInfo fi(m_file_path);
|
||||||
if (fi.isWritable()) {
|
if (fi.isWritable()) {
|
||||||
setReadOnly(false);
|
setReadOnly(false);
|
||||||
@@ -290,9 +290,9 @@ void QETProject::setFilePath(const QString &filepath)
|
|||||||
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
||||||
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
||||||
m_project_properties.addValue("savedfilepath", filePath());
|
m_project_properties.addValue("savedfilepath", filePath());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
emit(projectFilePathChanged(this, m_file_path));
|
emit(projectFilePathChanged(this, m_file_path));
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
@@ -315,7 +315,7 @@ QString QETProject::currentDir() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@return une chaine de caractere du type "Projet titre du projet".
|
@return une chaine de caractere du type "Projet titre du projet".
|
||||||
Si le projet n'a pas de titre, le nom du fichier est utilise.
|
Si le projet n'a pas de titre, le nom du fichier est utilise.
|
||||||
Si le projet n'est pas associe a un fichier, cette methode retourne "Projet
|
Si le projet n'est pas associe a un fichier, cette methode retourne "Projet
|
||||||
@@ -326,7 +326,7 @@ QString QETProject::currentDir() const
|
|||||||
QString QETProject::pathNameTitle() const
|
QString QETProject::pathNameTitle() const
|
||||||
{
|
{
|
||||||
QString final_title;
|
QString final_title;
|
||||||
|
|
||||||
if (!project_title_.isEmpty()) {
|
if (!project_title_.isEmpty()) {
|
||||||
final_title = QString(
|
final_title = QString(
|
||||||
tr(
|
tr(
|
||||||
@@ -349,7 +349,7 @@ QString QETProject::pathNameTitle() const
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
final_title = QString(
|
final_title = QString(
|
||||||
tr(
|
tr(
|
||||||
@@ -366,7 +366,7 @@ QString QETProject::pathNameTitle() const
|
|||||||
)
|
)
|
||||||
).arg(final_title);
|
).arg(final_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(final_title);
|
return(final_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,10 +394,10 @@ qreal QETProject::declaredQElectroTechVersion()
|
|||||||
void QETProject::setTitle(const QString &title) {
|
void QETProject::setTitle(const QString &title) {
|
||||||
// ne fait rien si le projet est en lecture seule
|
// ne fait rien si le projet est en lecture seule
|
||||||
if (isReadOnly()) return;
|
if (isReadOnly()) return;
|
||||||
|
|
||||||
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
|
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
|
||||||
if (project_title_ == title) return;
|
if (project_title_ == title) return;
|
||||||
|
|
||||||
project_title_ = title;
|
project_title_ = title;
|
||||||
emit(projectTitleChanged(this, project_title_));
|
emit(projectTitleChanged(this, project_title_));
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
@@ -487,7 +487,7 @@ void QETProject::setDefaultReportProperties(const QString &properties)
|
|||||||
{
|
{
|
||||||
QString old = m_default_report_properties;
|
QString old = m_default_report_properties;
|
||||||
m_default_report_properties = properties;
|
m_default_report_properties = properties;
|
||||||
|
|
||||||
emit reportPropertiesChanged(old, properties);
|
emit reportPropertiesChanged(old, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,7 +856,7 @@ QDomDocument QETProject::toXml()
|
|||||||
project_root.setAttribute("version", QET::version);
|
project_root.setAttribute("version", QET::version);
|
||||||
project_root.setAttribute("title", project_title_);
|
project_root.setAttribute("title", project_title_);
|
||||||
xml_doc.appendChild(project_root);
|
xml_doc.appendChild(project_root);
|
||||||
|
|
||||||
// titleblock templates, if any
|
// titleblock templates, if any
|
||||||
if (m_titleblocks_collection.templates().count()) {
|
if (m_titleblocks_collection.templates().count()) {
|
||||||
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
||||||
@@ -866,19 +866,19 @@ QDomDocument QETProject::toXml()
|
|||||||
}
|
}
|
||||||
project_root.appendChild(titleblocktemplates_elmt);
|
project_root.appendChild(titleblocktemplates_elmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// project-wide properties
|
// project-wide properties
|
||||||
QDomElement project_properties = xml_doc.createElement("properties");
|
QDomElement project_properties = xml_doc.createElement("properties");
|
||||||
writeProjectPropertiesXml(project_properties);
|
writeProjectPropertiesXml(project_properties);
|
||||||
project_root.appendChild(project_properties);
|
project_root.appendChild(project_properties);
|
||||||
|
|
||||||
// Properties for news diagrams
|
// Properties for news diagrams
|
||||||
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
||||||
writeDefaultPropertiesXml(new_diagrams_properties);
|
writeDefaultPropertiesXml(new_diagrams_properties);
|
||||||
project_root.appendChild(new_diagrams_properties);
|
project_root.appendChild(new_diagrams_properties);
|
||||||
|
|
||||||
// schemas
|
// schemas
|
||||||
|
|
||||||
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
|
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
|
||||||
int order_num = 1;
|
int order_num = 1;
|
||||||
const QList<Diagram *> diagrams_list = m_diagrams_list;
|
const QList<Diagram *> diagrams_list = m_diagrams_list;
|
||||||
@@ -895,10 +895,10 @@ QDomDocument QETProject::toXml()
|
|||||||
QDomNode appended_diagram = project_root.appendChild(xml_node);
|
QDomNode appended_diagram = project_root.appendChild(xml_node);
|
||||||
appended_diagram.toElement().setAttribute("order", order_num ++);
|
appended_diagram.toElement().setAttribute("order", order_num ++);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the elements collection.
|
// Write the elements collection.
|
||||||
project_root.appendChild(m_elements_collection->root().cloneNode(true));
|
project_root.appendChild(m_elements_collection->root().cloneNode(true));
|
||||||
|
|
||||||
return(xml_doc);
|
return(xml_doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,16 +932,20 @@ QETResult QETProject::write()
|
|||||||
QString error_message;
|
QString error_message;
|
||||||
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
|
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
|
||||||
return(error_message);
|
return(error_message);
|
||||||
|
|
||||||
//title block variables should be updated after file save dialog is confirmed, before file is saved.
|
//title block variables should be updated after file save dialog is confirmed, before file is saved.
|
||||||
m_project_properties.addValue("saveddate", QDate::currentDate().toString(Qt::SystemLocaleShortDate));
|
m_project_properties.addValue(
|
||||||
|
"saveddate",
|
||||||
|
QDate::currentDate().toString(
|
||||||
|
QLocale::system().toString(
|
||||||
|
QLocale::ShortFormat)));
|
||||||
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
||||||
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
||||||
m_project_properties.addValue("savedfilepath", filePath());
|
m_project_properties.addValue("savedfilepath", filePath());
|
||||||
|
|
||||||
emit(projectInformationsChanged(this));
|
emit(projectInformationsChanged(this));
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
|
|
||||||
setModified(false);
|
setModified(false);
|
||||||
return(QETResult());
|
return(QETResult());
|
||||||
}
|
}
|
||||||
@@ -981,15 +985,15 @@ bool QETProject::isEmpty() const
|
|||||||
{
|
{
|
||||||
// si le projet a un titre, on considere qu'il n'est pas vide
|
// si le projet a un titre, on considere qu'il n'est pas vide
|
||||||
if (!project_title_.isEmpty()) return(false);
|
if (!project_title_.isEmpty()) return(false);
|
||||||
|
|
||||||
//@TODO check if the embedded element collection is empty
|
//@TODO check if the embedded element collection is empty
|
||||||
|
|
||||||
// compte le nombre de schemas non vides
|
// compte le nombre de schemas non vides
|
||||||
int pertinent_diagrams = 0;
|
int pertinent_diagrams = 0;
|
||||||
foreach(Diagram *diagram, m_diagrams_list) {
|
foreach(Diagram *diagram, m_diagrams_list) {
|
||||||
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
|
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(pertinent_diagrams > 0);
|
return(pertinent_diagrams > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1089,13 +1093,13 @@ ElementsLocation QETProject::importElement(ElementsLocation &location)
|
|||||||
Integrate a title block template into this project.
|
Integrate a title block template into this project.
|
||||||
@param src_tbt The location of the title block template
|
@param src_tbt The location of the title block template
|
||||||
to be integrated into this project
|
to be integrated into this project
|
||||||
@param handler
|
@param handler
|
||||||
@return the name of the template after integration,
|
@return the name of the template after integration,
|
||||||
or an empty QString if a problem occurred.
|
or an empty QString if a problem occurred.
|
||||||
*/
|
*/
|
||||||
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
|
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
|
||||||
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
|
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
|
||||||
|
|
||||||
// check whether a TBT having the same name already exists within this project
|
// check whether a TBT having the same name already exists within this project
|
||||||
QString target_name = dst_tbt.name();
|
QString target_name = dst_tbt.name();
|
||||||
while (m_titleblocks_collection.templates().contains(target_name))
|
while (m_titleblocks_collection.templates().contains(target_name))
|
||||||
@@ -1113,7 +1117,7 @@ QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation
|
|||||||
return(target_name);
|
return(target_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
|
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
|
||||||
{
|
{
|
||||||
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
|
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
|
||||||
@@ -1164,7 +1168,7 @@ QList<ElementsLocation> QETProject::unusedElements() const
|
|||||||
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
|
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
|
||||||
// a diagram can only use a title block template embedded wihtin its parent project
|
// a diagram can only use a title block template embedded wihtin its parent project
|
||||||
if (location.parentProject() != this) return(false);
|
if (location.parentProject() != this) return(false);
|
||||||
|
|
||||||
foreach (Diagram *diagram, diagrams()) {
|
foreach (Diagram *diagram, diagrams()) {
|
||||||
if (diagram -> usesTitleBlockTemplate(location.name())) {
|
if (diagram -> usesTitleBlockTemplate(location.name())) {
|
||||||
return(true);
|
return(true);
|
||||||
@@ -1184,9 +1188,9 @@ Diagram *QETProject::addNewDiagram(int pos)
|
|||||||
if (isReadOnly()) {
|
if (isReadOnly()) {
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Diagram *diagram = new Diagram(this);
|
Diagram *diagram = new Diagram(this);
|
||||||
|
|
||||||
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
|
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
|
||||||
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
||||||
diagram->defaultConductorProperties = defaultConductorProperties();
|
diagram->defaultConductorProperties = defaultConductorProperties();
|
||||||
@@ -1214,7 +1218,7 @@ void QETProject::removeDiagram(Diagram *diagram)
|
|||||||
emit(diagramRemoved(this, diagram));
|
emit(diagramRemoved(this, diagram));
|
||||||
diagram->deleteLater();
|
diagram->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1228,10 +1232,10 @@ void QETProject::removeDiagram(Diagram *diagram)
|
|||||||
*/
|
*/
|
||||||
void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
||||||
if (old_index < 0 || new_index < 0) return;
|
if (old_index < 0 || new_index < 0) return;
|
||||||
|
|
||||||
int diagram_max_index = m_diagrams_list.size() - 1;
|
int diagram_max_index = m_diagrams_list.size() - 1;
|
||||||
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
|
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
|
||||||
|
|
||||||
m_diagrams_list.move(old_index, new_index);
|
m_diagrams_list.move(old_index, new_index);
|
||||||
updateDiagramsFolioData();
|
updateDiagramsFolioData();
|
||||||
setModified(true);
|
setModified(true);
|
||||||
@@ -1258,7 +1262,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
{
|
{
|
||||||
QDomElement root_elmt = xml_project.documentElement();
|
QDomElement root_elmt = xml_project.documentElement();
|
||||||
m_state = ProjectParsingRunning;
|
m_state = ProjectParsingRunning;
|
||||||
|
|
||||||
//The roots of the xml document must be a "project" element
|
//The roots of the xml document must be a "project" element
|
||||||
if (root_elmt.tagName() == "project")
|
if (root_elmt.tagName() == "project")
|
||||||
{
|
{
|
||||||
@@ -1282,7 +1286,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
"message box content"),
|
"message box content"),
|
||||||
QMessageBox::Open | QMessageBox::Cancel
|
QMessageBox::Open | QMessageBox::Cancel
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ret == QMessageBox::Cancel)
|
if (ret == QMessageBox::Cancel)
|
||||||
{
|
{
|
||||||
m_state = FileOpenDiscard;
|
m_state = FileOpenDiscard;
|
||||||
@@ -1296,7 +1300,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
{
|
{
|
||||||
m_state = ProjectParsingFailed;
|
m_state = ProjectParsingFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data_base.blockSignals(true);
|
m_data_base.blockSignals(true);
|
||||||
//Load the project-wide properties
|
//Load the project-wide properties
|
||||||
readProjectPropertiesXml(xml_project);
|
readProjectPropertiesXml(xml_project);
|
||||||
@@ -1310,7 +1314,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
|||||||
readDiagramsXml(xml_project);
|
readDiagramsXml(xml_project);
|
||||||
m_data_base.blockSignals(false);
|
m_data_base.blockSignals(false);
|
||||||
m_data_base.updateDB();
|
m_data_base.updateDB();
|
||||||
|
|
||||||
m_state = Ok;
|
m_state = Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1336,18 +1340,18 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
|||||||
"Création des folios"
|
"Création des folios"
|
||||||
"</p>"));
|
"</p>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Search the diagrams in the project
|
//Search the diagrams in the project
|
||||||
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
|
QDomNodeList diagram_nodes = xml_project.elementsByTagName("diagram");
|
||||||
|
|
||||||
if(dlgWaiting)
|
if(dlgWaiting)
|
||||||
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
||||||
|
|
||||||
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
|
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
|
||||||
{
|
{
|
||||||
if(dlgWaiting)
|
if(dlgWaiting)
|
||||||
dlgWaiting->setProgressBar(i+1);
|
dlgWaiting->setProgressBar(i+1);
|
||||||
|
|
||||||
if (diagram_nodes.at(i).isElement())
|
if (diagram_nodes.at(i).isElement())
|
||||||
{
|
{
|
||||||
QDomElement diagram_xml_element = diagram_nodes
|
QDomElement diagram_xml_element = diagram_nodes
|
||||||
@@ -1543,17 +1547,17 @@ void QETProject::writeProjectPropertiesXml(QDomElement &xml_element) {
|
|||||||
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
QDomDocument xml_document = xml_element.ownerDocument();
|
QDomDocument xml_document = xml_element.ownerDocument();
|
||||||
|
|
||||||
// export size of border
|
// export size of border
|
||||||
QDomElement border_elmt = xml_document.createElement("border");
|
QDomElement border_elmt = xml_document.createElement("border");
|
||||||
default_border_properties_.toXml(border_elmt);
|
default_border_properties_.toXml(border_elmt);
|
||||||
xml_element.appendChild(border_elmt);
|
xml_element.appendChild(border_elmt);
|
||||||
|
|
||||||
// export content of titleblock
|
// export content of titleblock
|
||||||
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
||||||
default_titleblock_properties_.toXml(titleblock_elmt);
|
default_titleblock_properties_.toXml(titleblock_elmt);
|
||||||
xml_element.appendChild(titleblock_elmt);
|
xml_element.appendChild(titleblock_elmt);
|
||||||
|
|
||||||
// exporte default conductor
|
// exporte default conductor
|
||||||
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
||||||
default_conductor_properties_.toXml(conductor_elmt);
|
default_conductor_properties_.toXml(conductor_elmt);
|
||||||
@@ -1728,7 +1732,7 @@ bool QETProject::projectWasModified()
|
|||||||
!m_undo_stack -> isClean() ||
|
!m_undo_stack -> isClean() ||
|
||||||
m_titleblocks_collection.templates().count() )
|
m_titleblocks_collection.templates().count() )
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
else
|
else
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -1740,19 +1744,19 @@ bool QETProject::projectWasModified()
|
|||||||
void QETProject::updateDiagramsFolioData()
|
void QETProject::updateDiagramsFolioData()
|
||||||
{
|
{
|
||||||
int total_folio = m_diagrams_list.count();
|
int total_folio = m_diagrams_list.count();
|
||||||
|
|
||||||
DiagramContext project_wide_properties = m_project_properties;
|
DiagramContext project_wide_properties = m_project_properties;
|
||||||
project_wide_properties.addValue("projecttitle", title());
|
project_wide_properties.addValue("projecttitle", title());
|
||||||
project_wide_properties.addValue("projectpath", filePath());
|
project_wide_properties.addValue("projectpath", filePath());
|
||||||
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
||||||
|
|
||||||
for (int i = 0 ; i < total_folio ; ++ i)
|
for (int i = 0 ; i < total_folio ; ++ i)
|
||||||
{
|
{
|
||||||
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
|
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
|
||||||
NumerotationContext nC = folioAutoNum(autopagenum);
|
NumerotationContext nC = folioAutoNum(autopagenum);
|
||||||
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
||||||
|
|
||||||
if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
|
if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
|
||||||
(!autopagenum.isNull()))
|
(!autopagenum.isNull()))
|
||||||
{
|
{
|
||||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
||||||
@@ -1761,12 +1765,12 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
else {
|
else {
|
||||||
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(m_diagrams_list.at(i-1)->border_and_titleblock.finalfolio());
|
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(m_diagrams_list.at(i-1)->border_and_titleblock.finalfolio());
|
||||||
m_diagrams_list.at(i-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
|
m_diagrams_list.at(i-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
|
||||||
|
|
||||||
if (i == total_folio-1) {
|
if (i == total_folio-1) {
|
||||||
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
|
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
|
||||||
}
|
}
|
||||||
@@ -1775,7 +1779,7 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
|
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Diagram *d : m_diagrams_list) {
|
for (Diagram *d : m_diagrams_list) {
|
||||||
d->update();
|
d->update();
|
||||||
}
|
}
|
||||||
@@ -1788,7 +1792,7 @@ void QETProject::updateDiagramsFolioData()
|
|||||||
*/
|
*/
|
||||||
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
||||||
Q_UNUSED(collection)
|
Q_UNUSED(collection)
|
||||||
|
|
||||||
foreach (Diagram *diagram, m_diagrams_list) {
|
foreach (Diagram *diagram, m_diagrams_list) {
|
||||||
diagram -> titleBlockTemplateChanged(template_name);
|
diagram -> titleBlockTemplateChanged(template_name);
|
||||||
}
|
}
|
||||||
@@ -1801,7 +1805,7 @@ void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection
|
|||||||
*/
|
*/
|
||||||
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
||||||
Q_UNUSED(collection)
|
Q_UNUSED(collection)
|
||||||
|
|
||||||
// warn diagrams that the given template is about to be removed
|
// warn diagrams that the given template is about to be removed
|
||||||
foreach (Diagram *diagram, m_diagrams_list) {
|
foreach (Diagram *diagram, m_diagrams_list) {
|
||||||
diagram -> titleBlockTemplateRemoved(template_name);
|
diagram -> titleBlockTemplateRemoved(template_name);
|
||||||
|
|||||||
Reference in New Issue
Block a user