Add ungrouped device BOM CSV export

This commit is contained in:
enesgursoy6110
2026-09-09 22:31:33 +03:00
parent 73f7ea8f50
commit 16dbc5c404
11 changed files with 836 additions and 0 deletions
+31
View File
@@ -21,6 +21,7 @@
#include "QWidgetAnimation/qwidgetanimation.h"
#include "autoNum/ui/autonumberingdockwidget.h"
#include "conductornumexport.h"
#include "devicebomexport.h"
#include "diagramcommands.h"
#include "diagramevent/diagrameventaddimage.h"
#ifdef QET_HAS_QTPDF
@@ -470,6 +471,34 @@ void QETDiagramEditor::setUpActions()
bom.exec();
});
m_device_bom_export = new QAction(QET::Icons::DocumentSpreadsheet,
tr("Exporter la nomenclature des appareils au format CSV"), this);
m_device_bom_export->setObjectName(QStringLiteral("export_device_bom_csv"));
connect(m_device_bom_export, &QAction::triggered, this, [this]() {
auto *view = currentProjectView();
if (!view) return;
QPointer<QETProject> project = view->project();
QString dir = project->currentDir();
if (dir.isEmpty()) dir = QETApp::documentDir();
QFileDialog dialog(
this,
tr("Exporter la nomenclature des appareils au format CSV"),
QDir(dir).filePath(QStringLiteral("bom.csv")),
tr("Fichiers CSV (*.csv)"));
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDefaultSuffix(QStringLiteral("csv"));
if (dialog.exec() != QDialog::Accepted || !project) return;
const QString path = dialog.selectedFiles().value(0);
if (path.isEmpty()) return;
QString error;
if (!DeviceBomExport::writeCsv(*project, path, &error)) {
QMessageBox::critical(this, tr("Exporter la nomenclature"),
tr("Impossible d'enregistrer la nomenclature dans %1.\n%2").arg(path, error));
} else {
statusBar()->showMessage(tr("Nomenclature exportée dans %1").arg(path), 5000);
}
});
//Add a nomenclature item
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
connect(m_add_nomenclature, &QAction::triggered, this, [=]() {
@@ -948,6 +977,7 @@ void QETDiagramEditor::setUpMenu()
menu_project -> addAction(m_add_summary);
menu_project -> addAction(m_add_nomenclature);
menu_project -> addAction(m_csv_export);
menu_project -> addAction(m_device_bom_export);
menu_project -> addAction(m_project_export_conductor_num);
menu_project -> addAction(m_terminal_strip_dialog);
menu_project -> addAction(m_project_terminalBloc);
@@ -1799,6 +1829,7 @@ void QETDiagramEditor::slot_updateActions()
m_add_summary -> setEnabled(editable_project);
m_add_nomenclature -> setEnabled(editable_project);
m_csv_export -> setEnabled(editable_project);
m_device_bom_export -> setEnabled(opened_project);
m_project_export_conductor_num-> setEnabled(opened_project);
m_terminal_strip_dialog -> setEnabled(editable_project);
m_project_export_wiring_list -> setEnabled(opened_project);