Fix indentation code

This commit is contained in:
Laurent Trinques
2020-07-15 23:00:21 +02:00
parent b9ce532db7
commit 68116f4664
6 changed files with 803 additions and 803 deletions

View File

@@ -26,8 +26,8 @@
/******************************************************/ /******************************************************/
ECHStrategy::ECHStrategy(ElementsLocation &source, ElementsLocation &destination) : ECHStrategy::ECHStrategy(ElementsLocation &source, ElementsLocation &destination) :
m_source(source), m_source(source),
m_destination (destination) m_destination (destination)
{} {}
ECHStrategy::~ECHStrategy() {} ECHStrategy::~ECHStrategy() {}
@@ -35,12 +35,12 @@ ECHStrategy::~ECHStrategy() {}
/******************************************************/ /******************************************************/
ECHSFileToFile::ECHSFileToFile(ElementsLocation &source, ElementsLocation &destination) : ECHSFileToFile::ECHSFileToFile(ElementsLocation &source, ElementsLocation &destination) :
ECHStrategy(source, destination) ECHStrategy(source, destination)
{} {}
ElementsLocation ECHSFileToFile::copy() ElementsLocation ECHSFileToFile::copy()
{ {
//Check if the destination already have an item with the same name of the item to copy //Check if the destination already have an item with the same name of the item to copy
ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName()); ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName());
QString rename; QString rename;
if (location.exist()) if (location.exist())
@@ -69,32 +69,32 @@ ElementsLocation ECHSFileToFile::copy()
else else
return ElementsLocation(); return ElementsLocation();
} }
if (m_source.isElement()) if (m_source.isElement())
return copyElement(m_source, m_destination, rename); return copyElement(m_source, m_destination, rename);
else else
return copyDirectory(m_source, m_destination, rename); return copyDirectory(m_source, m_destination, rename);
} }
ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename) ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{ {
QDir source_dir(source.fileSystemPath()); QDir source_dir(source.fileSystemPath());
QDir destination_dir(destination.fileSystemPath()); QDir destination_dir(destination.fileSystemPath());
if (!source_dir.exists() || !destination_dir.exists()) return ElementsLocation(); if (!source_dir.exists() || !destination_dir.exists()) return ElementsLocation();
QString new_dir_name = rename.isEmpty() ? source_dir.dirName() : rename; QString new_dir_name = rename.isEmpty() ? source_dir.dirName() : rename;
//Create a new dir //Create a new dir
if (destination_dir.mkdir(new_dir_name)) if (destination_dir.mkdir(new_dir_name))
{ {
//The new created directory //The new created directory
QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name); QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name);
//Copy the qet_directory file //Copy the qet_directory file
QFile::copy(source_dir.canonicalPath() + "/qet_directory", created_dir.canonicalPath() + "/qet_directory"); QFile::copy(source_dir.canonicalPath() + "/qet_directory", created_dir.canonicalPath() + "/qet_directory");
//Copy all dirs found in source_dir to destination_dir //Copy all dirs found in source_dir to destination_dir
ElementsLocation created_location(created_dir.canonicalPath()); ElementsLocation created_location(created_dir.canonicalPath());
//Used this bool when user drop a folder into itself to avoid infinite recursive creation of the dropped dir //Used this bool when user drop a folder into itself to avoid infinite recursive creation of the dropped dir
bool copy_itself = false; bool copy_itself = false;
@@ -116,30 +116,30 @@ ElementsLocation ECHSFileToFile::copyDirectory(ElementsLocation &source, Element
copyDirectory(sub_source, created_location); copyDirectory(sub_source, created_location);
} }
//Copy all elements found in source_dir to destination_dir //Copy all elements found in source_dir to destination_dir
source_dir.setNameFilters(QStringList() << "*.elmt"); source_dir.setNameFilters(QStringList() << "*.elmt");
foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name)) foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
{ {
ElementsLocation sub_source(source.fileSystemPath() + "/" + str); ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
copyElement(sub_source, created_location); copyElement(sub_source, created_location);
} }
return created_location; return created_location;
} }
return ElementsLocation(); return ElementsLocation();
} }
ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename) ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{ {
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename; QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name); bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name);
if (rb) if (rb)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//On windows when user drag and drop an element from the common elements collection //On windows when user drag and drop an element from the common elements collection
//to the custom elements collection, the element file stay in read only mode, and so //to the custom elements collection, the element file stay in read only mode, and so
//user can't save the element //user can't save the element
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
qt_ntfs_permission_lookup++; qt_ntfs_permission_lookup++;
QFile file(destination.fileSystemPath() + "/" + new_elmt_name); QFile file(destination.fileSystemPath() + "/" + new_elmt_name);
@@ -153,7 +153,7 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
#endif #endif
return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name); return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name);
} }
else else
return ElementsLocation(); return ElementsLocation();
} }
@@ -165,7 +165,7 @@ ECHSXmlToFile::ECHSXmlToFile(ElementsLocation &source, ElementsLocation &destina
ElementsLocation ECHSXmlToFile::copy() ElementsLocation ECHSXmlToFile::copy()
{ {
//Check if the destination already have an item with the same name of the item to copy //Check if the destination already have an item with the same name of the item to copy
ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName()); ElementsLocation location(m_destination.fileSystemPath() + "/" + m_source.fileName());
QString rename; QString rename;
if (location.exist()) if (location.exist())
@@ -194,7 +194,7 @@ ElementsLocation ECHSXmlToFile::copy()
else else
return ElementsLocation(); return ElementsLocation();
} }
if (m_source.isElement()) if (m_source.isElement())
return copyElement(m_source, m_destination, rename); return copyElement(m_source, m_destination, rename);
else else
@@ -204,61 +204,61 @@ ElementsLocation ECHSXmlToFile::copy()
ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename) ElementsLocation ECHSXmlToFile::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{ {
QDir destination_dir(destination.fileSystemPath()); QDir destination_dir(destination.fileSystemPath());
if (!(destination_dir.exists() && source.exist())) return ElementsLocation(); if (!(destination_dir.exists() && source.exist())) return ElementsLocation();
QString new_dir_name = rename.isEmpty() ? source.fileName() : rename; QString new_dir_name = rename.isEmpty() ? source.fileName() : rename;
//Create new dir //Create new dir
if (destination_dir.mkdir(new_dir_name)) if (destination_dir.mkdir(new_dir_name))
{ {
QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name); QDir created_dir(destination_dir.canonicalPath() + "/" + new_dir_name);
ElementsLocation created_location(created_dir.canonicalPath()); ElementsLocation created_location(created_dir.canonicalPath());
//Create the qet-directory file //Create the qet-directory file
QDomDocument document; QDomDocument document;
QDomElement root = document.createElement("qet-directory"); QDomElement root = document.createElement("qet-directory");
document.appendChild(root); document.appendChild(root);
root.appendChild(source.nameList().toXml(document)); root.appendChild(source.nameList().toXml(document));
QString filepath = created_dir.canonicalPath() + "/qet_directory"; QString filepath = created_dir.canonicalPath() + "/qet_directory";
QET::writeXmlFile(document, filepath); QET::writeXmlFile(document, filepath);
//Create all directory found in source to created_dir //Create all directory found in source to created_dir
XmlElementCollection *project_collection = source.projectCollection(); XmlElementCollection *project_collection = source.projectCollection();
QStringList directories_names = project_collection->directoriesNames( project_collection->directory(source.collectionPath(false)) ); QStringList directories_names = project_collection->directoriesNames( project_collection->directory(source.collectionPath(false)) );
foreach(QString name, directories_names) foreach(QString name, directories_names)
{ {
ElementsLocation sub_source_dir(source.projectCollectionPath() + "/" + name); ElementsLocation sub_source_dir(source.projectCollectionPath() + "/" + name);
copyDirectory(sub_source_dir, created_location); copyDirectory(sub_source_dir, created_location);
} }
//Create all elements found in source to destination //Create all elements found in source to destination
QStringList elements_names = project_collection->elementsNames( project_collection->directory(source.collectionPath(false))) ; QStringList elements_names = project_collection->elementsNames( project_collection->directory(source.collectionPath(false))) ;
foreach (QString name, elements_names) foreach (QString name, elements_names)
{ {
ElementsLocation source_element(source.projectCollectionPath() + "/" + name); ElementsLocation source_element(source.projectCollectionPath() + "/" + name);
copyElement(source_element, created_location); copyElement(source_element, created_location);
} }
return created_location; return created_location;
} }
return ElementsLocation(); return ElementsLocation();
} }
ElementsLocation ECHSXmlToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename) ElementsLocation ECHSXmlToFile::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
{ {
if (!(destination.exist() && source.exist())) return ElementsLocation(); if (!(destination.exist() && source.exist())) return ElementsLocation();
QString new_element_name = rename.isEmpty() ? source.fileName() : rename; QString new_element_name = rename.isEmpty() ? source.fileName() : rename;
//Get the xml descrption of the element //Get the xml descrption of the element
QDomDocument document; QDomDocument document;
document.appendChild(document.importNode(source.xml(), true)); document.appendChild(document.importNode(source.xml(), true));
//Create the .elmt file //Create the .elmt file
QString filepath = destination.fileSystemPath() + "/" + new_element_name; QString filepath = destination.fileSystemPath() + "/" + new_element_name;
if (QET::writeXmlFile(document, filepath)) if (QET::writeXmlFile(document, filepath))
return ElementsLocation(filepath); return ElementsLocation(filepath);
@@ -275,10 +275,10 @@ ECHSToXml::ECHSToXml(ElementsLocation &source, ElementsLocation &destination) :
ElementsLocation ECHSToXml::copy() ElementsLocation ECHSToXml::copy()
{ {
if (!(m_source.exist() && m_destination.isDirectory() && m_destination.isProject())) return ElementsLocation(); if (!(m_source.exist() && m_destination.isDirectory() && m_destination.isProject())) return ElementsLocation();
//Check if the destination already have an item with the same name of the item to copy //Check if the destination already have an item with the same name of the item to copy
ElementsLocation location(m_destination.projectCollectionPath() + "/" + m_source.fileName()); ElementsLocation location(m_destination.projectCollectionPath() + "/" + m_source.fileName());
QString rename; QString rename;
if (location.exist()) if (location.exist())
{ {
@@ -291,7 +291,7 @@ ElementsLocation ECHSToXml::copy()
else else
return ElementsLocation(); return ElementsLocation();
} }
return m_destination.projectCollection()->copy(m_source, m_destination, rename); return m_destination.projectCollection()->copy(m_source, m_destination, rename);
} }
@@ -305,7 +305,7 @@ ElementCollectionHandler::ElementCollectionHandler() {}
ElementCollectionHandler::~ElementCollectionHandler() ElementCollectionHandler::~ElementCollectionHandler()
{ {
if (m_strategy) delete m_strategy; if (m_strategy) delete m_strategy;
} }
/** /**
@@ -320,11 +320,11 @@ ElementCollectionHandler::~ElementCollectionHandler()
ElementsLocation ElementCollectionHandler::copy(ElementsLocation &source, ElementsLocation &destination) ElementsLocation ElementCollectionHandler::copy(ElementsLocation &source, ElementsLocation &destination)
{ {
if (!source.exist() || !destination.exist() || destination.isElement()) return ElementsLocation(); if (!source.exist() || !destination.exist() || destination.isElement()) return ElementsLocation();
if (source.isFileSystem() && destination.isFileSystem()) m_strategy = new ECHSFileToFile(source, destination); if (source.isFileSystem() && destination.isFileSystem()) m_strategy = new ECHSFileToFile(source, destination);
if (source.isProject() && destination.isFileSystem()) m_strategy = new ECHSXmlToFile(source, destination); if (source.isProject() && destination.isFileSystem()) m_strategy = new ECHSXmlToFile(source, destination);
else if (destination.isProject()) m_strategy = new ECHSToXml(source, destination); else if (destination.isProject()) m_strategy = new ECHSToXml(source, destination);
if (m_strategy) if (m_strategy)
return m_strategy->copy(); return m_strategy->copy();
else else
@@ -342,31 +342,31 @@ ElementsLocation ElementCollectionHandler::copy(ElementsLocation &source, Elemen
*/ */
ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, const QString &name, const NamesList &name_list) ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, const QString &name, const NamesList &name_list)
{ {
//Parent must be a directorie and writable //Parent must be a directorie and writable
if (!(parent.isDirectory() && parent.isWritable() && parent.exist())) { if (!(parent.isDirectory() && parent.isWritable() && parent.exist())) {
qDebug() << "ElementCollectionHandler::createDir : the prerequisites are not valid. " << parent; qDebug() << "ElementCollectionHandler::createDir : the prerequisites are not valid. " << parent;
return ElementsLocation(); return ElementsLocation();
} }
//Directorie to create must not already exist //Directorie to create must not already exist
ElementsLocation created_dir = parent; ElementsLocation created_dir = parent;
created_dir.addToPath(name); created_dir.addToPath(name);
if (created_dir.exist()) { if (created_dir.exist()) {
return ElementsLocation(); return ElementsLocation();
} }
//Location is a file system //Location is a file system
if (parent.isFileSystem()) { if (parent.isFileSystem()) {
QDir parent_dir(parent.fileSystemPath()); QDir parent_dir(parent.fileSystemPath());
if (parent_dir.mkdir(name)) { if (parent_dir.mkdir(name)) {
//Create the qet-directory file //Create the qet-directory file
QDomDocument document; QDomDocument document;
QDomElement root = document.createElement("qet-directory"); QDomElement root = document.createElement("qet-directory");
document.appendChild(root); document.appendChild(root);
root.appendChild(name_list.toXml(document)); root.appendChild(name_list.toXml(document));
QString filepath = created_dir.fileSystemPath() + "/qet_directory"; QString filepath = created_dir.fileSystemPath() + "/qet_directory";
if (!QET::writeXmlFile(document, filepath)) { if (!QET::writeXmlFile(document, filepath)) {
qDebug() << "ElementCollectionHandler::createDir : write qet-directory file failed"; qDebug() << "ElementCollectionHandler::createDir : write qet-directory file failed";
@@ -388,7 +388,7 @@ ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, c
return ElementsLocation(); return ElementsLocation();
} }
} }
return ElementsLocation(); return ElementsLocation();
} }
@@ -403,35 +403,35 @@ ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, c
bool ElementCollectionHandler::importFromProject(QETProject *project, ElementsLocation &location) bool ElementCollectionHandler::importFromProject(QETProject *project, ElementsLocation &location)
{ {
if (!(location.isElement() && location.exist() && location.isProject())) return false; if (!(location.isElement() && location.exist() && location.isProject())) return false;
ElementsLocation destination(location.collectionPath(false), project); ElementsLocation destination(location.collectionPath(false), project);
if (destination.exist()) return true; if (destination.exist()) return true;
QList <QString> names; QList <QString> names;
//Get the parent of location and find if exist in embedded collection of project //Get the parent of location and find if exist in embedded collection of project
ElementsLocation source = location.parent(); ElementsLocation source = location.parent();
names.append(location.fileName()); names.append(location.fileName());
destination = ElementsLocation(source.collectionPath(), project); destination = ElementsLocation(source.collectionPath(), project);
//Go back until to find an existing directory in destination //Go back until to find an existing directory in destination
while (!destination.exist()) { while (!destination.exist()) {
names.append(source.fileName()); names.append(source.fileName());
source = source.parent(); source = source.parent();
destination = ElementsLocation(source.collectionPath(), project); destination = ElementsLocation(source.collectionPath(), project);
} }
XmlElementCollection *collection = project->embeddedElementCollection(); XmlElementCollection *collection = project->embeddedElementCollection();
while (!names.isEmpty()) { while (!names.isEmpty()) {
source.addToPath(names.takeLast()); source.addToPath(names.takeLast());
destination = collection->copy(source, destination, QString(), false); destination = collection->copy(source, destination, QString(), false);
if (!destination.exist()) if (!destination.exist())
return false; return false;
} }
return true; return true;
} }
@@ -447,23 +447,23 @@ bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesL
if ( !(location.exist() && location.isWritable()) ) { if ( !(location.exist() && location.isWritable()) ) {
return false; return false;
} }
if (location.isFileSystem()) { if (location.isFileSystem()) {
if (location.isDirectory()) { if (location.isDirectory()) {
QDomDocument document; QDomDocument document;
QDomElement root = document.createElement("qet-directory"); QDomElement root = document.createElement("qet-directory");
document.appendChild(root); document.appendChild(root);
root.appendChild(name_list.toXml(document)); root.appendChild(name_list.toXml(document));
QString filepath = location.fileSystemPath() + "/qet_directory"; QString filepath = location.fileSystemPath() + "/qet_directory";
if (!QET::writeXmlFile(document, filepath)) { if (!QET::writeXmlFile(document, filepath)) {
qDebug() << "ElementCollectionHandler::setNames : write qet-directory file failed"; qDebug() << "ElementCollectionHandler::setNames : write qet-directory file failed";
return false; return false;
} }
return true; return true;
} }
if (location.isElement()) { if (location.isElement()) {
QDomDocument document; QDomDocument document;
document.appendChild(document.importNode(location.xml(), true)); document.appendChild(document.importNode(location.xml(), true));
@@ -471,19 +471,19 @@ bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesL
qDebug() << "ElementCollectionHandler::setNames : failed to load xml document from file"; qDebug() << "ElementCollectionHandler::setNames : failed to load xml document from file";
return false; return false;
} }
QDomElement document_element = document.documentElement(); QDomElement document_element = document.documentElement();
document_element.replaceChild(name_list.toXml(document), document_element.firstChildElement("names")); document_element.replaceChild(name_list.toXml(document), document_element.firstChildElement("names"));
return true; return true;
} }
} }
if (location.isProject()) { if (location.isProject()) {
QDomElement element = location.xml(); QDomElement element = location.xml();
QDomDocument document = element.ownerDocument(); QDomDocument document = element.ownerDocument();
element.replaceChild(name_list.toXml(document), element.firstChildElement("names")); element.replaceChild(name_list.toXml(document), element.firstChildElement("names"));
return true; return true;
} }
return false; return false;
} }

