2020-08-02 22:24:46 +02:00
|
|
|
|
/*
|
2023-01-01 17:05:57 +01:00
|
|
|
|
Copyright 2006-2023 The QElectroTech Team
|
2009-04-03 19:30:25 +00:00
|
|
|
|
This file is part of QElectroTech.
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
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.
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
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.
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2020-09-21 21:19:50 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
#include "qetproject.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
|
|
#include "ElementsCollection/xmlelementcollection.h"
|
|
|
|
|
#include "autoNum/assignvariables.h"
|
|
|
|
|
#include "autoNum/numerotationcontext.h"
|
|
|
|
|
#include "autoNum/numerotationcontextcommands.h"
|
2009-04-03 19:30:25 +00:00
|
|
|
|
#include "diagram.h"
|
|
|
|
|
#include "qetapp.h"
|
2009-08-09 16:02:14 +00:00
|
|
|
|
#include "qetmessagebox.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include "qetresult.h"
|
|
|
|
|
#include "titleblock/integrationmovetemplateshandler.h"
|
|
|
|
|
#include "titleblock/movetemplateshandler.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
|
#include "titleblocktemplate.h"
|
2013-04-11 06:55:00 +00:00
|
|
|
|
#include "ui/dialogwaiting.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include "ui/importelementdialog.h"
|
2021-09-10 23:30:20 +02:00
|
|
|
|
#include "TerminalStrip/terminalstrip.h"
|
|
|
|
|
#include "qetxml.h"
|
2016-05-13 15:00:22 +00:00
|
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include <QHash>
|
2020-10-03 16:04:54 +02:00
|
|
|
|
#include <QStandardPaths>
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include <QTimer>
|
2020-10-03 16:04:54 +02:00
|
|
|
|
#include <QtConcurrent>
|
|
|
|
|
#include <QtDebug>
|
2020-12-08 19:57:35 +01:00
|
|
|
|
#include <utility>
|
2020-10-03 16:04:54 +02:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
static int BACKUP_INTERVAL = 120000; //interval in ms of backup = 2min
|
2018-05-24 18:08:06 +00:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::QETProject
|
|
|
|
|
Create a empty project
|
|
|
|
|
@param parent
|
|
|
|
|
*/
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QETProject::QETProject(QObject *parent) :
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QObject (parent),
|
2020-04-12 18:51:38 +02:00
|
|
|
|
m_titleblocks_collection(this),
|
|
|
|
|
m_data_base(this, this)
|
2009-04-03 19:30:25 +00:00
|
|
|
|
{
|
2020-04-09 16:58:05 +02:00
|
|
|
|
setDefaultTitleBlockProperties(TitleBlockProperties::defaultProperties());
|
|
|
|
|
|
2015-12-16 17:16:15 +00:00
|
|
|
|
m_elements_collection = new XmlElementCollection(this);
|
2019-03-16 10:50:30 +00:00
|
|
|
|
init();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::QETProject
|
|
|
|
|
Construct a project from a .qet file
|
|
|
|
|
@param path : path of the file
|
|
|
|
|
@param parent : parent QObject
|
|
|
|
|
*/
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QETProject::QETProject(const QString &path, QObject *parent) :
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QObject (parent),
|
2020-04-12 18:51:38 +02:00
|
|
|
|
m_titleblocks_collection(this),
|
|
|
|
|
m_data_base(this, this)
|
2009-04-03 19:30:25 +00:00
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QFile file(path);
|
|
|
|
|
m_state = openFile(&file);
|
|
|
|
|
if (m_state != ProjectState::Ok) {
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-03-16 10:50:30 +00:00
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 23:06:08 +01:00
|
|
|
|
#ifdef BUILD_WITHOUT_KF5
|
|
|
|
|
#else
|
2019-03-16 10:50:30 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::QETProject
|
|
|
|
|
@param backup : backup file to open, QETProject take ownership of backup.
|
|
|
|
|
@param parent : parent QObject
|
|
|
|
|
*/
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QETProject::QETProject(KAutoSaveFile *backup, QObject *parent) :
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QObject (parent),
|
2020-04-12 18:51:38 +02:00
|
|
|
|
m_titleblocks_collection(this),
|
|
|
|
|
m_data_base(this, this)
|
2019-03-16 10:50:30 +00:00
|
|
|
|
{
|
|
|
|
|
m_state = openFile(backup);
|
|
|
|
|
//Failed to open from the backup, try to open the crashed
|
|
|
|
|
if (m_state != ProjectState::Ok)
|
2015-11-15 19:47:15 +00:00
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QFile file(backup->managedFile().path());
|
|
|
|
|
m_state = openFile(&file);
|
|
|
|
|
if(m_state != ProjectState::Ok)
|
|
|
|
|
{
|
|
|
|
|
backup->open(QIODevice::ReadWrite);
|
|
|
|
|
delete backup;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2019-03-16 10:50:30 +00:00
|
|
|
|
//Set the real path, instead of the path of the backup.
|
|
|
|
|
setFilePath(backup->managedFile().path());
|
|
|
|
|
delete backup;
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
//Set the project to read only mode if the file it.
|
|
|
|
|
QFileInfo fi(m_file_path);
|
|
|
|
|
setReadOnly(!fi.isWritable());
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
}
|
2020-12-16 23:06:08 +01:00
|
|
|
|
#endif
|
2019-03-16 10:50:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::~QETProject
|
|
|
|
|
Destructor
|
|
|
|
|
*/
|
2020-07-06 21:52:14 +02:00
|
|
|
|
QETProject::~QETProject()
|
|
|
|
|
{
|
2022-04-09 12:46:07 +02:00
|
|
|
|
//We block database signal to avoid hundreds of unnecessary emitted signal
|
|
|
|
|
//due to deletion (diagram, item, etc...) and as much update made in the not yet deleted things.
|
|
|
|
|
m_data_base.blockSignals(true);
|
|
|
|
|
|
2022-03-31 19:05:45 +02:00
|
|
|
|
//Each time a diagram is deleted we also remove it from m_diagram_list
|
|
|
|
|
//because a lot of thing append during the destructor of a diagram class
|
|
|
|
|
//and one of these thing (not directly in the destructor of the diagram
|
|
|
|
|
//but in another destructor called by the diagram destructor)
|
|
|
|
|
//is to get the diagram list of the project to make some updates @see QList<Diagram *> QETProject::diagrams() const.
|
|
|
|
|
//So we need to remove the freshly deleted diagram from the list
|
|
|
|
|
//in each iteration of the loop to avoid the use of a dangling pointer.
|
|
|
|
|
const auto diag_list = m_diagrams_list;
|
|
|
|
|
for (const auto &diagram : diag_list)
|
|
|
|
|
{
|
2020-07-07 22:11:39 +02:00
|
|
|
|
delete diagram;
|
2022-03-31 19:05:45 +02:00
|
|
|
|
m_diagrams_list.removeOne(diagram);
|
|
|
|
|
}
|
2019-03-16 10:50:30 +00:00
|
|
|
|
}
|
2014-01-05 15:00:46 +00:00
|
|
|
|
|
2020-04-12 18:51:38 +02:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::dataBase
|
|
|
|
|
@return The data base of this project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
projectDataBase *QETProject::dataBase()
|
|
|
|
|
{
|
2020-04-12 18:51:38 +02:00
|
|
|
|
return &m_data_base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::uuid
|
|
|
|
|
@return the uuid of this project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QUuid QETProject::uuid() const
|
|
|
|
|
{
|
2020-04-12 18:51:38 +02:00
|
|
|
|
return m_uuid;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::init
|
|
|
|
|
*/
|
2019-03-16 10:50:30 +00:00
|
|
|
|
void QETProject::init()
|
|
|
|
|
{
|
|
|
|
|
connect(&m_titleblocks_collection, &TitleBlockTemplatesCollection::changed, this, &QETProject::updateDiagramsTitleBlockTemplate);
|
|
|
|
|
connect(&m_titleblocks_collection, &TitleBlockTemplatesCollection::aboutToRemove, this, &QETProject::removeDiagramsTitleBlockTemplate);
|
|
|
|
|
|
|
|
|
|
m_undo_stack = new QUndoStack(this);
|
2018-05-24 18:08:06 +00:00
|
|
|
|
connect(m_undo_stack, SIGNAL(cleanChanged(bool)), this, SLOT(undoStackChanged(bool)));
|
2019-03-16 10:50:30 +00:00
|
|
|
|
|
2018-05-24 18:08:06 +00:00
|
|
|
|
m_save_backup_timer.setInterval(BACKUP_INTERVAL);
|
|
|
|
|
connect(&m_save_backup_timer, &QTimer::timeout, this, &QETProject::writeBackup);
|
|
|
|
|
m_save_backup_timer.start();
|
|
|
|
|
writeBackup();
|
2019-03-16 10:50:30 +00:00
|
|
|
|
|
2018-05-24 18:08:06 +00:00
|
|
|
|
QSettings settings;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
int autosave_interval = settings.value(QStringLiteral("diagrameditor/autosave-interval"), 0).toInt();
|
2018-05-24 18:08:06 +00:00
|
|
|
|
if(autosave_interval > 0)
|
|
|
|
|
{
|
|
|
|
|
int ms = autosave_interval*60*1000;
|
|
|
|
|
m_autosave_timer.setInterval(ms);
|
2022-04-09 13:07:47 +02:00
|
|
|
|
connect(&m_autosave_timer, &QTimer::timeout, this, [=]()
|
2018-05-24 18:08:06 +00:00
|
|
|
|
{
|
|
|
|
|
if(!this->m_file_path.isEmpty())
|
|
|
|
|
this->write();
|
|
|
|
|
});
|
|
|
|
|
m_autosave_timer.start();
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::openFile
|
|
|
|
|
@param file
|
|
|
|
|
@return
|
|
|
|
|
*/
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QETProject::ProjectState QETProject::openFile(QFile *file)
|
2009-04-03 19:30:25 +00:00
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
bool opened_here = file->isOpen() ? false : true;
|
2020-08-25 20:32:21 +02:00
|
|
|
|
if (!file->isOpen()
|
|
|
|
|
&& !file->open(QIODevice::ReadOnly
|
2020-10-03 16:04:54 +02:00
|
|
|
|
| QIODevice::Text)) {
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return FileOpenFailed;
|
|
|
|
|
}
|
|
|
|
|
QFileInfo fi(*file);
|
|
|
|
|
setFilePath(fi.absoluteFilePath());
|
|
|
|
|
|
|
|
|
|
//Extract the content of the xml
|
|
|
|
|
QDomDocument xml_project;
|
|
|
|
|
if (!xml_project.setContent(file))
|
2018-05-24 18:08:06 +00:00
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if(opened_here) {
|
|
|
|
|
file->close();
|
|
|
|
|
}
|
|
|
|
|
return XmlParsingFailed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Build the project from the xml
|
|
|
|
|
readProjectXml(xml_project);
|
|
|
|
|
|
|
|
|
|
if (!fi.isWritable()) {
|
|
|
|
|
setReadOnly(true);
|
|
|
|
|
}
|
|
|
|
|
if(opened_here) {
|
|
|
|
|
file->close();
|
2018-05-24 18:08:06 +00:00
|
|
|
|
}
|
2023-01-12 16:19:44 +01:00
|
|
|
|
return m_state;
|
2022-12-21 19:18:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::refresh
|
|
|
|
|
* Refresh everything in the project.
|
|
|
|
|
* This is notably use when open a project from file.
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::refresh()
|
|
|
|
|
{
|
|
|
|
|
DialogWaiting *dlgWaiting { nullptr };
|
|
|
|
|
if(DialogWaiting::hasInstance())
|
|
|
|
|
{
|
|
|
|
|
dlgWaiting = DialogWaiting::instance();
|
|
|
|
|
dlgWaiting->setModal(true);
|
|
|
|
|
dlgWaiting->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(const auto &diagram : diagrams())
|
|
|
|
|
{
|
|
|
|
|
if(dlgWaiting)
|
|
|
|
|
{
|
|
|
|
|
dlgWaiting->setProgressBar(dlgWaiting->progressBarValue()+1);
|
|
|
|
|
dlgWaiting->setDetail(diagram->title());
|
|
|
|
|
}
|
|
|
|
|
diagram->refreshContents();
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Cette methode peut etre utilisee pour tester la bonne ouverture d'un projet
|
|
|
|
|
@return l'etat du projet
|
|
|
|
|
@see ProjectState
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QETProject::ProjectState QETProject::state() const
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(m_state);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return la liste des schemas de ce projet
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QList<Diagram *> QETProject::diagrams() const
|
|
|
|
|
{
|
2017-03-05 13:10:47 +00:00
|
|
|
|
return(m_diagrams_list);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-08 19:03:13 +00:00
|
|
|
|
/**
|
|
|
|
|
@param diagram Pointer to a Diagram object
|
|
|
|
|
@return the folio number of the given diagram object within the project,
|
|
|
|
|
or -1 if it is not part of this project.
|
|
|
|
|
Note: this returns 0 for the first diagram, not 1
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
int QETProject::folioIndex(const Diagram *diagram) const
|
|
|
|
|
{
|
2011-09-08 19:03:13 +00:00
|
|
|
|
// QList::indexOf returns -1 if no item matched.
|
2017-03-05 13:10:47 +00:00
|
|
|
|
return(m_diagrams_list.indexOf(const_cast<Diagram *>(diagram)));
|
2011-09-08 19:03:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 17:16:15 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::embeddedCollection
|
|
|
|
|
@return The embedded collection
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
XmlElementCollection *QETProject::embeddedElementCollection() const
|
|
|
|
|
{
|
2015-12-16 17:16:15 +00:00
|
|
|
|
return m_elements_collection;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-08 17:04:34 +00:00
|
|
|
|
/**
|
|
|
|
|
@return the title block templates collection enbeedded within this project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
TitleBlockTemplatesProjectCollection *QETProject::embeddedTitleBlockTemplatesCollection()
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(&m_titleblocks_collection);
|
2012-01-08 17:04:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
|
|
|
|
@return le chemin du fichier dans lequel ce projet est enregistre
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::filePath()
|
|
|
|
|
{
|
2018-05-24 18:08:06 +00:00
|
|
|
|
return(m_file_path);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setFilePath
|
|
|
|
|
Set the filepath of this project file
|
|
|
|
|
Set a file path also create a backup file according to the path.
|
|
|
|
|
If a previous path was set, the previous backup file is deleted and a new one
|
|
|
|
|
is created according to the path.
|
|
|
|
|
@param filepath
|
|
|
|
|
*/
|
2019-03-16 10:50:30 +00:00
|
|
|
|
void QETProject::setFilePath(const QString &filepath)
|
|
|
|
|
{
|
|
|
|
|
if (filepath == m_file_path) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-16 23:06:08 +01:00
|
|
|
|
#ifdef BUILD_WITHOUT_KF5
|
|
|
|
|
#else
|
2020-08-02 22:24:46 +02:00
|
|
|
|
if (m_backup_file.isOpen()) {
|
|
|
|
|
m_backup_file.close();
|
2019-03-16 10:50:30 +00:00
|
|
|
|
}
|
2020-08-02 22:24:46 +02:00
|
|
|
|
m_backup_file.setManagedFile(QUrl::fromLocalFile(filepath));
|
2020-12-16 23:06:08 +01:00
|
|
|
|
#endif
|
2018-05-24 18:08:06 +00:00
|
|
|
|
m_file_path = filepath;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
QFileInfo fi(m_file_path);
|
2019-03-29 20:51:24 +00:00
|
|
|
|
if (fi.isWritable()) {
|
|
|
|
|
setReadOnly(false);
|
|
|
|
|
}
|
2019-03-16 10:50:30 +00:00
|
|
|
|
|
|
|
|
|
//title block variables should be updated after file save as dialog is confirmed, before file is saved.
|
2020-10-31 14:22:06 +01:00
|
|
|
|
m_project_properties.addValue("saveddate", QLocale::system().toString(QDate::currentDate(), QLocale::ShortFormat));
|
|
|
|
|
m_project_properties.addValue("saveddate-eu", QDate::currentDate().toString("dd-MM-yyyy"));
|
|
|
|
|
m_project_properties.addValue("saveddate-us", QDate::currentDate().toString("yyyy-MM-dd"));
|
|
|
|
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
|
|
|
|
m_project_properties.addValue("savedfilepath", filePath());
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit projectFilePathChanged(this, m_file_path);
|
|
|
|
|
emit projectInformationsChanged(this);
|
2018-08-05 15:04:15 +00:00
|
|
|
|
updateDiagramsFolioData();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-07-13 00:59:46 +00:00
|
|
|
|
/**
|
|
|
|
|
@return le dossier contenant le fichier projet si celui-ci a ete
|
|
|
|
|
enregistre ; dans le cas contraire, cette methode retourne l'emplacement
|
|
|
|
|
du bureau de l'utilisateur.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::currentDir() const
|
|
|
|
|
{
|
2009-07-13 00:59:46 +00:00
|
|
|
|
QString current_directory;
|
2018-05-24 18:08:06 +00:00
|
|
|
|
if (m_file_path.isEmpty()) {
|
2015-03-02 20:14:56 +00:00
|
|
|
|
current_directory = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
2009-07-13 00:59:46 +00:00
|
|
|
|
} else {
|
2018-05-24 18:08:06 +00:00
|
|
|
|
current_directory = QFileInfo(m_file_path).absoluteDir().absolutePath();
|
2009-07-13 00:59:46 +00:00
|
|
|
|
}
|
|
|
|
|
return(current_directory);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
@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'est pas associe a un fichier, cette methode retourne "Projet
|
|
|
|
|
sans titre".
|
|
|
|
|
De plus, si le projet est en lecture seule, le tag "[lecture seule]" est
|
|
|
|
|
ajoute.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::pathNameTitle() const
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QString final_title;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (!project_title_.isEmpty()) {
|
|
|
|
|
final_title = QString(
|
|
|
|
|
tr(
|
2017-01-10 14:56:34 +00:00
|
|
|
|
"Projet « %1 : %2»",
|
2017-01-10 20:22:34 +00:00
|
|
|
|
"displayed title for a ProjectView - %1 is the project title, -%2 is the project path"
|
2009-04-03 19:30:25 +00:00
|
|
|
|
)
|
2022-04-09 13:07:47 +02:00
|
|
|
|
).arg(project_title_, m_file_path);
|
2018-05-24 18:08:06 +00:00
|
|
|
|
} else if (!m_file_path.isEmpty()) {
|
2009-04-03 19:30:25 +00:00
|
|
|
|
final_title = QString(
|
|
|
|
|
tr(
|
|
|
|
|
"Projet %1",
|
|
|
|
|
"displayed title for a title-less project - %1 is the file name"
|
|
|
|
|
)
|
2018-05-24 18:08:06 +00:00
|
|
|
|
).arg(QFileInfo(m_file_path).completeBaseName());
|
2009-04-03 19:30:25 +00:00
|
|
|
|
} else {
|
|
|
|
|
final_title = QString(
|
|
|
|
|
tr(
|
|
|
|
|
"Projet sans titre",
|
|
|
|
|
"displayed title for a project-less, file-less project"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (isReadOnly()) {
|
|
|
|
|
final_title = QString(
|
|
|
|
|
tr(
|
|
|
|
|
"%1 [lecture seule]",
|
|
|
|
|
"displayed title for a read-only project - %1 is a displayable title"
|
|
|
|
|
)
|
|
|
|
|
).arg(final_title);
|
|
|
|
|
}
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if (m_modified) {
|
2012-07-07 19:45:32 +00:00
|
|
|
|
final_title = QString(
|
|
|
|
|
tr(
|
2017-01-10 14:56:34 +00:00
|
|
|
|
"%1 [modifié]",
|
2017-01-10 20:22:34 +00:00
|
|
|
|
"displayed title for a modified project - %1 is a displayable title"
|
2012-07-07 19:45:32 +00:00
|
|
|
|
)
|
2017-01-10 14:56:34 +00:00
|
|
|
|
).arg(final_title);
|
2012-07-07 19:45:32 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(final_title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return le titre du projet
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::title() const
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(project_title_);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-18 19:16:52 +00:00
|
|
|
|
/**
|
|
|
|
|
@return la version de QElectroTech declaree dans le fichier projet lorsque
|
|
|
|
|
celui-ci a ete ouvert ; si ce projet n'a jamais ete enregistre / ouvert
|
2023-01-12 15:26:06 +01:00
|
|
|
|
depuis un fichier, cette methode une version nulle.
|
2010-07-18 19:16:52 +00:00
|
|
|
|
*/
|
2023-01-12 13:27:55 +01:00
|
|
|
|
QVersionNumber QETProject::declaredQElectroTechVersion()
|
2020-09-07 22:03:40 +02:00
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(m_project_qet_version);
|
2010-07-18 19:16:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
|
|
|
|
@param title le nouveau titre du projet
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::setTitle(const QString &title) {
|
|
|
|
|
// ne fait rien si le projet est en lecture seule
|
|
|
|
|
if (isReadOnly()) return;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
// ne fait rien si le titre du projet n'est pas change par l'appel de cette methode
|
|
|
|
|
if (project_title_ == title) return;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
project_title_ = title;
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit projectTitleChanged(this, project_title_);
|
|
|
|
|
emit projectInformationsChanged(this);
|
2012-07-02 06:34:40 +00:00
|
|
|
|
updateDiagramsFolioData();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return les dimensions par defaut utilisees lors de la creation d'un
|
|
|
|
|
nouveau schema dans ce projet.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
BorderProperties QETProject::defaultBorderProperties() const
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(default_border_properties_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Permet de specifier les dimensions par defaut utilisees lors de la creation
|
|
|
|
|
d'un nouveau schema dans ce projet.
|
|
|
|
|
@param border dimensions d'un schema
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::setDefaultBorderProperties(const BorderProperties &border) {
|
|
|
|
|
default_border_properties_ = border;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return le cartouche par defaut utilise lors de la creation d'un
|
|
|
|
|
nouveau schema dans ce projet.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
TitleBlockProperties QETProject::defaultTitleBlockProperties() const
|
|
|
|
|
{
|
2010-12-20 02:45:36 +00:00
|
|
|
|
return(default_titleblock_properties_);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setDefaultTitleBlockProperties
|
|
|
|
|
Specify the title block to be used at the creation of a new diagram for this project
|
|
|
|
|
@param titleblock
|
|
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
|
void QETProject::setDefaultTitleBlockProperties(const TitleBlockProperties &titleblock) {
|
|
|
|
|
default_titleblock_properties_ = titleblock;
|
2015-04-09 09:39:34 +00:00
|
|
|
|
//Integrate the title block in this project
|
|
|
|
|
if (!titleblock.template_name.isEmpty())
|
|
|
|
|
{
|
2015-04-17 11:36:28 +00:00
|
|
|
|
TitleBlockTemplatesFilesCollection *collection = nullptr;
|
2015-04-25 08:43:00 +00:00
|
|
|
|
switch (titleblock.collection)
|
|
|
|
|
{
|
|
|
|
|
case QET::Common :
|
|
|
|
|
collection = QETApp::commonTitleBlockTemplatesCollection();
|
|
|
|
|
break;
|
|
|
|
|
case QET::Custom :
|
|
|
|
|
collection = QETApp::customTitleBlockTemplatesCollection();
|
|
|
|
|
break;
|
2015-04-25 08:54:54 +00:00
|
|
|
|
case QET::Embedded :
|
2015-04-25 08:43:00 +00:00
|
|
|
|
//Titleblock is already embedded to project
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 16:58:05 +02:00
|
|
|
|
IntegrationMoveTitleBlockTemplatesHandler m_;
|
|
|
|
|
integrateTitleBlockTemplate(collection -> location(titleblock.template_name), &m_);
|
2015-04-09 09:39:34 +00:00
|
|
|
|
}
|
2016-07-13 14:57:27 +00:00
|
|
|
|
emit defaultTitleBlockPropertiesChanged();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return le type de conducteur par defaut utilise lors de la creation d'un
|
|
|
|
|
nouveau schema dans ce projet.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
ConductorProperties QETProject::defaultConductorProperties() const
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(default_conductor_properties_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Permet de specifier e type de conducteur par defaut utilise lors de la
|
|
|
|
|
creation d'un nouveau schema dans ce projet.
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::setDefaultConductorProperties(const ConductorProperties &conductor) {
|
|
|
|
|
default_conductor_properties_ = conductor;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::defaultReportProperties() const
|
|
|
|
|
{
|
2017-02-09 11:07:45 +00:00
|
|
|
|
return m_default_report_properties;
|
2014-01-18 19:04:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-09 11:07:45 +00:00
|
|
|
|
void QETProject::setDefaultReportProperties(const QString &properties)
|
|
|
|
|
{
|
|
|
|
|
QString old = m_default_report_properties;
|
|
|
|
|
m_default_report_properties = properties;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2017-02-09 11:07:45 +00:00
|
|
|
|
emit reportPropertiesChanged(old, properties);
|
2014-01-18 19:04:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::setDefaultXRefProperties(const QString& type, const XRefProperties &properties) {
|
2014-07-03 08:52:14 +00:00
|
|
|
|
m_default_xref_properties.insert(type, properties);
|
|
|
|
|
emit XRefPropertiesChanged();
|
2014-04-11 09:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-11 08:46:49 +00:00
|
|
|
|
void QETProject::setDefaultXRefProperties(QHash<QString, XRefProperties> hash)
|
|
|
|
|
{
|
2014-11-06 15:22:30 +00:00
|
|
|
|
m_default_xref_properties.swap(hash);
|
2014-07-03 08:52:14 +00:00
|
|
|
|
emit XRefPropertiesChanged();
|
2014-04-11 09:51:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-31 10:02:33 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::conductorAutoNum
|
|
|
|
|
@return All value of conductor autonum stored in project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QHash <QString, NumerotationContext> QETProject::conductorAutoNum() const
|
|
|
|
|
{
|
2014-07-31 10:02:33 +00:00
|
|
|
|
return m_conductor_autonum;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-05 20:14:14 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::elementAutoNum
|
|
|
|
|
@return All value of element autonum stored in project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QHash <QString, NumerotationContext> QETProject::elementAutoNum() const
|
|
|
|
|
{
|
2016-07-05 20:14:14 +00:00
|
|
|
|
return m_element_autonum;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 01:33:49 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::elementAutoNumFormula
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@param key : autonum title
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@return Formula of element autonum stored in element autonum
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
QString QETProject::elementAutoNumFormula (const QString& key) const
|
2016-11-26 17:12:31 +00:00
|
|
|
|
{
|
|
|
|
|
if (m_element_autonum.contains(key)) {
|
2016-11-26 19:30:59 +00:00
|
|
|
|
return autonum::numerotationContextToFormula(m_element_autonum[key]);
|
2016-11-26 17:12:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::elementAutoNumCurrentFormula
|
|
|
|
|
@return current formula being used by project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::elementAutoNumCurrentFormula() const
|
|
|
|
|
{
|
2016-11-26 17:12:31 +00:00
|
|
|
|
return elementAutoNumFormula(m_current_element_autonum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::elementCurrentAutoNum
|
|
|
|
|
@return current element autonum title
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::elementCurrentAutoNum () const
|
|
|
|
|
{
|
2016-11-26 17:12:31 +00:00
|
|
|
|
return m_current_element_autonum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setCurrrentElementAutonum
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@param autoNum : set the current element autonum to autonum
|
2020-08-16 11:19:36 +02:00
|
|
|
|
*/
|
2016-11-26 17:12:31 +00:00
|
|
|
|
void QETProject::setCurrrentElementAutonum(QString autoNum) {
|
2018-07-19 14:14:31 +00:00
|
|
|
|
m_current_element_autonum = std::move(autoNum);
|
2016-07-10 01:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::conductorAutoNumFormula
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@param key : autonum title
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@return Formula of element autonum stored in conductor autonum
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
QString QETProject::conductorAutoNumFormula (const QString& key) const
|
2016-12-06 19:49:18 +00:00
|
|
|
|
{
|
2016-08-29 15:37:42 +00:00
|
|
|
|
if (m_conductor_autonum.contains(key))
|
2016-12-06 19:49:18 +00:00
|
|
|
|
return autonum::numerotationContextToFormula(m_conductor_autonum.value(key));
|
|
|
|
|
else
|
|
|
|
|
return QString();
|
2016-08-29 15:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-14 17:16:14 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::conductorCurrentAutoNum
|
|
|
|
|
@return current conductor autonum title
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QString QETProject::conductorCurrentAutoNum () const
|
|
|
|
|
{
|
2016-11-26 17:12:31 +00:00
|
|
|
|
return m_current_conductor_autonum;
|
2016-07-14 17:16:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-29 15:37:42 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setCurrentConductorAutoNum
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@param autoNum set the current conductor autonum to autonum
|
2020-08-16 11:19:36 +02:00
|
|
|
|
*/
|
2016-11-26 17:12:31 +00:00
|
|
|
|
void QETProject::setCurrentConductorAutoNum(QString autoNum) {
|
2018-07-19 14:14:31 +00:00
|
|
|
|
m_current_conductor_autonum = std::move(autoNum);
|
2016-08-29 15:37:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 15:00:22 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::folioAutoNum
|
|
|
|
|
@return All value of folio autonum stored in project
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QHash <QString, NumerotationContext> QETProject::folioAutoNum() const
|
|
|
|
|
{
|
2016-05-13 15:00:22 +00:00
|
|
|
|
return m_folio_autonum;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-31 10:02:33 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::addConductorAutoNum
|
|
|
|
|
Add a new conductor numerotation context. If key already exist,
|
2022-12-04 06:24:28 -05:00
|
|
|
|
replace old context with the new context
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param key
|
|
|
|
|
@param context
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::addConductorAutoNum(const QString& key, const NumerotationContext& context) {
|
2014-07-31 10:02:33 +00:00
|
|
|
|
m_conductor_autonum.insert(key, context);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 01:33:49 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::addElementAutoNum
|
|
|
|
|
Add a new element numerotation context. If key already exist,
|
2022-12-04 06:24:28 -05:00
|
|
|
|
replace old context with the new context
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param key
|
|
|
|
|
@param context
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::addElementAutoNum(const QString& key, const NumerotationContext& context)
|
2016-11-26 17:12:31 +00:00
|
|
|
|
{
|
2016-07-10 01:33:49 +00:00
|
|
|
|
m_element_autonum.insert(key, context);
|
2016-11-26 17:12:31 +00:00
|
|
|
|
emit elementAutoNumAdded(key);
|
2016-07-05 20:14:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 15:00:22 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::addFolioAutoNum
|
|
|
|
|
Add a new folio numerotation context. If key already exist,
|
2022-12-04 06:24:28 -05:00
|
|
|
|
replace old context with the new context
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param key
|
|
|
|
|
@param context
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::addFolioAutoNum(const QString& key, const NumerotationContext& context) {
|
2016-05-13 15:00:22 +00:00
|
|
|
|
m_folio_autonum.insert(key, context);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 09:41:33 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::removeConductorAutoNum
|
|
|
|
|
Remove Conductor Numerotation Context stored with key
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::removeConductorAutoNum(const QString& key) {
|
2014-08-12 09:41:33 +00:00
|
|
|
|
m_conductor_autonum.remove(key);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 01:33:49 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::removeElementAutonum
|
|
|
|
|
Remove Element Numerotation Context stored with key
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::removeElementAutoNum(const QString& key)
|
2016-11-26 17:12:31 +00:00
|
|
|
|
{
|
2016-07-10 01:33:49 +00:00
|
|
|
|
m_element_autonum.remove(key);
|
2016-11-26 17:12:31 +00:00
|
|
|
|
emit elementAutoNumRemoved(key);
|
2016-07-10 01:33:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 15:00:22 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::removeFolioAutonum
|
|
|
|
|
Remove Folio Numerotation Context stored with key
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2018-07-19 14:14:31 +00:00
|
|
|
|
void QETProject::removeFolioAutoNum(const QString& key) {
|
2016-05-13 15:00:22 +00:00
|
|
|
|
m_folio_autonum.remove(key);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-31 10:02:33 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::conductorAutoNum
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Return conductor numerotation context stored with key.
|
2020-08-16 11:19:36 +02:00
|
|
|
|
If key is not found, return an empty numerotation context
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
NumerotationContext QETProject::conductorAutoNum (const QString &key) const
|
|
|
|
|
{
|
2014-07-31 10:02:33 +00:00
|
|
|
|
if (m_conductor_autonum.contains(key)) return m_conductor_autonum[key];
|
|
|
|
|
else return NumerotationContext();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 01:33:49 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::elementAutoNum
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Return element numerotation context stored with key.
|
2020-08-16 11:19:36 +02:00
|
|
|
|
If key is not found, return an empty numerotation context
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2016-07-26 18:52:49 +00:00
|
|
|
|
NumerotationContext QETProject::elementAutoNum (const QString &key) {
|
2016-07-10 01:33:49 +00:00
|
|
|
|
if (m_element_autonum.contains(key)) return m_element_autonum[key];
|
|
|
|
|
else return NumerotationContext();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 15:00:22 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::folioAutoNum
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Return folio numerotation context stored with key.
|
2020-08-16 11:19:36 +02:00
|
|
|
|
If key is not found, return an empty numerotation context
|
|
|
|
|
@param key
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
NumerotationContext QETProject::folioAutoNum (const QString &key) const
|
|
|
|
|
{
|
2016-05-13 15:00:22 +00:00
|
|
|
|
if (m_folio_autonum.contains(key)) return m_folio_autonum[key];
|
|
|
|
|
else return NumerotationContext();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-01 19:41:49 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::freezeExistentConductorLabel
|
|
|
|
|
Freeze Existent Conductors in the selected folios
|
2020-08-20 17:44:59 +02:00
|
|
|
|
@param freeze
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param from - first folio index to apply freeze
|
|
|
|
|
@param to - last folio index to apply freeze
|
|
|
|
|
*/
|
2016-12-12 10:52:44 +00:00
|
|
|
|
void QETProject::freezeExistentConductorLabel(bool freeze, int from, int to) {
|
2016-09-01 19:41:49 +00:00
|
|
|
|
for (int i = from; i <= to; i++) {
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list.at(i)->freezeConductors(freeze);
|
2016-09-01 19:41:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::freezeNewConductorLabel
|
|
|
|
|
Freeze New Conductors in the selected folios
|
2020-08-20 17:44:59 +02:00
|
|
|
|
@param freeze
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param from - first folio index to apply freeze
|
|
|
|
|
@param to - last folio index to apply freeze
|
|
|
|
|
*/
|
2016-12-12 10:52:44 +00:00
|
|
|
|
void QETProject::freezeNewConductorLabel(bool freeze, int from, int to) {
|
2016-09-01 19:41:49 +00:00
|
|
|
|
for (int i = from; i <= to; i++) {
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list.at(i)->setFreezeNewConductors(freeze);
|
2016-09-01 19:41:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::isFreezeNewConductors
|
|
|
|
|
@return freeze new conductors Project Wide status
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::isFreezeNewConductors()
|
|
|
|
|
{
|
2016-09-01 19:41:49 +00:00
|
|
|
|
return m_freeze_new_conductors;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setfreezeNewConductors
|
|
|
|
|
Set Project Wide freeze new conductors
|
|
|
|
|
*/
|
2016-09-01 19:41:49 +00:00
|
|
|
|
void QETProject::setFreezeNewConductors(bool set) {
|
|
|
|
|
m_freeze_new_conductors = set;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-11 11:10:57 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::freezeExistentElementLabel
|
|
|
|
|
Freeze Existent Elements in the selected folios
|
2020-08-20 17:44:59 +02:00
|
|
|
|
@param freeze
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param from - first folio index to apply freeze
|
|
|
|
|
@param to - last folio index to apply freeze
|
|
|
|
|
*/
|
2016-12-10 12:00:52 +00:00
|
|
|
|
void QETProject::freezeExistentElementLabel(bool freeze, int from, int to) {
|
2016-07-20 15:07:21 +00:00
|
|
|
|
for (int i = from; i <= to; i++) {
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list.at(i)->freezeElements(freeze);
|
2016-07-20 15:07:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::freezeNewElementLabel
|
|
|
|
|
Freeze New Elements in the selected folios
|
2020-08-20 17:44:59 +02:00
|
|
|
|
@param freeze
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param from - first folio index to apply freeze
|
|
|
|
|
@param to - last folio index to apply freeze
|
|
|
|
|
*/
|
2016-12-10 12:00:52 +00:00
|
|
|
|
void QETProject::freezeNewElementLabel(bool freeze, int from, int to) {
|
2016-07-20 15:07:21 +00:00
|
|
|
|
for (int i = from; i <= to; i++) {
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list.at(i)->setFreezeNewElements(freeze);
|
2016-07-20 15:07:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::freezeNewElements
|
|
|
|
|
@return freeze new elements Project Wide status
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::isFreezeNewElements()
|
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
|
return m_freeze_new_elements;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setfreezeNewElements
|
|
|
|
|
Set Project Wide freeze new elements
|
|
|
|
|
*/
|
2016-07-20 15:07:21 +00:00
|
|
|
|
void QETProject::setFreezeNewElements(bool set) {
|
|
|
|
|
m_freeze_new_elements = set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::autoConductor
|
|
|
|
|
@return true if use of auto conductor is authorized.
|
|
|
|
|
See also Q_PROPERTY autoConductor
|
|
|
|
|
*/
|
2016-07-20 15:07:21 +00:00
|
|
|
|
bool QETProject::autoConductor() const
|
2016-05-13 15:00:22 +00:00
|
|
|
|
{
|
2016-07-20 15:07:21 +00:00
|
|
|
|
return m_auto_conductor;
|
2016-05-13 15:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-11 11:10:57 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setAutoConductor
|
|
|
|
|
@param ac
|
|
|
|
|
Enable the use of auto conductor if true
|
|
|
|
|
See also Q_PROPERTY autoConductor
|
|
|
|
|
*/
|
2015-01-11 11:10:57 +00:00
|
|
|
|
void QETProject::setAutoConductor(bool ac)
|
|
|
|
|
{
|
|
|
|
|
if (ac != m_auto_conductor)
|
|
|
|
|
m_auto_conductor = ac;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-13 15:00:22 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::autoFolioNumberingNewFolios
|
|
|
|
|
emit Signal to add new Diagram with autonum
|
|
|
|
|
properties
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
void QETProject::autoFolioNumberingNewFolios()
|
|
|
|
|
{
|
2016-05-13 15:00:22 +00:00
|
|
|
|
emit addAutoNumDiagram();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::autoFolioNumberingNewFolios
|
2020-08-20 17:44:59 +02:00
|
|
|
|
@param from
|
|
|
|
|
@param to
|
|
|
|
|
@param autonum : used, index from selected tabs "from" and "to"
|
2020-08-16 11:19:36 +02:00
|
|
|
|
rename folios with selected autonum
|
|
|
|
|
*/
|
2020-08-20 17:45:24 +02:00
|
|
|
|
void QETProject::autoFolioNumberingSelectedFolios(int from,
|
|
|
|
|
int to,
|
|
|
|
|
const QString& autonum){
|
2017-03-05 13:10:47 +00:00
|
|
|
|
int total_folio = m_diagrams_list.count();
|
2019-03-16 10:50:30 +00:00
|
|
|
|
DiagramContext project_wide_properties = m_project_properties;
|
2022-04-09 13:07:47 +02:00
|
|
|
|
|
|
|
|
|
for (int i=from; i<=to; i++)
|
|
|
|
|
{
|
2016-05-13 15:00:22 +00:00
|
|
|
|
NumerotationContext nC = folioAutoNum(autonum);
|
|
|
|
|
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list[i] -> border_and_titleblock.setFolio("%autonum");
|
2020-08-20 17:45:24 +02:00
|
|
|
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(
|
|
|
|
|
i + 1,
|
|
|
|
|
total_folio,
|
|
|
|
|
nCC.toRepresentedString(),
|
|
|
|
|
project_wide_properties);
|
|
|
|
|
m_diagrams_list[i] -> project() -> addFolioAutoNum(
|
|
|
|
|
autonum,nCC.next());
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list[i] -> update();
|
2016-05-13 15:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@brief QETProject::toXml
|
|
|
|
|
@return un document XML representant le projet
|
2009-04-03 19:30:25 +00:00
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
QDomDocument QETProject::toXml()
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
// racine du projet
|
|
|
|
|
QDomDocument xml_doc;
|
|
|
|
|
QDomElement project_root = xml_doc.createElement("project");
|
|
|
|
|
project_root.setAttribute("version", QET::version);
|
2021-01-23 21:57:56 +01:00
|
|
|
|
if (project_title_.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
// if project_title_is Empty add title from m_file_path
|
|
|
|
|
// is for project name in Collectie
|
|
|
|
|
setTitle(QFileInfo(m_file_path).completeBaseName());
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
project_root.setAttribute("title", project_title_);
|
|
|
|
|
xml_doc.appendChild(project_root);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2010-12-20 02:45:36 +00:00
|
|
|
|
// titleblock templates, if any
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if (m_titleblocks_collection.templates().count()) {
|
2010-12-20 02:45:36 +00:00
|
|
|
|
QDomElement titleblocktemplates_elmt = xml_doc.createElement("titleblocktemplates");
|
2019-03-16 10:50:30 +00:00
|
|
|
|
foreach (QString template_name, m_titleblocks_collection.templates()) {
|
|
|
|
|
QDomElement e = m_titleblocks_collection.getTemplateXmlDescription(template_name);
|
2012-01-08 17:04:34 +00:00
|
|
|
|
titleblocktemplates_elmt.appendChild(xml_doc.importNode(e, true));
|
2010-12-19 18:14:05 +00:00
|
|
|
|
}
|
2010-12-20 02:45:36 +00:00
|
|
|
|
project_root.appendChild(titleblocktemplates_elmt);
|
2010-12-19 18:14:05 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2012-07-01 21:54:07 +00:00
|
|
|
|
// project-wide properties
|
|
|
|
|
QDomElement project_properties = xml_doc.createElement("properties");
|
|
|
|
|
writeProjectPropertiesXml(project_properties);
|
|
|
|
|
project_root.appendChild(project_properties);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2014-04-11 09:51:21 +00:00
|
|
|
|
// Properties for news diagrams
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QDomElement new_diagrams_properties = xml_doc.createElement("newdiagrams");
|
|
|
|
|
writeDefaultPropertiesXml(new_diagrams_properties);
|
|
|
|
|
project_root.appendChild(new_diagrams_properties);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
// schemas
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-08-17 21:24:46 +02:00
|
|
|
|
qDebug() << "Export XML de" << m_diagrams_list.count() << "schemas";
|
2009-04-03 19:30:25 +00:00
|
|
|
|
int order_num = 1;
|
2017-03-05 13:10:47 +00:00
|
|
|
|
const QList<Diagram *> diagrams_list = m_diagrams_list;
|
|
|
|
|
for(Diagram *diagram : diagrams_list)
|
|
|
|
|
{
|
2020-08-17 21:24:46 +02:00
|
|
|
|
qDebug() << QString("exporting diagram \"%1\""
|
2020-10-03 16:04:54 +02:00
|
|
|
|
).arg(diagram -> title())
|
2020-08-17 21:24:46 +02:00
|
|
|
|
<< "["
|
|
|
|
|
<< diagram
|
|
|
|
|
<< "]";
|
2020-07-14 20:00:28 +02:00
|
|
|
|
QDomElement xml_diagram = diagram->toXml().documentElement();
|
|
|
|
|
QDomNode xml_node = xml_doc.importNode(xml_diagram, true);
|
2020-07-06 21:52:14 +02:00
|
|
|
|
|
2020-07-14 20:00:28 +02:00
|
|
|
|
QDomNode appended_diagram = project_root.appendChild(xml_node);
|
|
|
|
|
appended_diagram.toElement().setAttribute("order", order_num ++);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2021-09-10 23:30:20 +02:00
|
|
|
|
//Write terminal strip to xml
|
|
|
|
|
if (m_terminal_strip_vector.count())
|
|
|
|
|
{
|
|
|
|
|
auto xml_strip = xml_doc.createElement(QStringLiteral("terminal_strips"));
|
|
|
|
|
for (auto &strip : m_terminal_strip_vector) {
|
|
|
|
|
xml_strip.appendChild(strip->toXml(xml_doc));
|
|
|
|
|
}
|
|
|
|
|
project_root.appendChild(xml_strip);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-17 21:24:46 +02:00
|
|
|
|
// Write the elements collection.
|
2016-05-02 09:00:23 +00:00
|
|
|
|
project_root.appendChild(m_elements_collection->root().cloneNode(true));
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(xml_doc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Ferme le projet
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::close()
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::write
|
|
|
|
|
Save the project in a file
|
|
|
|
|
@see filePath()
|
|
|
|
|
@see setFilePath()
|
|
|
|
|
@return true if the project was successfully saved, else false
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
QETResult QETProject::write()
|
|
|
|
|
{
|
2020-10-31 14:22:06 +01:00
|
|
|
|
// this operation requires a filepath
|
2018-05-24 18:08:06 +00:00
|
|
|
|
if (m_file_path.isEmpty())
|
2012-07-13 07:21:19 +00:00
|
|
|
|
return(QString("unable to save project to file: no filepath was specified"));
|
2014-11-22 20:03:38 +00:00
|
|
|
|
|
2020-10-31 14:22:06 +01:00
|
|
|
|
// if the project was opened read-only
|
|
|
|
|
// and the file is still non-writable, do not save the project
|
2018-05-24 18:08:06 +00:00
|
|
|
|
if (isReadOnly() && !QFileInfo(m_file_path).isWritable())
|
|
|
|
|
return(QString("the file %1 was opened read-only and thus will not be written").arg(m_file_path));
|
2017-01-27 17:42:58 +00:00
|
|
|
|
|
2020-08-16 14:26:40 +02:00
|
|
|
|
QDomDocument xml_project(toXml());
|
2012-04-09 01:03:08 +00:00
|
|
|
|
QString error_message;
|
2020-08-16 14:26:40 +02:00
|
|
|
|
if (!QET::writeXmlFile(xml_project, m_file_path, &error_message))
|
|
|
|
|
return(error_message);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-10-31 14:22:06 +01:00
|
|
|
|
//title block variables should be updated after file save dialog is confirmed, before file is saved.
|
|
|
|
|
m_project_properties.addValue("saveddate", QLocale::system().toString(QDate::currentDate(), QLocale::ShortFormat));
|
|
|
|
|
m_project_properties.addValue("saveddate-us", QDate::currentDate().toString("yyyy-MM-dd"));
|
|
|
|
|
m_project_properties.addValue("saveddate-eu", QDate::currentDate().toString("dd-MM-yyyy"));
|
|
|
|
|
m_project_properties.addValue("savedtime", QDateTime::currentDateTime().toString("HH:mm"));
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_project_properties.addValue("savedfilename", QFileInfo(filePath()).baseName());
|
|
|
|
|
m_project_properties.addValue("savedfilepath", filePath());
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit projectInformationsChanged(this);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
updateDiagramsFolioData();
|
|
|
|
|
|
2012-07-13 07:21:19 +00:00
|
|
|
|
setModified(false);
|
|
|
|
|
return(QETResult());
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@brief QETProject::isReadOnly
|
2009-04-03 19:30:25 +00:00
|
|
|
|
@return true si le projet est en mode readonly, false sinon
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::isReadOnly() const
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(m_read_only && read_only_file_path_ == m_file_path);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::setReadOnly
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Set this project to read only if read_only = true
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param read_only
|
|
|
|
|
*/
|
2014-12-21 13:17:35 +00:00
|
|
|
|
void QETProject::setReadOnly(bool read_only)
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if (m_read_only != read_only)
|
2014-12-21 13:17:35 +00:00
|
|
|
|
{
|
|
|
|
|
//keep the file to which this project is read-only
|
2018-05-24 18:08:06 +00:00
|
|
|
|
read_only_file_path_ = m_file_path;
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_read_only = read_only;
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit readOnlyChanged(this, read_only);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return true si le projet peut etre considere comme vide, c'est-a-dire :
|
|
|
|
|
- soit avec une collection embarquee vide
|
|
|
|
|
- soit avec uniquement des schemas consideres comme vides
|
|
|
|
|
- soit avec un titre de projet
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::isEmpty() const
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
// si le projet a un titre, on considere qu'il n'est pas vide
|
|
|
|
|
if (!project_title_.isEmpty()) return(false);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-09-24 17:01:33 +02:00
|
|
|
|
#if TODO_LIST
|
|
|
|
|
#pragma message("@TODO check if the embedded element collection is empty")
|
|
|
|
|
#endif
|
2016-05-24 20:59:45 +00:00
|
|
|
|
//@TODO check if the embedded element collection is empty
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
// compte le nombre de schemas non vides
|
|
|
|
|
int pertinent_diagrams = 0;
|
2017-03-05 13:10:47 +00:00
|
|
|
|
foreach(Diagram *diagram, m_diagrams_list) {
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (!diagram -> isEmpty()) ++ pertinent_diagrams;
|
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(pertinent_diagrams > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::importElement
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Import the element represented by location
|
2022-12-04 06:24:28 -05:00
|
|
|
|
to the embedded collection of this project
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param location
|
|
|
|
|
@return the location of the imported element, location can be null.
|
|
|
|
|
*/
|
2016-05-05 13:31:04 +00:00
|
|
|
|
ElementsLocation QETProject::importElement(ElementsLocation &location)
|
|
|
|
|
{
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Location isn't an element or doesn't exist
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (! (location.isElement() && location.exist()) ) {
|
|
|
|
|
return ElementsLocation();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2016-05-05 13:31:04 +00:00
|
|
|
|
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Get the path where the element must be imported
|
2016-05-05 13:31:04 +00:00
|
|
|
|
QString import_path;
|
|
|
|
|
if (location.isFileSystem()) {
|
|
|
|
|
import_path = "import/" + location.collectionPath(false);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2016-05-22 14:51:09 +00:00
|
|
|
|
else if (location.isProject()) {
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (location.project() == this) {
|
|
|
|
|
return location;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2016-05-05 13:31:04 +00:00
|
|
|
|
|
|
|
|
|
import_path = location.collectionPath(false);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2016-05-05 13:31:04 +00:00
|
|
|
|
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Element already exist in the embedded collection, we ask what to do to user
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (m_elements_collection->exist(import_path)) {
|
|
|
|
|
ElementsLocation existing_location(import_path, this);
|
|
|
|
|
|
2020-08-18 21:28:52 +02:00
|
|
|
|
//existing_location and location have the same uuid, so it is the same element
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (existing_location.uuid() == location.uuid()) {
|
|
|
|
|
return existing_location;
|
2016-01-08 17:01:51 +00:00
|
|
|
|
}
|
2016-05-05 13:31:04 +00:00
|
|
|
|
|
|
|
|
|
ImportElementDialog ied;
|
|
|
|
|
if (ied.exec() == QDialog::Accepted) {
|
|
|
|
|
QET::Action action = ied.action();
|
|
|
|
|
|
2022-12-04 06:24:28 -05:00
|
|
|
|
//Use the exisiting element
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (action == QET::Ignore) {
|
|
|
|
|
return existing_location;
|
|
|
|
|
}
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Erase the existing element, and use the newer instead
|
2016-05-05 13:31:04 +00:00
|
|
|
|
else if (action == QET::Erase) {
|
|
|
|
|
ElementsLocation parent_loc = existing_location.parent();
|
|
|
|
|
return m_elements_collection->copy(location, parent_loc);
|
|
|
|
|
}
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Add the new element with an other name.
|
2016-05-05 13:31:04 +00:00
|
|
|
|
else if (action == QET::Rename) {
|
|
|
|
|
int a = 0;
|
|
|
|
|
QString parent_path = existing_location.parent().projectCollectionPath();
|
|
|
|
|
QString name_ = existing_location.fileName();
|
|
|
|
|
name_.remove(".elmt");
|
|
|
|
|
|
|
|
|
|
ElementsLocation loc;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
a++;
|
|
|
|
|
QString new_path = parent_path + "/" + name_ + QString::number(a) + ".elmt";
|
|
|
|
|
loc = ElementsLocation (new_path);
|
|
|
|
|
} while (loc.exist());
|
|
|
|
|
|
|
|
|
|
ElementsLocation parent_loc = existing_location.parent();
|
|
|
|
|
return m_elements_collection->copy(location, parent_loc, loc.fileName());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return ElementsLocation();
|
|
|
|
|
}
|
2016-01-08 17:01:51 +00:00
|
|
|
|
}
|
2016-05-05 13:31:04 +00:00
|
|
|
|
else {
|
|
|
|
|
return ElementsLocation();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2016-01-08 17:01:51 +00:00
|
|
|
|
}
|
2020-08-17 21:24:46 +02:00
|
|
|
|
//Element doesn't exist in the collection, we just import it
|
2016-05-05 13:31:04 +00:00
|
|
|
|
else {
|
2020-08-17 21:24:46 +02:00
|
|
|
|
ElementsLocation loc(m_elements_collection->addElement(
|
2020-10-03 16:04:54 +02:00
|
|
|
|
location), this);
|
2016-03-19 14:18:00 +00:00
|
|
|
|
|
2016-05-05 13:31:04 +00:00
|
|
|
|
if (!loc.exist()) {
|
2020-08-17 21:24:46 +02:00
|
|
|
|
qDebug() << "failed to import location. "
|
|
|
|
|
<< location;
|
2016-05-05 13:31:04 +00:00
|
|
|
|
return ElementsLocation();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return loc;
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-22 10:40:37 +00:00
|
|
|
|
/**
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@brief QETProject::integrateTitleBlockTemplate
|
2012-01-22 10:40:37 +00:00
|
|
|
|
Integrate a title block template into this project.
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@param src_tbt The location of the title block template
|
|
|
|
|
to be integrated into this project
|
2020-09-21 20:23:20 +02:00
|
|
|
|
@param handler
|
2020-08-17 21:24:20 +02:00
|
|
|
|
@return the name of the template after integration,
|
|
|
|
|
or an empty QString if a problem occurred.
|
2012-01-22 10:40:37 +00:00
|
|
|
|
*/
|
|
|
|
|
QString QETProject::integrateTitleBlockTemplate(const TitleBlockTemplateLocation &src_tbt, MoveTitleBlockTemplatesHandler *handler) {
|
2019-03-16 10:50:30 +00:00
|
|
|
|
TitleBlockTemplateLocation dst_tbt(src_tbt.name(), &m_titleblocks_collection);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2012-01-22 10:40:37 +00:00
|
|
|
|
// check whether a TBT having the same name already exists within this project
|
|
|
|
|
QString target_name = dst_tbt.name();
|
2019-03-16 10:50:30 +00:00
|
|
|
|
while (m_titleblocks_collection.templates().contains(target_name))
|
2015-04-09 09:39:34 +00:00
|
|
|
|
{
|
2012-01-22 10:40:37 +00:00
|
|
|
|
QET::Action action = handler -> templateAlreadyExists(src_tbt, dst_tbt);
|
|
|
|
|
if (action == QET::Retry) {
|
|
|
|
|
continue;
|
|
|
|
|
} else if (action == QET::Erase) {
|
|
|
|
|
break;
|
2012-04-04 16:13:08 +00:00
|
|
|
|
} else if (action == QET::Abort || action == QET::Ignore) {
|
2012-01-22 10:40:37 +00:00
|
|
|
|
return(QString());
|
|
|
|
|
} else if (action == QET::Rename) {
|
|
|
|
|
target_name = handler -> nameForRenamingOperation();
|
2012-04-04 16:13:08 +00:00
|
|
|
|
} else if (action == QET::Managed) {
|
|
|
|
|
return(target_name);
|
2012-01-22 10:40:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if (!m_titleblocks_collection.setTemplateXmlDescription(target_name, src_tbt.getTemplateXmlDescription()))
|
2015-11-16 08:59:43 +00:00
|
|
|
|
{
|
2015-03-02 20:14:56 +00:00
|
|
|
|
handler -> errorWithATemplate(src_tbt, tr("Une erreur s'est produite durant l'intégration du modèle.", "error message"));
|
2012-01-22 10:40:37 +00:00
|
|
|
|
target_name = QString();
|
|
|
|
|
}
|
|
|
|
|
return(target_name);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
|
|
|
|
Permet de savoir si un element est utilise dans un projet
|
|
|
|
|
@param location Emplacement d'un element
|
|
|
|
|
@return true si l'element location est utilise sur au moins un des schemas
|
|
|
|
|
de ce projet, false sinon
|
|
|
|
|
*/
|
2016-06-30 09:12:25 +00:00
|
|
|
|
bool QETProject::usesElement(const ElementsLocation &location) const
|
|
|
|
|
{
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach(Diagram *diagram, diagrams()) {
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (diagram -> usesElement(location)) {
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-30 09:12:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::unusedElements
|
|
|
|
|
@return the list of unused element (exactly her location)
|
|
|
|
|
An unused element, is an element present in the embedded collection but not present in a diagram of this project.
|
|
|
|
|
Be aware that an element can be not present in a diagram,
|
|
|
|
|
but managed by an undo command (delete an element), so an unused element can be used after an undo.
|
|
|
|
|
*/
|
2016-06-30 09:12:25 +00:00
|
|
|
|
QList<ElementsLocation> QETProject::unusedElements() const
|
|
|
|
|
{
|
|
|
|
|
QList <ElementsLocation> unused_list;
|
|
|
|
|
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach(ElementsLocation location, m_elements_collection->elementsLocation())
|
2016-06-30 09:12:25 +00:00
|
|
|
|
if (location.isElement() && !usesElement(location))
|
|
|
|
|
unused_list << location;
|
|
|
|
|
|
|
|
|
|
return unused_list;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-23 20:36:51 +00:00
|
|
|
|
/**
|
|
|
|
|
@param location Location of a title block template
|
|
|
|
|
@return true if the provided template is used by at least one diagram
|
|
|
|
|
within this project, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &location) {
|
2022-12-04 06:24:28 -05:00
|
|
|
|
// a diagram can only use a title block template embedded within its parent project
|
2012-01-23 20:36:51 +00:00
|
|
|
|
if (location.parentProject() != this) return(false);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach (Diagram *diagram, diagrams()) {
|
2012-01-23 20:36:51 +00:00
|
|
|
|
if (diagram -> usesTitleBlockTemplate(location.name())) {
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(false);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::addNewDiagram
|
|
|
|
|
Add a new diagram in project at position pos.
|
|
|
|
|
@param pos
|
|
|
|
|
@return the new created diagram
|
|
|
|
|
*/
|
2020-05-24 16:24:39 +02:00
|
|
|
|
Diagram *QETProject::addNewDiagram(int pos)
|
|
|
|
|
{
|
|
|
|
|
if (isReadOnly()) {
|
|
|
|
|
return(nullptr);
|
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2018-07-30 15:24:29 +00:00
|
|
|
|
Diagram *diagram = new Diagram(this);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-05-24 16:24:39 +02:00
|
|
|
|
diagram->border_and_titleblock.importBorder(defaultBorderProperties());
|
|
|
|
|
diagram->border_and_titleblock.importTitleBlock(defaultTitleBlockProperties());
|
|
|
|
|
diagram->defaultConductorProperties = defaultConductorProperties();
|
|
|
|
|
|
|
|
|
|
addDiagram(diagram, pos);
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit diagramAdded(this, diagram);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
return(diagram);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::removeDiagram
|
2020-08-17 21:24:20 +02:00
|
|
|
|
Remove diagram from project
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@param diagram
|
|
|
|
|
*/
|
2020-07-06 21:52:14 +02:00
|
|
|
|
void QETProject::removeDiagram(Diagram *diagram)
|
|
|
|
|
{
|
|
|
|
|
if (isReadOnly() ||
|
|
|
|
|
!diagram || !m_diagrams_list.contains(diagram)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-02-07 07:54:54 +00:00
|
|
|
|
|
2020-07-06 21:52:14 +02:00
|
|
|
|
if (m_diagrams_list.removeAll(diagram))
|
|
|
|
|
{
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit diagramRemoved(this, diagram);
|
2020-07-06 21:52:14 +02:00
|
|
|
|
diagram->deleteLater();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
updateDiagramsFolioData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Gere le fait que l'ordre des schemas ait change
|
|
|
|
|
@param old_index ancien indice du schema deplace
|
|
|
|
|
@param new_index nouvel indice du schema deplace
|
|
|
|
|
Si l'ancien ou le nouvel index est negatif ou superieur au nombre de schemas
|
|
|
|
|
dans le projet, cette methode ne fait rien.
|
|
|
|
|
Les index vont de 0 a "nombre de schemas - 1"
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::diagramOrderChanged(int old_index, int new_index) {
|
|
|
|
|
if (old_index < 0 || new_index < 0) return;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2017-03-05 13:10:47 +00:00
|
|
|
|
int diagram_max_index = m_diagrams_list.size() - 1;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (old_index > diagram_max_index || new_index > diagram_max_index) return;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list.move(old_index, new_index);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
updateDiagramsFolioData();
|
2012-07-13 17:34:34 +00:00
|
|
|
|
setModified(true);
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit projectDiagramsOrderChanged(this, old_index, new_index);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-07 19:45:32 +00:00
|
|
|
|
/**
|
|
|
|
|
Mark this project as modified and emit the projectModified() signal.
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::setModified(bool modified) {
|
2019-03-16 10:50:30 +00:00
|
|
|
|
if (m_modified != modified) {
|
|
|
|
|
m_modified = modified;
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit projectModified(this, m_modified);
|
|
|
|
|
emit projectInformationsChanged(this);
|
2012-07-07 19:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::readProjectXml
|
|
|
|
|
Read and make the project from an xml description
|
|
|
|
|
@param xml_project : the description of the project from an xml
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
void QETProject::readProjectXml(QDomDocument &xml_project)
|
|
|
|
|
{
|
|
|
|
|
QDomElement root_elmt = xml_project.documentElement();
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_state = ProjectParsingRunning;
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-08-25 20:32:21 +02:00
|
|
|
|
//The roots of the xml document must be a "project" element
|
2021-03-30 19:59:14 +02:00
|
|
|
|
if (root_elmt.tagName() == QLatin1String("project"))
|
2020-08-25 20:32:21 +02:00
|
|
|
|
{
|
|
|
|
|
//Normal opening mode
|
2021-03-30 19:59:14 +02:00
|
|
|
|
if (root_elmt.hasAttribute(QStringLiteral("version")))
|
2015-11-15 19:47:15 +00:00
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
bool conv_ok;
|
2023-01-12 13:27:55 +01:00
|
|
|
|
QVersionNumber qet_version = QVersionNumber::fromString(QET::version);
|
|
|
|
|
m_project_qet_version = QVersionNumber::fromString(root_elmt.attribute(QStringLiteral("version")));
|
|
|
|
|
|
2020-09-24 17:01:33 +02:00
|
|
|
|
#if TODO_LIST
|
2020-08-25 20:32:21 +02:00
|
|
|
|
#pragma message("@TODO use of version convert")
|
2020-09-24 17:01:33 +02:00
|
|
|
|
#endif
|
2023-01-12 13:27:55 +01:00
|
|
|
|
if (qet_version < m_project_qet_version)
|
2015-11-15 19:47:15 +00:00
|
|
|
|
{
|
2023-01-13 09:28:05 +01:00
|
|
|
|
|
2015-03-02 20:14:56 +00:00
|
|
|
|
int ret = QET::QetMessageBox::warning(
|
2020-08-25 20:32:21 +02:00
|
|
|
|
nullptr,
|
|
|
|
|
tr("Avertissement",
|
|
|
|
|
"message box title"),
|
2023-01-13 10:47:52 +01:00
|
|
|
|
tr("Ce document semble avoir été enregistré avec une version %1"
|
|
|
|
|
"\n qui est ultérieure à votre version !"
|
2023-01-13 09:28:05 +01:00
|
|
|
|
" \n"
|
2023-01-13 09:32:05 +01:00
|
|
|
|
"Vous utilisez actuellement QElectroTech en version %2")
|
2023-01-13 10:47:52 +01:00
|
|
|
|
.arg(root_elmt.attribute(QStringLiteral("version")), QET::version +
|
|
|
|
|
tr(".\n Il est alors possible que l'ouverture de tout ou partie de ce "
|
2020-08-25 20:32:21 +02:00
|
|
|
|
"document échoue.\n"
|
2023-01-13 10:47:52 +01:00
|
|
|
|
"Que désirez vous faire ?"),
|
2020-08-25 20:32:21 +02:00
|
|
|
|
"message box content"),
|
2015-11-15 19:47:15 +00:00
|
|
|
|
QMessageBox::Open | QMessageBox::Cancel
|
|
|
|
|
);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
if (ret == QMessageBox::Cancel)
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_state = FileOpenDiscard;
|
2011-08-26 19:06:35 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2023-01-12 13:27:55 +01:00
|
|
|
|
|
2021-02-27 14:01:33 +01:00
|
|
|
|
//Since QElectrotech 0.9 the compatibility with project made with
|
|
|
|
|
//Qet 0.6 or lower is break;
|
2023-01-12 13:27:55 +01:00
|
|
|
|
//keep float here for very old version
|
2023-01-12 15:09:42 +01:00
|
|
|
|
qreal r_project_qet_version = root_elmt.attribute(QStringLiteral("version")).toDouble(&conv_ok);
|
2023-01-13 10:41:43 +01:00
|
|
|
|
if (conv_ok && m_project_qet_version < QVersionNumber(0, 100) && r_project_qet_version <= 0.6)
|
2021-02-27 14:01:33 +01:00
|
|
|
|
{
|
|
|
|
|
auto ret = QET::QetMessageBox::warning(
|
2023-01-13 10:47:52 +01:00
|
|
|
|
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) +
|
|
|
|
|
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"
|
|
|
|
|
"Que désirez vous faire ?"),
|
2023-01-13 09:28:05 +01:00
|
|
|
|
QMessageBox::Open | QMessageBox::Cancel
|
2023-01-13 10:47:52 +01:00
|
|
|
|
);
|
2021-02-27 14:01:33 +01:00
|
|
|
|
|
|
|
|
|
if (ret == QMessageBox::Cancel)
|
|
|
|
|
{
|
|
|
|
|
m_state = FileOpenDiscard;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2021-03-30 19:59:14 +02:00
|
|
|
|
setTitle(root_elmt.attribute(QStringLiteral("title")));
|
2015-11-15 19:47:15 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_state = ProjectParsingFailed;
|
2023-01-12 16:19:44 +01:00
|
|
|
|
return;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-08-02 18:20:30 +02:00
|
|
|
|
m_data_base.blockSignals(true);
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//Load the project-wide properties
|
|
|
|
|
readProjectPropertiesXml(xml_project);
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//Load the default properties for the new diagrams
|
|
|
|
|
readDefaultPropertiesXml(xml_project);
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//load the embedded titleblock templates
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_titleblocks_collection.fromXml(xml_project.documentElement());
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//Load the embedded elements collection
|
|
|
|
|
readElementsCollectionXml(xml_project);
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//Load the diagrams
|
|
|
|
|
readDiagramsXml(xml_project);
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
|
|
|
|
//Load the terminal strip
|
|
|
|
|
readTerminalStripXml(xml_project);
|
|
|
|
|
|
2022-12-21 19:18:49 +01:00
|
|
|
|
//Now that all are loaded we refresh content of the project.
|
|
|
|
|
refresh();
|
|
|
|
|
|
2021-09-10 23:30:20 +02:00
|
|
|
|
|
2020-08-02 18:20:30 +02:00
|
|
|
|
m_data_base.blockSignals(false);
|
|
|
|
|
m_data_base.updateDB();
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_state = Ok;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::readDiagramsXml
|
|
|
|
|
Load the diagrams from the xml description of the project.
|
|
|
|
|
Note a project can have 0 diagram
|
|
|
|
|
@param xml_project
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
void QETProject::readDiagramsXml(QDomDocument &xml_project)
|
|
|
|
|
{
|
2020-09-24 17:01:33 +02:00
|
|
|
|
#if TODO_LIST
|
2020-08-25 20:32:21 +02:00
|
|
|
|
#pragma message("@TODO try to solve a weird bug (dialog is black) since port to Qt5 with the DialogWaiting")
|
2020-09-24 17:01:33 +02:00
|
|
|
|
#endif
|
2015-03-02 20:14:56 +00:00
|
|
|
|
//@TODO try to solve a weird bug (dialog is black) since port to Qt5 with the DialogWaiting
|
2013-04-11 06:55:00 +00:00
|
|
|
|
//show DialogWaiting
|
2018-04-04 15:07:52 +00:00
|
|
|
|
DialogWaiting *dlgWaiting = nullptr;
|
|
|
|
|
if(DialogWaiting::hasInstance())
|
|
|
|
|
{
|
|
|
|
|
dlgWaiting = DialogWaiting::instance();
|
|
|
|
|
dlgWaiting -> setModal(true);
|
|
|
|
|
dlgWaiting -> show();
|
2020-08-25 20:32:21 +02:00
|
|
|
|
dlgWaiting -> setTitle(tr("<p align=\"center\">"
|
|
|
|
|
"<b>Ouverture du projet en cours...</b><br/>"
|
|
|
|
|
"Création des folios"
|
|
|
|
|
"</p>"));
|
2018-04-04 15:07:52 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2020-08-25 20:32:21 +02:00
|
|
|
|
//Search the diagrams in the project
|
2021-03-30 19:59:14 +02:00
|
|
|
|
QDomNodeList diagram_nodes = xml_project.elementsByTagName(QStringLiteral("diagram"));
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2018-04-04 15:07:52 +00:00
|
|
|
|
if(dlgWaiting)
|
|
|
|
|
dlgWaiting->setProgressBarRange(0, diagram_nodes.length()*3);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2015-03-02 20:14:56 +00:00
|
|
|
|
for (int i = 0 ; i < diagram_nodes.length() ; ++ i)
|
|
|
|
|
{
|
2018-04-04 15:07:52 +00:00
|
|
|
|
if(dlgWaiting)
|
|
|
|
|
dlgWaiting->setProgressBar(i+1);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2015-03-02 20:14:56 +00:00
|
|
|
|
if (diagram_nodes.at(i).isElement())
|
|
|
|
|
{
|
2020-08-25 20:32:21 +02:00
|
|
|
|
QDomElement diagram_xml_element = diagram_nodes
|
|
|
|
|
.at(i)
|
|
|
|
|
.toElement();
|
2021-05-14 13:38:59 +02:00
|
|
|
|
auto diagram = new Diagram(this);
|
|
|
|
|
m_diagrams_list << diagram;
|
2020-07-06 21:52:14 +02:00
|
|
|
|
|
2021-05-14 13:38:59 +02:00
|
|
|
|
connect(&diagram->border_and_titleblock, &BorderTitleBlock::needFolioData,
|
|
|
|
|
this, &QETProject::updateDiagramsFolioData);
|
|
|
|
|
connect(diagram, &Diagram::usedTitleBlockTemplateChanged,
|
|
|
|
|
this, &QETProject::usedTitleBlockTemplateChanged);
|
2020-07-06 21:52:14 +02:00
|
|
|
|
|
|
|
|
|
diagram->initFromXml(diagram_xml_element);
|
|
|
|
|
if(dlgWaiting)
|
|
|
|
|
dlgWaiting->setDetail(diagram->title());
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-31 14:39:34 +00:00
|
|
|
|
|
2021-05-14 13:38:59 +02:00
|
|
|
|
updateDiagramsFolioData();
|
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
//Initialise links between elements in this project
|
2016-10-17 14:26:13 +00:00
|
|
|
|
//and refresh the text of conductor
|
2018-04-04 15:07:52 +00:00
|
|
|
|
if(dlgWaiting)
|
|
|
|
|
{
|
|
|
|
|
dlgWaiting->setTitle( tr("<p align=\"center\">"
|
|
|
|
|
"<b>Ouverture du projet en cours...</b><br/>"
|
|
|
|
|
"Mise en place des références croisées"
|
|
|
|
|
"</p>"));
|
|
|
|
|
}
|
2010-12-19 18:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::readElementsCollectionXml
|
|
|
|
|
Load the diagrams from the xml description of the project
|
|
|
|
|
@param xml_project : the xml description of the project
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
void QETProject::readElementsCollectionXml(QDomDocument &xml_project)
|
|
|
|
|
{
|
|
|
|
|
//Get the embedded elements collection of the project
|
2021-03-30 19:59:14 +02:00
|
|
|
|
QDomNodeList collection_roots = xml_project.elementsByTagName(QStringLiteral("collection"));
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QDomElement collection_root;
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
|
|
|
|
if (!collection_roots.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
//Only the first found collection is take
|
2009-04-03 19:30:25 +00:00
|
|
|
|
collection_root = collection_roots.at(0).toElement();
|
|
|
|
|
}
|
2016-05-25 15:12:01 +00:00
|
|
|
|
//Make an empty collection
|
|
|
|
|
if (collection_root.isNull()) {
|
2015-12-16 17:16:15 +00:00
|
|
|
|
m_elements_collection = new XmlElementCollection(this);
|
|
|
|
|
}
|
2016-05-25 15:12:01 +00:00
|
|
|
|
//Read the collection
|
|
|
|
|
else {
|
2015-12-16 17:16:15 +00:00
|
|
|
|
m_elements_collection = new XmlElementCollection(collection_root, this);
|
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-01 21:54:07 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::readProjectPropertiesXml
|
|
|
|
|
Load project properties from the XML description of the project
|
|
|
|
|
@param xml_project : the xml description of the project
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
void QETProject::readProjectPropertiesXml(QDomDocument &xml_project)
|
|
|
|
|
{
|
2022-04-09 13:07:47 +02:00
|
|
|
|
for (const auto &dom_elmt : QET::findInDomElement(xml_project.documentElement(), QStringLiteral("properties")))
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_project_properties.fromXml(dom_elmt);
|
2012-07-01 21:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
|
@brief QETProject::readDefaultPropertiesXml
|
|
|
|
|
load default properties for new diagram, found in the xml of this project
|
|
|
|
|
or by default find in the QElectroTech global conf
|
|
|
|
|
@param xml_project : the xml description of the project
|
|
|
|
|
*/
|
2015-11-15 19:47:15 +00:00
|
|
|
|
void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
|
|
|
|
{
|
|
|
|
|
// Find xml element where is stored properties for new diagram
|
2021-03-30 19:59:14 +02:00
|
|
|
|
QDomNodeList newdiagrams_nodes = xml_project.elementsByTagName(QStringLiteral("newdiagrams"));
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (newdiagrams_nodes.isEmpty()) return;
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QDomElement newdiagrams_elmt = newdiagrams_nodes.at(0).toElement();
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
|
|
|
|
// By default, use value find in the global conf of QElectroTech
|
2021-03-11 19:52:50 +01:00
|
|
|
|
default_border_properties_ = BorderProperties:: defaultProperties();
|
2014-10-26 11:57:38 +00:00
|
|
|
|
default_titleblock_properties_ = TitleBlockProperties::defaultProperties();
|
|
|
|
|
default_conductor_properties_ = ConductorProperties:: defaultProperties();
|
2021-03-11 19:52:50 +01:00
|
|
|
|
m_default_report_properties = ReportProperties:: defaultProperties();
|
|
|
|
|
m_default_xref_properties = XRefProperties:: defaultProperties();
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
|
|
|
|
//Read values indicate in project
|
2016-07-05 20:14:14 +00:00
|
|
|
|
QDomElement border_elmt, titleblock_elmt, conductors_elmt, report_elmt, xref_elmt, conds_autonums, folio_autonums, element_autonums;
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
|
|
|
|
for (QDomNode child = newdiagrams_elmt.firstChild() ; !child.isNull() ; child = child.nextSibling())
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QDomElement child_elmt = child.toElement();
|
|
|
|
|
if (child_elmt.isNull()) continue;
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
2021-03-30 19:59:14 +02:00
|
|
|
|
if (child_elmt.tagName() == QLatin1String("border"))
|
2009-04-03 19:30:25 +00:00
|
|
|
|
border_elmt = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName() == QLatin1String("inset"))
|
2010-12-20 02:45:36 +00:00
|
|
|
|
titleblock_elmt = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName() == QLatin1String("conductors"))
|
2009-04-03 19:30:25 +00:00
|
|
|
|
conductors_elmt = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName() == QLatin1String("report"))
|
2014-01-18 19:04:39 +00:00
|
|
|
|
report_elmt = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName() == QLatin1String("xrefs"))
|
2014-04-11 09:51:21 +00:00
|
|
|
|
xref_elmt = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName() == QLatin1String("conductors_autonums"))
|
2014-07-31 10:02:33 +00:00
|
|
|
|
conds_autonums = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName()== QLatin1String("folio_autonums"))
|
2016-05-13 15:00:22 +00:00
|
|
|
|
folio_autonums = child_elmt;
|
2021-03-30 19:59:14 +02:00
|
|
|
|
else if (child_elmt.tagName()== QLatin1String("element_autonums"))
|
2016-07-05 20:14:14 +00:00
|
|
|
|
element_autonums = child_elmt;
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
2015-11-15 19:47:15 +00:00
|
|
|
|
|
2016-07-05 20:14:14 +00:00
|
|
|
|
// size, titleblock, conductor, report, conductor autonum, folio autonum, element autonum
|
2014-04-11 09:51:21 +00:00
|
|
|
|
if (!border_elmt.isNull()) default_border_properties_.fromXml(border_elmt);
|
|
|
|
|
if (!titleblock_elmt.isNull()) default_titleblock_properties_.fromXml(titleblock_elmt);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
if (!conductors_elmt.isNull()) default_conductor_properties_.fromXml(conductors_elmt);
|
2021-03-30 19:59:14 +02:00
|
|
|
|
if (!report_elmt.isNull()) setDefaultReportProperties(report_elmt.attribute(QStringLiteral("label")));
|
2015-11-15 19:47:15 +00:00
|
|
|
|
if (!xref_elmt.isNull())
|
|
|
|
|
{
|
2022-04-09 13:07:47 +02:00
|
|
|
|
for (const auto &elmt : QET::findInDomElement(xref_elmt, QStringLiteral("xref")))
|
2015-11-15 19:47:15 +00:00
|
|
|
|
{
|
2014-07-03 08:52:14 +00:00
|
|
|
|
XRefProperties xrp;
|
|
|
|
|
xrp.fromXml(elmt);
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_default_xref_properties.insert(elmt.attribute(QStringLiteral("type")), xrp);
|
2014-07-03 08:52:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-15 19:47:15 +00:00
|
|
|
|
if (!conds_autonums.isNull())
|
|
|
|
|
{
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_current_conductor_autonum = conds_autonums.attribute(QStringLiteral("current_autonum"));
|
|
|
|
|
m_freeze_new_conductors = conds_autonums.attribute(QStringLiteral("freeze_new_conductors")) == QLatin1String("true");
|
|
|
|
|
for (auto elmt : QET::findInDomElement(conds_autonums, QStringLiteral("conductor_autonum")))
|
2015-11-15 19:47:15 +00:00
|
|
|
|
{
|
2014-07-31 10:02:33 +00:00
|
|
|
|
NumerotationContext nc;
|
|
|
|
|
nc.fromXml(elmt);
|
|
|
|
|
m_conductor_autonum.insert(elmt.attribute("title"), nc);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-13 15:00:22 +00:00
|
|
|
|
if (!folio_autonums.isNull())
|
|
|
|
|
{
|
2021-03-30 19:59:14 +02:00
|
|
|
|
for (auto elmt : QET::findInDomElement(folio_autonums, QStringLiteral("folio_autonum")))
|
2016-07-10 01:33:49 +00:00
|
|
|
|
{
|
2016-05-13 15:00:22 +00:00
|
|
|
|
NumerotationContext nc;
|
|
|
|
|
nc.fromXml(elmt);
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_folio_autonum.insert(elmt.attribute(QStringLiteral("title")), nc);
|
2016-05-13 15:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-05 20:14:14 +00:00
|
|
|
|
if (!element_autonums.isNull())
|
|
|
|
|
{
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_current_element_autonum = element_autonums.attribute(QStringLiteral("current_autonum"));
|
|
|
|
|
m_freeze_new_elements = element_autonums.attribute(QStringLiteral("freeze_new_elements")) == QLatin1String("true");
|
|
|
|
|
for (auto elmt : QET::findInDomElement(element_autonums, QStringLiteral("element_autonum")))
|
2016-07-10 01:33:49 +00:00
|
|
|
|
{
|
|
|
|
|
NumerotationContext nc;
|
|
|
|
|
nc.fromXml(elmt);
|
2021-03-30 19:59:14 +02:00
|
|
|
|
m_element_autonum.insert(elmt.attribute(QStringLiteral("title")), nc);
|
2016-07-10 01:33:49 +00:00
|
|
|
|
}
|
2016-07-05 20:14:14 +00:00
|
|
|
|
}
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-10 23:30:20 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::readTerminalStripXml
|
|
|
|
|
* Read the terminal strips of this project
|
|
|
|
|
* @param xml_project
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::readTerminalStripXml(const QDomDocument &xml_project)
|
|
|
|
|
{
|
|
|
|
|
auto xml_elmt = xml_project.documentElement();
|
|
|
|
|
auto xml_strips = xml_elmt.firstChildElement(QStringLiteral("terminal_strips"));
|
|
|
|
|
if (!xml_strips.isNull())
|
|
|
|
|
{
|
|
|
|
|
for (auto xml_strip : QETXML::findInDomElement(xml_strips, TerminalStrip::xmlTagName()))
|
|
|
|
|
{
|
|
|
|
|
auto terminal_strip = new TerminalStrip(this);
|
|
|
|
|
terminal_strip->fromXml(xml_strip);
|
|
|
|
|
addTerminalStrip(terminal_strip);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-15 19:47:15 +00:00
|
|
|
|
/**
|
|
|
|
|
Export project properties under the \a xml_element XML element.
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::writeProjectPropertiesXml(QDomElement &xml_element) {
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_project_properties.toXml(xml_element);
|
2015-11-15 19:47:15 +00:00
|
|
|
|
}
|
2014-04-11 09:51:21 +00:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
|
@brief QETProject::writeDefaultPropertiesXml
|
|
|
|
|
Export all defaults properties used by a new diagram and his content
|
2020-08-17 21:24:20 +02:00
|
|
|
|
size of border
|
|
|
|
|
content of titleblock
|
|
|
|
|
default conductor
|
|
|
|
|
defaut folio report
|
|
|
|
|
default Xref
|
2022-12-04 06:24:28 -05:00
|
|
|
|
@param xml_element : xml element to use to store default properties.
|
2020-08-08 23:58:17 +02:00
|
|
|
|
*/
|
2020-07-15 20:48:52 +02:00
|
|
|
|
void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
|
|
|
|
{
|
2009-04-03 19:30:25 +00:00
|
|
|
|
QDomDocument xml_document = xml_element.ownerDocument();
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2014-04-11 09:51:21 +00:00
|
|
|
|
// export size of border
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QDomElement border_elmt = xml_document.createElement("border");
|
|
|
|
|
default_border_properties_.toXml(border_elmt);
|
|
|
|
|
xml_element.appendChild(border_elmt);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2014-04-11 09:51:21 +00:00
|
|
|
|
// export content of titleblock
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
|
|
|
|
default_titleblock_properties_.toXml(titleblock_elmt);
|
|
|
|
|
xml_element.appendChild(titleblock_elmt);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2014-04-11 09:51:21 +00:00
|
|
|
|
// exporte default conductor
|
2021-03-11 19:52:50 +01:00
|
|
|
|
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
|
|
|
|
default_conductor_properties_.toXml(conductor_elmt);
|
|
|
|
|
xml_element.appendChild(conductor_elmt);
|
2014-01-18 19:04:39 +00:00
|
|
|
|
|
|
|
|
|
// export default report properties
|
|
|
|
|
QDomElement report_elmt = xml_document.createElement("report");
|
|
|
|
|
report_elmt.setAttribute("label", defaultReportProperties());
|
|
|
|
|
xml_element.appendChild(report_elmt);
|
2014-04-11 09:51:21 +00:00
|
|
|
|
|
2020-07-15 20:48:52 +02:00
|
|
|
|
// export default XRef properties
|
2014-07-03 08:52:14 +00:00
|
|
|
|
QDomElement xrefs_elmt = xml_document.createElement("xrefs");
|
2020-07-15 20:48:52 +02:00
|
|
|
|
for (QString key : defaultXRefProperties().keys())
|
|
|
|
|
{
|
|
|
|
|
auto xrp = defaultXRefProperties(key);
|
|
|
|
|
xrp.setKey(key);
|
|
|
|
|
auto xref_dom = xrp.toXml(xml_document);
|
|
|
|
|
xrefs_elmt.appendChild(xref_dom);
|
2014-07-03 08:52:14 +00:00
|
|
|
|
}
|
|
|
|
|
xml_element.appendChild(xrefs_elmt);
|
2014-07-31 10:02:33 +00:00
|
|
|
|
|
2016-08-29 15:37:42 +00:00
|
|
|
|
//Export Conductor Autonums
|
|
|
|
|
QDomElement conductor_autonums = xml_document.createElement("conductors_autonums");
|
|
|
|
|
conductor_autonums.setAttribute("current_autonum", m_current_conductor_autonum);
|
2016-09-01 19:41:49 +00:00
|
|
|
|
conductor_autonums.setAttribute("freeze_new_conductors", m_freeze_new_conductors ? "true" : "false");
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach (QString key, conductorAutoNum().keys()) {
|
2016-08-29 15:37:42 +00:00
|
|
|
|
QDomElement conductor_autonum = conductorAutoNum(key).toXml(xml_document, "conductor_autonum");
|
|
|
|
|
if (key != "" && conductorAutoNumFormula(key) != "") {
|
|
|
|
|
conductor_autonum.setAttribute("title", key);
|
|
|
|
|
conductor_autonum.setAttribute("formula", conductorAutoNumFormula(key));
|
|
|
|
|
conductor_autonums.appendChild(conductor_autonum);
|
|
|
|
|
}
|
2014-07-31 10:02:33 +00:00
|
|
|
|
}
|
2016-08-29 15:37:42 +00:00
|
|
|
|
xml_element.appendChild(conductor_autonums);
|
2016-05-13 15:00:22 +00:00
|
|
|
|
|
|
|
|
|
//Export Folio Autonums
|
|
|
|
|
QDomElement folio_autonums = xml_document.createElement("folio_autonums");
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach (QString key, folioAutoNum().keys()) {
|
2016-05-13 15:00:22 +00:00
|
|
|
|
QDomElement folio_autonum = folioAutoNum(key).toXml(xml_document, "folio_autonum");
|
|
|
|
|
folio_autonum.setAttribute("title", key);
|
|
|
|
|
folio_autonums.appendChild(folio_autonum);
|
|
|
|
|
}
|
|
|
|
|
xml_element.appendChild(folio_autonums);
|
2016-07-05 20:14:14 +00:00
|
|
|
|
|
|
|
|
|
//Export Element Autonums
|
|
|
|
|
QDomElement element_autonums = xml_document.createElement("element_autonums");
|
2016-07-14 17:16:14 +00:00
|
|
|
|
element_autonums.setAttribute("current_autonum", m_current_element_autonum);
|
2016-07-20 15:07:21 +00:00
|
|
|
|
element_autonums.setAttribute("freeze_new_elements", m_freeze_new_elements ? "true" : "false");
|
2017-02-05 16:18:50 +00:00
|
|
|
|
foreach (QString key, elementAutoNum().keys()) {
|
2016-07-10 01:33:49 +00:00
|
|
|
|
QDomElement element_autonum = elementAutoNum(key).toXml(xml_document, "element_autonum");
|
2016-07-18 15:23:30 +00:00
|
|
|
|
if (key != "" && elementAutoNumFormula(key) != "") {
|
|
|
|
|
element_autonum.setAttribute("title", key);
|
|
|
|
|
element_autonum.setAttribute("formula", elementAutoNumFormula(key));
|
|
|
|
|
element_autonums.appendChild(element_autonum);
|
|
|
|
|
}
|
2016-07-10 01:33:49 +00:00
|
|
|
|
}
|
2016-07-05 20:14:14 +00:00
|
|
|
|
xml_element.appendChild(element_autonums);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-08 23:54:15 +00:00
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
|
@brief QETProject::addDiagram
|
|
|
|
|
Add a diagram in this project
|
|
|
|
|
@param diagram added diagram
|
2022-12-04 06:24:28 -05:00
|
|
|
|
@param pos position of the new diagram, by default at the end
|
2020-08-08 23:58:17 +02:00
|
|
|
|
*/
|
2020-05-24 16:24:39 +02:00
|
|
|
|
void QETProject::addDiagram(Diagram *diagram, int pos)
|
|
|
|
|
{
|
|
|
|
|
if (!diagram) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 23:58:17 +02:00
|
|
|
|
connect(&diagram->border_and_titleblock,
|
|
|
|
|
&BorderTitleBlock::needFolioData,
|
|
|
|
|
this,
|
|
|
|
|
&QETProject::updateDiagramsFolioData);
|
|
|
|
|
connect(diagram, &Diagram::usedTitleBlockTemplateChanged,
|
|
|
|
|
this, &QETProject::usedTitleBlockTemplateChanged);
|
2020-05-24 16:24:39 +02:00
|
|
|
|
|
|
|
|
|
if (pos == -1) {
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list << diagram;
|
2020-05-24 16:24:39 +02:00
|
|
|
|
} else {
|
|
|
|
|
m_diagrams_list.insert(pos, diagram);
|
|
|
|
|
}
|
2020-11-01 21:27:40 +01:00
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
updateDiagramsFolioData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@return La liste des noms a utiliser pour la categorie dediee aux elements
|
|
|
|
|
integres automatiquement dans le projet.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
NamesList QETProject::namesListForIntegrationCategory()
|
|
|
|
|
{
|
2020-12-10 16:01:10 +01:00
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
|
|
|
|
NamesList names;
|
|
|
|
|
const QChar russian_data[24] = {
|
|
|
|
|
0x0418, 0x043C, 0x043F, 0x043E, 0x0440, 0x0442, 0x0438, 0x0440,
|
|
|
|
|
0x043E, 0x0432, 0x0430, 0x043D, 0x043D, 0x044B, 0x0435, 0x0020,
|
|
|
|
|
0x044D, 0x043B, 0x0435, 0x043C, 0x0435, 0x043D, 0x0442, 0x044B};
|
|
|
|
|
const QChar greek_data[18] = {
|
|
|
|
|
0x0395,
|
|
|
|
|
0x03b9,
|
|
|
|
|
0x03c3,
|
|
|
|
|
0x03b7,
|
|
|
|
|
0x03b3,
|
|
|
|
|
0x03bc,
|
|
|
|
|
0x03ad,
|
|
|
|
|
0x03bd,
|
|
|
|
|
0x03b1,
|
|
|
|
|
0x0020,
|
|
|
|
|
0x03c3,
|
|
|
|
|
0x03c4,
|
|
|
|
|
0x03bf,
|
|
|
|
|
0x03b9,
|
|
|
|
|
0x03c7,
|
|
|
|
|
0x03b5,
|
|
|
|
|
0x03af,
|
|
|
|
|
0x03b1};
|
2023-01-02 20:13:42 +01:00
|
|
|
|
const QChar turkish_data[12] = {
|
|
|
|
|
0x0130,
|
|
|
|
|
0x0074,
|
|
|
|
|
0x0068,
|
|
|
|
|
0x0061,
|
|
|
|
|
0x006C,
|
|
|
|
|
0x0020,
|
|
|
|
|
0x00F6,
|
|
|
|
|
0x011F,
|
|
|
|
|
0x0065,
|
|
|
|
|
0x006C,
|
|
|
|
|
0x0065,
|
|
|
|
|
0x0072};
|
|
|
|
|
const QChar ukrainian_data[20] = {
|
|
|
|
|
0x0406,
|
|
|
|
|
0x043c,
|
|
|
|
|
0x043f,
|
|
|
|
|
0x043e,
|
|
|
|
|
0x0440,
|
|
|
|
|
0x0442,
|
|
|
|
|
0x043e,
|
|
|
|
|
0x0432,
|
|
|
|
|
0x0430,
|
|
|
|
|
0x043d,
|
|
|
|
|
0x0456,
|
|
|
|
|
0x0020,
|
|
|
|
|
0x0435,
|
|
|
|
|
0x043b,
|
|
|
|
|
0x0435,
|
|
|
|
|
0x043c,
|
|
|
|
|
0x0435,
|
|
|
|
|
0x043d,
|
|
|
|
|
0x0442,
|
|
|
|
|
0x0438};
|
2020-12-10 16:01:10 +01:00
|
|
|
|
const QChar japanese_data[10] = {
|
|
|
|
|
0x30A4,
|
|
|
|
|
0x30F3,
|
|
|
|
|
0x30D0,
|
|
|
|
|
0x30FC,
|
|
|
|
|
0x30C8,
|
|
|
|
|
0x3055,
|
|
|
|
|
0x308C,
|
|
|
|
|
0x305F,
|
|
|
|
|
0x8981,
|
|
|
|
|
0x7D20};
|
2013-07-04 16:15:51 +00:00
|
|
|
|
|
2015-03-02 20:14:56 +00:00
|
|
|
|
names.addName("fr", "Éléments importés");
|
2009-04-03 19:30:25 +00:00
|
|
|
|
names.addName("en", "Imported elements");
|
2014-04-30 19:13:36 +00:00
|
|
|
|
names.addName("de", "Importierte elemente");
|
2009-04-03 19:30:25 +00:00
|
|
|
|
names.addName("es", "Elementos importados");
|
2009-05-09 13:16:18 +00:00
|
|
|
|
names.addName("ru", QString(russian_data, 24));
|
2015-03-02 20:14:56 +00:00
|
|
|
|
names.addName("cs", "Zavedené prvky");
|
2010-03-28 16:27:48 +00:00
|
|
|
|
names.addName("pl", "Elementy importowane");
|
2014-04-30 19:13:36 +00:00
|
|
|
|
names.addName("pt", "elementos importados");
|
2011-03-02 07:15:24 +00:00
|
|
|
|
names.addName("it", "Elementi importati");
|
2013-07-04 16:15:51 +00:00
|
|
|
|
names.addName("el", QString(greek_data, 18));
|
2015-03-02 20:14:56 +00:00
|
|
|
|
names.addName("nl", "Elementen geïmporteerd");
|
2014-04-30 19:13:36 +00:00
|
|
|
|
names.addName("hr", "Uvezeni elementi");
|
|
|
|
|
names.addName("ca", "Elements importats");
|
|
|
|
|
names.addName("ro", "Elemente importate");
|
2023-01-02 20:13:42 +01:00
|
|
|
|
names.addName("tr", QString(turkish_data, 12));
|
|
|
|
|
names.addName("da", "Importerede elementer");
|
|
|
|
|
names.addName("sl", "Uvoženi elementi");
|
2020-08-15 14:17:29 +09:00
|
|
|
|
names.addName("ja", QString(japanese_data, 10));
|
2023-01-02 20:13:42 +01:00
|
|
|
|
names.addName("uk", QString(ukrainian_data, 20));
|
2020-12-10 16:01:10 +01:00
|
|
|
|
return (names);
|
|
|
|
|
#else
|
|
|
|
|
# if TODO_LIST
|
|
|
|
|
# pragma message("@TODO remove code for QT 6 or later")
|
|
|
|
|
# endif
|
|
|
|
|
qDebug() << "Help code for QT 6 or later";
|
|
|
|
|
NamesList names;
|
|
|
|
|
names.addName("fr", "Éléments importés");
|
|
|
|
|
names.addName("en", "Imported elements");
|
|
|
|
|
names.addName("de", "Importierte elemente");
|
|
|
|
|
names.addName("es", "Elementos importados");
|
|
|
|
|
names.addName("cs", "Zavedené prvky");
|
|
|
|
|
names.addName("pl", "Elementy importowane");
|
|
|
|
|
names.addName("pt", "elementos importados");
|
|
|
|
|
names.addName("it", "Elementi importati");
|
|
|
|
|
names.addName("nl", "Elementen geïmporteerd");
|
|
|
|
|
names.addName("hr", "Uvezeni elementi");
|
|
|
|
|
names.addName("ca", "Elements importats");
|
|
|
|
|
names.addName("ro", "Elemente importate");
|
2023-01-02 20:13:42 +01:00
|
|
|
|
names.addName("da", "Importerede elementer");
|
|
|
|
|
names.addName("sl", "Uvoženi elementi");
|
|
|
|
|
names.addName("uk", "Імпортовані елементи");
|
2020-12-10 16:01:10 +01:00
|
|
|
|
return (names);
|
|
|
|
|
#endif
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-24 18:08:06 +00:00
|
|
|
|
/**
|
2020-08-08 23:58:17 +02:00
|
|
|
|
@brief QETProject::writeBackup
|
|
|
|
|
Write a backup file of this project, in the case that QET crash
|
|
|
|
|
*/
|
2018-05-24 18:08:06 +00:00
|
|
|
|
void QETProject::writeBackup()
|
|
|
|
|
{
|
2020-12-16 23:06:08 +01:00
|
|
|
|
#ifdef BUILD_WITHOUT_KF5
|
|
|
|
|
#else
|
|
|
|
|
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
2020-08-08 23:58:17 +02:00
|
|
|
|
QDomDocument xml_project(toXml());
|
2020-10-03 16:04:54 +02:00
|
|
|
|
QtConcurrent::run(
|
|
|
|
|
QET::writeToFile,xml_project,&m_backup_file,nullptr);
|
2020-12-16 23:06:08 +01:00
|
|
|
|
# else
|
|
|
|
|
# if TODO_LIST
|
|
|
|
|
# pragma message("@TODO remove code for QT 6 or later")
|
|
|
|
|
# endif
|
2021-03-07 19:58:49 +01:00
|
|
|
|
qDebug() << "Help code for QT 6 or later"
|
|
|
|
|
<< "QtConcurrent::run its backwards now...function, object, args";
|
2020-12-16 23:06:08 +01:00
|
|
|
|
# endif
|
2020-10-03 16:04:54 +02:00
|
|
|
|
#endif
|
2018-05-24 18:08:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-07 19:45:32 +00:00
|
|
|
|
/**
|
|
|
|
|
@return true if project options (title, project-wide properties, settings
|
2012-07-13 17:34:34 +00:00
|
|
|
|
for new diagrams, diagrams order...) were modified, false otherwise.
|
2012-07-07 19:45:32 +00:00
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::projectOptionsWereModified()
|
|
|
|
|
{
|
2012-07-07 19:45:32 +00:00
|
|
|
|
// unlike similar methods, this method does not compare the content against
|
|
|
|
|
// expected values; instead, we just check whether we have been set as modified.
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(m_modified);
|
2012-07-07 19:45:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-01 21:54:07 +00:00
|
|
|
|
/**
|
|
|
|
|
@return the project-wide properties made available to child diagrams.
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
DiagramContext QETProject::projectProperties()
|
|
|
|
|
{
|
2019-03-16 10:50:30 +00:00
|
|
|
|
return(m_project_properties);
|
2012-07-01 21:54:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Use \a context as project-wide properties made available to child diagrams.
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::setProjectProperties(const DiagramContext &context) {
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_project_properties = context;
|
2012-07-01 21:54:07 +00:00
|
|
|
|
updateDiagramsFolioData();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-10 23:30:20 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::terminalStrip
|
|
|
|
|
* @return a QVector who contain all terminal strip owned by this project
|
|
|
|
|
*/
|
|
|
|
|
QVector<TerminalStrip *> QETProject::terminalStrip() const {
|
|
|
|
|
return m_terminal_strip_vector;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::newTerminalStrip
|
|
|
|
|
* @param installation : installation of the terminal strip
|
|
|
|
|
* @param location : location of the terminal strip
|
|
|
|
|
* @param name : name of the terminal strip
|
|
|
|
|
* @return Create a new terminal strip with this project as parent.
|
|
|
|
|
* You can retrieve this terminal strip at any time by calling the function
|
|
|
|
|
* QETProject::terminalStrip()
|
|
|
|
|
*/
|
|
|
|
|
TerminalStrip *QETProject::newTerminalStrip(QString installation, QString location, QString name)
|
|
|
|
|
{
|
|
|
|
|
auto ts = new TerminalStrip(installation,
|
|
|
|
|
location,
|
|
|
|
|
name,
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
m_terminal_strip_vector.append(ts);
|
|
|
|
|
return ts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::addTerminalStrip
|
|
|
|
|
* Add \p strip to the terminal strip list of the project.
|
|
|
|
|
* The project of \p strip must this project
|
|
|
|
|
* @param strip
|
|
|
|
|
* @return true if successfully added
|
|
|
|
|
*/
|
|
|
|
|
bool QETProject::addTerminalStrip(TerminalStrip *strip)
|
|
|
|
|
{
|
|
|
|
|
if (strip->parent() != this)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (m_terminal_strip_vector.contains(strip))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
m_terminal_strip_vector.append(strip);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief QETProject::removeTerminalStrip
|
|
|
|
|
* Remove \p strip from the terminal strip list of this project.
|
|
|
|
|
* Strip is removed from the list but not deleted.
|
|
|
|
|
* @param strip
|
|
|
|
|
* @return true if successfully removed.
|
|
|
|
|
*/
|
|
|
|
|
bool QETProject::removeTerminalStrip(TerminalStrip *strip) {
|
|
|
|
|
return m_terminal_strip_vector.removeOne(strip);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
|
/**
|
|
|
|
|
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
|
|
|
|
|
que l'on obtient en faisant Fichier > Nouveau.
|
|
|
|
|
@return true si les schemas, la collection embarquee ou les proprietes de ce
|
|
|
|
|
projet ont ete modifies.
|
|
|
|
|
Concretement, le projet doit avoir un titre vide et ni ses schemas ni sa
|
|
|
|
|
collection embarquee ne doivent avoir ete modifies.
|
|
|
|
|
@see diagramsWereModified(), embeddedCollectionWasModified()
|
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
|
bool QETProject::projectWasModified()
|
|
|
|
|
{
|
2014-11-27 17:47:01 +00:00
|
|
|
|
|
2021-03-11 19:52:50 +01:00
|
|
|
|
if ( projectOptionsWereModified() ||
|
|
|
|
|
!m_undo_stack -> isClean() ||
|
2019-03-16 10:50:30 +00:00
|
|
|
|
m_titleblocks_collection.templates().count() )
|
2014-11-27 17:47:01 +00:00
|
|
|
|
return(true);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2014-11-27 17:47:01 +00:00
|
|
|
|
else
|
|
|
|
|
return(false);
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Indique a chaque schema du projet quel est son numero de folio et combien de
|
|
|
|
|
folio le projet contient.
|
|
|
|
|
*/
|
2018-12-28 18:39:54 +00:00
|
|
|
|
void QETProject::updateDiagramsFolioData()
|
|
|
|
|
{
|
2017-03-05 13:10:47 +00:00
|
|
|
|
int total_folio = m_diagrams_list.count();
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2019-03-16 10:50:30 +00:00
|
|
|
|
DiagramContext project_wide_properties = m_project_properties;
|
2012-07-02 06:34:40 +00:00
|
|
|
|
project_wide_properties.addValue("projecttitle", title());
|
2018-08-05 15:04:15 +00:00
|
|
|
|
project_wide_properties.addValue("projectpath", filePath());
|
2018-08-06 16:12:00 +00:00
|
|
|
|
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2018-12-28 18:39:54 +00:00
|
|
|
|
for (int i = 0 ; i < total_folio ; ++ i)
|
|
|
|
|
{
|
2017-03-05 13:10:47 +00:00
|
|
|
|
QString autopagenum = m_diagrams_list[i]->border_and_titleblock.autoPageNum();
|
2016-05-13 15:00:22 +00:00
|
|
|
|
NumerotationContext nC = folioAutoNum(autopagenum);
|
|
|
|
|
NumerotationContextCommands nCC = NumerotationContextCommands(nC);
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
|
|
|
|
if ((m_diagrams_list[i]->border_and_titleblock.folio().contains("%autonum")) &&
|
2018-12-28 18:39:54 +00:00
|
|
|
|
(!autopagenum.isNull()))
|
|
|
|
|
{
|
2017-03-05 13:10:47 +00:00
|
|
|
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nCC.toRepresentedString(), project_wide_properties);
|
|
|
|
|
m_diagrams_list[i]->project()->addFolioAutoNum(autopagenum,nCC.next());
|
2016-05-13 15:00:22 +00:00
|
|
|
|
}
|
2018-12-28 18:39:54 +00:00
|
|
|
|
else {
|
|
|
|
|
m_diagrams_list[i] -> border_and_titleblock.setFolioData(i + 1, total_folio, nullptr, project_wide_properties);
|
2016-05-13 15:00:22 +00:00
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2018-12-28 18:39:54 +00:00
|
|
|
|
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-1)->border_and_titleblock.setNextFolioNum(m_diagrams_list.at(i)->border_and_titleblock.finalfolio());
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2018-12-28 18:39:54 +00:00
|
|
|
|
if (i == total_folio-1) {
|
|
|
|
|
m_diagrams_list.at(i)->border_and_titleblock.setNextFolioNum(QString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_diagrams_list.at(i)->border_and_titleblock.setPreviousFolioNum(QString());
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2022-04-09 13:07:47 +02:00
|
|
|
|
for (const auto &diagram_ : qAsConst(m_diagrams_list)) {
|
|
|
|
|
diagram_->update();
|
2009-04-03 19:30:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-08 17:04:34 +00:00
|
|
|
|
/**
|
|
|
|
|
Inform each diagram that the \a template_name title block changed.
|
|
|
|
|
@param collection Title block templates collection
|
|
|
|
|
@param template_name Name of the changed template
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::updateDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
|
|
|
|
Q_UNUSED(collection)
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2017-03-05 13:10:47 +00:00
|
|
|
|
foreach (Diagram *diagram, m_diagrams_list) {
|
2012-01-08 17:04:34 +00:00
|
|
|
|
diagram -> titleBlockTemplateChanged(template_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Inform each diagram that the \a template_name title block is about to be removed.
|
|
|
|
|
@param collection Title block templates collection
|
|
|
|
|
@param template_name Name of the removed template
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::removeDiagramsTitleBlockTemplate(TitleBlockTemplatesCollection *collection, const QString &template_name) {
|
|
|
|
|
Q_UNUSED(collection)
|
2020-09-21 20:23:20 +02:00
|
|
|
|
|
2012-01-08 17:04:34 +00:00
|
|
|
|
// warn diagrams that the given template is about to be removed
|
2017-03-05 13:10:47 +00:00
|
|
|
|
foreach (Diagram *diagram, m_diagrams_list) {
|
2012-01-08 17:04:34 +00:00
|
|
|
|
diagram -> titleBlockTemplateRemoved(template_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-23 20:36:51 +00:00
|
|
|
|
/**
|
|
|
|
|
Handles the fact a digram changed the title block template it used
|
|
|
|
|
@param template_name Name of the template
|
|
|
|
|
*/
|
|
|
|
|
void QETProject::usedTitleBlockTemplateChanged(const QString &template_name) {
|
2022-04-09 13:07:47 +02:00
|
|
|
|
emit diagramUsedTemplate(embeddedTitleBlockTemplatesCollection(), template_name);
|
2012-01-23 20:36:51 +00:00
|
|
|
|
}
|