diff --git a/sources/conductornumexport.cpp b/sources/conductornumexport.cpp
new file mode 100644
index 000000000..970c1448f
--- /dev/null
+++ b/sources/conductornumexport.cpp
@@ -0,0 +1,133 @@
+/*
+ Copyright 2006-2019 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#include "conductornumexport.h"
+#include "diagram.h"
+#include "diagramcontent.h"
+#include "conductor.h"
+#include "terminal.h"
+#include "element.h"
+#include "conductortextitem.h"
+
+#include
+
+/**
+ * @brief ConductorNumExport::ConductorNumExport
+ * @param project : the project to export the conductors num
+ * @param parent : parent widget
+ */
+ConductorNumExport::ConductorNumExport(QETProject *project, QWidget *parent) :
+ m_project(project),
+ m_parent_widget(parent)
+{
+ fillHash();
+}
+
+/**
+ * @brief ConductorNumExport::toCsv
+ * Export the num of conductors into a csv file.
+ * @return true if suceesfully exported.
+ */
+bool ConductorNumExport::toCsv()
+{
+ QString name = QObject::tr("numero_de_fileries_") + m_project->title();
+ if(!name.endsWith(".csv")) {
+ name += ".csv";
+ }
+
+ QString filename = QFileDialog::getSaveFileName(m_parent_widget, QObject::tr("Enregister sous... "), name, QObject::tr("Fichiers csv (*.csv)"));
+ QFile file(filename);
+ if(!filename.isEmpty())
+ {
+ if(QFile::exists(filename))
+ {
+ // if file already exist -> delete it
+ if(!QFile::remove(filename))
+ {
+ QMessageBox::critical(m_parent_widget, QObject::tr("Erreur"),
+ QObject::tr("Impossible de remplacer le fichier!\n\n")+
+ "Destination : "+filename+"\n");
+ return false;
+ }
+ }
+ if (file.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ QTextStream stream(&file);
+ stream << wiresNum() << endl;
+ }
+ else {
+ return false;
+ }
+ }
+ else {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief ConductorNumExport::wiresNum
+ * @return the wire num formated in csv
+ */
+QString ConductorNumExport::wiresNum() const
+{
+ QString csv;
+
+ QStringList list = m_hash.keys();
+ list.sort();
+ for (QString key : list)
+ {
+ for (int i=0; idiagrams())
+ {
+ DiagramContent dc(d, false);
+ for (Conductor *c : dc.conductors())
+ {
+ QString num = c->textItem()->toPlainText();
+ if (num.isEmpty() || num.contains(rx)) {
+ continue;
+ }
+
+ //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.
+ if(!(c->terminal1->parentElement()->linkType() & Element::AllReport))
+ {
+ int value = m_hash.value(num, 0);
+ ++value;
+ m_hash.insert(num, value);
+ }
+ if(!(c->terminal2->parentElement()->linkType() & Element::AllReport))
+ {
+ int value = m_hash.value(num, 0);
+ ++value;
+ m_hash.insert(num, value);
+ }
+ }
+ }
+}
diff --git a/sources/conductornumexport.h b/sources/conductornumexport.h
new file mode 100644
index 000000000..7f14875fa
--- /dev/null
+++ b/sources/conductornumexport.h
@@ -0,0 +1,46 @@
+/*
+ Copyright 2006-2019 The QElectroTech Team
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see .
+*/
+#ifndef ConductorNumExport_H
+#define ConductorNumExport_H
+
+#include
+
+class QETProject;
+class QWidget;
+
+/**
+ * @brief The ConductorNumExport class
+ * A class to export the num of conductors into a csv file.
+ */
+class ConductorNumExport
+{
+ public:
+ ConductorNumExport(QETProject *project, QWidget *parent = nullptr);
+ bool toCsv();
+ QString wiresNum() const;
+
+ private:
+ void fillHash();
+
+ private:
+ QETProject *m_project = nullptr;
+ QHash m_hash;
+ QWidget *m_parent_widget = nullptr;
+};
+
+#endif // ConductorNumExport_H
diff --git a/sources/diagramcontent.cpp b/sources/diagramcontent.cpp
index fbb876eb4..474bd7691 100644
--- a/sources/diagramcontent.cpp
+++ b/sources/diagramcontent.cpp
@@ -88,23 +88,26 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
//For each selected element, we determine if conductors must be moved or updated.
for(Element *elmt : m_elements)
{
- for(Terminal *terminal : elmt->terminals())
- {
- for(Conductor *conductor : terminal->conductors())
- {
- Terminal *other_terminal;
- if (conductor->terminal1 == terminal)
- other_terminal = conductor->terminal2;
- else
- other_terminal = conductor->terminal1;
+ if (elmt->isSelected())
+ {
+ for(Terminal *terminal : elmt->terminals())
+ {
+ for(Conductor *conductor : terminal->conductors())
+ {
+ Terminal *other_terminal;
+ if (conductor->terminal1 == terminal)
+ other_terminal = conductor->terminal2;
+ else
+ other_terminal = conductor->terminal1;
- //If the two elements of conductor are movable
- if (m_elements.contains(other_terminal -> parentElement()) && !m_conductors_to_move.contains(conductor))
- m_conductors_to_move << conductor;
- else if (!m_conductors_to_update.contains(conductor))
- m_conductors_to_update << conductor;
- }
- }
+ //If the two elements of conductor are movable
+ if (m_elements.contains(other_terminal -> parentElement()) && !m_conductors_to_move.contains(conductor))
+ m_conductors_to_move << conductor;
+ else if (!m_conductors_to_update.contains(conductor))
+ m_conductors_to_update << conductor;
+ }
+ }
+ }
}
}
diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp
index 1637f404e..1e9b39e8d 100644
--- a/sources/qetdiagrameditor.cpp
+++ b/sources/qetdiagrameditor.cpp
@@ -48,6 +48,7 @@
#include "diagramcommands.h"
#include "dialogwaiting.h"
#include "addelementtextcommand.h"
+#include "conductornumexport.h"
#include
#include
@@ -402,6 +403,17 @@ void QETDiagramEditor::setUpActions()
//Lauch the plugin of terminal generator
m_project_terminalBloc = new QAction(QET::Icons::TerminalStrip, tr("Lancer le plugin de création de borniers"), this);
connect(m_project_terminalBloc, &QAction::triggered, this, &QETDiagramEditor::generateTerminalBlock);
+
+ //Export conductor num to csv
+ m_project_export_conductor_num = new QAction(QET::Icons::DocumentSpreadsheet, tr("Exporter la liste des noms de conducteurs"), this);
+ connect(m_project_export_conductor_num, &QAction::triggered, [this]() {
+ QETProject *project = this->currentProject();
+ if (project)
+ {
+ ConductorNumExport wne(project, this);
+ wne.toCsv();
+ }
+ });
//MDI view style
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
@@ -744,6 +756,7 @@ void QETDiagramEditor::setUpMenu() {
menu_project -> addSeparator();
menu_project -> addAction(m_project_folio_list);
menu_project -> addAction(m_project_nomenclature);
+ menu_project -> addAction(m_project_export_conductor_num);
menu_project -> addAction(m_project_terminalBloc);
main_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils principale"));
@@ -1418,7 +1431,8 @@ void QETDiagramEditor::slot_updateActions()
m_close_file -> setEnabled(opened_project);
m_save_file -> setEnabled(opened_project);
m_save_file_as -> setEnabled(opened_project);
- m_project_edit_properties -> setEnabled(opened_project);
+ m_project_edit_properties->setEnabled(opened_project);
+ m_project_export_conductor_num->setEnabled(opened_project);
//prj_terminalBloc -> setEnabled(opened_project);
m_rotate_texts -> setEnabled(editable_project);
m_project_add_diagram -> setEnabled(editable_project);
@@ -1429,7 +1443,6 @@ void QETDiagramEditor::slot_updateActions()
m_export_diagram -> setEnabled(opened_diagram);
m_print -> setEnabled(opened_diagram);
m_edit_diagram_properties -> setEnabled(opened_diagram);
- m_project_nomenclature -> setEnabled(editable_project);
m_zoom_actions_group. setEnabled(opened_diagram);
m_select_actions_group. setEnabled(opened_diagram);
m_add_item_actions_group. setEnabled(editable_project);
diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h
index ccba924ba..634438b57 100644
--- a/sources/qetdiagrameditor.h
+++ b/sources/qetdiagrameditor.h
@@ -185,6 +185,7 @@ class QETDiagramEditor : public QETMainWindow
QAction *m_project_folio_list; ///< Sommaire des schemas
QAction *m_project_nomenclature; ///< generate nomenclature
QAction *m_project_terminalBloc; ///< generate terminal block
+ QAction *m_project_export_conductor_num; ///