View File

@@ -31,10 +31,10 @@
* @param parent : parent widget * @param parent : parent widget
*/ */
ConductorNumExport::ConductorNumExport(QETProject *project, QWidget *parent) : ConductorNumExport::ConductorNumExport(QETProject *project, QWidget *parent) :
m_project(project), m_project(project),
m_parent_widget(parent) m_parent_widget(parent)
{ {
fillHash(); fillHash();
} }
/** /**
@@ -44,44 +44,44 @@ ConductorNumExport::ConductorNumExport(QETProject *project, QWidget *parent) :
*/ */
bool ConductorNumExport::toCsv() bool ConductorNumExport::toCsv()
{ {
QString name = QObject::tr("numero_de_fileries_") + m_project->title() + ".csv"; QString name = QObject::tr("numero_de_fileries_") + m_project->title() + ".csv";
// if(!name.endsWith(".csv")) { // if(!name.endsWith(".csv")) {
// name += ".csv"; // name += ".csv";
// } // }
QString filename = QFileDialog::getSaveFileName(m_parent_widget, QObject::tr("Enregister sous... "), name, QObject::tr("Fichiers csv (*.csv)")); QString filename = QFileDialog::getSaveFileName(m_parent_widget, QObject::tr("Enregister sous... "), name, QObject::tr("Fichiers csv (*.csv)"));
QFile file(filename); QFile file(filename);
if(!filename.isEmpty()) if(!filename.isEmpty())
{ {
if(QFile::exists(filename)) if(QFile::exists(filename))
{ {
// if file already exist -> delete it // if file already exist -> delete it
if(!QFile::remove(filename)) if(!QFile::remove(filename))
{ {
QMessageBox::critical(m_parent_widget, QObject::tr("Erreur"), QMessageBox::critical(m_parent_widget, QObject::tr("Erreur"),
QObject::tr("Impossible de remplacer le fichier!\n\n")+ QObject::tr("Impossible de remplacer le fichier!\n\n")+
"Destination : "+filename+"\n"); "Destination : "+filename+"\n");
return false; return false;
} }
} }
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{ {
QTextStream stream(&file); QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove
stream << wiresNum() << endl; stream << wiresNum() << endl;
#else #else
stream << wiresNum() << &Qt::endl(stream); stream << wiresNum() << &Qt::endl(stream);
#endif #endif
} }
else { else {
return false; return false;
} }
} }
else { else {
return false; return false;
} }
return true; return true;
} }
/** /**
@@ -90,18 +90,18 @@ bool ConductorNumExport::toCsv()
*/ */
QString ConductorNumExport::wiresNum() const QString ConductorNumExport::wiresNum() const
{ {
QString csv; QString csv;
QStringList list = m_hash.keys(); QStringList list = m_hash.keys();
list.sort(); list.sort();
for (QString key : list) for (QString key : list)
{ {
for (int i=0; i<m_hash.value(key) ; ++i) { for (int i=0; i<m_hash.value(key) ; ++i) {
csv.append(key + "\n"); csv.append(key + "\n");
} }
} }
return csv; return csv;
} }
/** /**
@@ -110,32 +110,32 @@ QString ConductorNumExport::wiresNum() const
*/ */
void ConductorNumExport::fillHash() void ConductorNumExport::fillHash()
{ {
//We used this rx to avoid insert num composed only withe white space. //We used this rx to avoid insert num composed only withe white space.
QRegularExpression rx("^ *$"); QRegularExpression rx("^ *$");
for (Diagram *d : m_project->diagrams()) for (Diagram *d : m_project->diagrams())
{ {
DiagramContent dc(d, false); DiagramContent dc(d, false);
for (Conductor *c : dc.conductors()) for (Conductor *c : dc.conductors())
{ {
QString num = c->textItem()->toPlainText(); QString num = c->textItem()->toPlainText();
if (num.isEmpty() || num.contains(rx)) { if (num.isEmpty() || num.contains(rx)) {
continue; continue;
} }
//We must to define if the connected terminal is a folio report, if it is the case //We must to define if the connected terminal is a folio report, if it is the case
//we don't add the num to the hash because the terminal doesn't represent a real terminal. //we don't add the num to the hash because the terminal doesn't represent a real terminal.
if(!(c->terminal1->parentElement()->linkType() & Element::AllReport)) if(!(c->terminal1->parentElement()->linkType() & Element::AllReport))
{ {
int value = m_hash.value(num, 0); int value = m_hash.value(num, 0);
++value; ++value;
m_hash.insert(num, value); m_hash.insert(num, value);
} }
if(!(c->terminal2->parentElement()->linkType() & Element::AllReport)) if(!(c->terminal2->parentElement()->linkType() & Element::AllReport))
{ {
int value = m_hash.value(num, 0); int value = m_hash.value(num, 0);
++value; ++value;
m_hash.insert(num, value); m_hash.insert(num, value);
} }
} }
} }
} }

View File

@@ -29,18 +29,18 @@ class QWidget;
*/ */
class ConductorNumExport class ConductorNumExport
{ {
public: public:
ConductorNumExport(QETProject *project, QWidget *parent = nullptr); ConductorNumExport(QETProject *project, QWidget *parent = nullptr);
bool toCsv(); bool toCsv();
QString wiresNum() const; QString wiresNum() const;
private: private:
void fillHash(); void fillHash();
private: private:
QETProject *m_project = nullptr; QETProject *m_project = nullptr;
QHash <QString, int> m_hash; QHash <QString, int> m_hash;
QWidget *m_parent_widget = nullptr; QWidget *m_parent_widget = nullptr;
}; };
#endif // ConductorNumExport_H #endif // ConductorNumExport_H

File diff suppressed because it is too large Load Diff

View File

@@ -56,26 +56,26 @@ DiagramEventAddImage::~DiagramEventAddImage()
*/ */
void DiagramEventAddImage::mousePressEvent(QGraphicsSceneMouseEvent *event) void DiagramEventAddImage::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (m_image && event -> button() == Qt::LeftButton) if (m_image && event -> button() == Qt::LeftButton)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
pos.rx() -= m_image->boundingRect().width()/2; pos.rx() -= m_image->boundingRect().width()/2;
pos.ry() -= m_image->boundingRect().height()/2; pos.ry() -= m_image->boundingRect().height()/2;
m_diagram -> undoStack().push (new AddItemCommand<DiagramImageItem *>(m_image, m_diagram, pos)); m_diagram -> undoStack().push (new AddItemCommand<DiagramImageItem *>(m_image, m_diagram, pos));
for (QGraphicsView *view : m_diagram->views()) { for (QGraphicsView *view : m_diagram->views()) {
view->setContextMenuPolicy((Qt::DefaultContextMenu)); view->setContextMenuPolicy((Qt::DefaultContextMenu));
} }
m_running = false; m_running = false;
emit finish(); emit finish();
event->setAccepted(true); event->setAccepted(true);
} }
else if (m_image && event -> button() == Qt::RightButton) else if (m_image && event -> button() == Qt::RightButton)
{ {
m_image->setRotation(m_image->rotation() + 90); m_image->setRotation(m_image->rotation() + 90);
event->setAccepted(true); event->setAccepted(true);
} }
} }
/** /**
@@ -88,21 +88,21 @@ void DiagramEventAddImage::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (!m_image || event->buttons() != Qt::NoButton) { if (!m_image || event->buttons() != Qt::NoButton) {
return; return;
}; };
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
if (!m_is_added) if (!m_is_added)
{ {
for (QGraphicsView *view : m_diagram->views()) { for (QGraphicsView *view : m_diagram->views()) {
view->setContextMenuPolicy((Qt::NoContextMenu)); view->setContextMenuPolicy((Qt::NoContextMenu));
} }
m_diagram->addItem(m_image); m_diagram->addItem(m_image);
m_is_added = true; m_is_added = true;
} }
m_image->setPos(pos - m_image->boundingRect().center()); m_image->setPos(pos - m_image->boundingRect().center());
event->setAccepted(true); event->setAccepted(true);
} }
/** /**
@@ -125,14 +125,14 @@ void DiagramEventAddImage::wheelEvent(QGraphicsSceneWheelEvent *event)
if (!m_is_added || !m_image || event -> modifiers() != Qt::CTRL) { if (!m_is_added || !m_image || event -> modifiers() != Qt::CTRL) {
return; return;
} }
qreal scaling = m_image->scale(); qreal scaling = m_image->scale();
event->delta() > 1? scaling += 0.01 : scaling -= 0.01; event->delta() > 1? scaling += 0.01 : scaling -= 0.01;
if (scaling>0.01 && scaling <= 2) { if (scaling>0.01 && scaling <= 2) {
m_image->setScale(scaling); m_image->setScale(scaling);
} }
event->setAccepted(true); event->setAccepted(true);
} }
/** /**
@@ -141,8 +141,8 @@ void DiagramEventAddImage::wheelEvent(QGraphicsSceneWheelEvent *event)
*/ */
bool DiagramEventAddImage::isNull() const bool DiagramEventAddImage::isNull() const
{ {
if (!m_image) return true; if (!m_image) return true;
return false; return false;
} }
/** /**
@@ -151,21 +151,21 @@ bool DiagramEventAddImage::isNull() const
*/ */
void DiagramEventAddImage::openDialog() void DiagramEventAddImage::openDialog()
{ {
if (m_diagram -> isReadOnly()) return; if (m_diagram -> isReadOnly()) return;
//Open dialog for select image //Open dialog for select image
QString pathPictures = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); QString pathPictures = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
QString fileName = QFileDialog::getOpenFileName(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Selectionner une image..."), pathPictures, QObject::tr("Image Files (*.png *.jpg *.jpeg *.bmp *.svg)")); QString fileName = QFileDialog::getOpenFileName(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Selectionner une image..."), pathPictures, QObject::tr("Image Files (*.png *.jpg *.jpeg *.bmp *.svg)"));
if (fileName.isEmpty()) return; if (fileName.isEmpty()) return;
QImage image(fileName); QImage image(fileName);
if(image.isNull()) if(image.isNull())
{ {
QMessageBox::critical(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Erreur"), QObject::tr("Impossible de charger l'image.")); QMessageBox::critical(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Erreur"), QObject::tr("Impossible de charger l'image."));
return; return;
} }
m_image = new DiagramImageItem (QPixmap::fromImage(image)); m_image = new DiagramImageItem (QPixmap::fromImage(image));
m_running = true; m_running = true;
} }

View File

@@ -1525,7 +1525,7 @@ void Element::setUpFormula(bool code_letter)
if(!m_freeze_label && !formula.isEmpty()) if(!m_freeze_label && !formula.isEmpty())
{ {
DiagramContext dc = m_element_informations; DiagramContext dc = m_element_informations;
m_element_informations.addValue("label", actualLabel()); m_element_informations.addValue("label", actualLabel());
emit elementInfoChange(dc, m_element_informations); emit elementInfoChange(dc, m_element_informations);
} }
} }