From 7960697b9e06d4cddc537da539351c489fabe050 Mon Sep 17 00:00:00 2001 From: Claveau Joshua Date: Fri, 21 Aug 2020 14:39:35 +0200 Subject: [PATCH] Remove unused class --- sources/nomenclature.cpp | 200 --------------------------------------- sources/nomenclature.h | 63 ------------ 2 files changed, 263 deletions(-) delete mode 100644 sources/nomenclature.cpp delete mode 100644 sources/nomenclature.h diff --git a/sources/nomenclature.cpp b/sources/nomenclature.cpp deleted file mode 100644 index 183464fcf..000000000 --- a/sources/nomenclature.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - Copyright 2006-2020 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 - -#include "nomenclature.h" -#include "elementprovider.h" -#include "assignvariables.h" - -#define PR(x) qDebug() << #x " = " << x; - -/** - @brief nomenclature::nomenclature - Constructor - @param project : an project (QETProject) of QET file - @param parent -*/ -nomenclature::nomenclature(QETProject *project, QWidget *parent): - m_project(project) -{ - m_parent = parent; - //get list of schema present in project - m_list_diagram = m_project -> diagrams(); -} - -/** - Destructor -*/ -nomenclature::~nomenclature() { -} - -/** - Save to csv file - @param true if success -*/ -bool nomenclature::saveToCSVFile() -{ - // SAVE IN FILE - QString name = QObject::tr("nomenclature_") + QString(m_project -> title() + ".csv"); - if (!name.endsWith(".csv")) { - name += ".csv"; - } - QString filename = QFileDialog::getSaveFileName(this->m_parent, 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(this->m_parent, 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); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove - stream << getNomenclature() << endl; -#else -#pragma message("@TODO remove code for QT 5.15 or later") - stream << getNomenclature() << &Qt::endl(stream); -#endif - } - else return false; - } - else return false; - - return true; -} - -/** - @brief nomenclature::getNomenclature - Create and formated a nomenclature to csv file. - @return The QString of nomenclature -*/ -QString nomenclature::getNomenclature() -{ - //Process... - QString data = QObject::tr("NOMENCLATURE : ") + m_project -> title() + "\n\n"; - data += QObject::tr("A001") +";" //:Don't translate this text! //ID for folio position in project - ""+ QObject::tr("B001") +";" //:Don't translate this text! //ID for folio title - ""+ QObject::tr("C001") +";" //:Don't translate this text! //ID for folio number - ""+ QObject::tr("D001") +";" //:Don't translate this text! //ID for qet designation - ""+ QObject::tr("E001") +";" //:Don't translate this text! //ID for position of element on the folio - ""+ QObject::tr("F001") +";" //:Don't translate this text! //ID for label of element - ""+ QObject::tr("F002") +";" //:Don't translate this text! //ID for label formula of element - ""+ QObject::tr("G001") +";" //:Don't translate this text! //ID for order number - ""+ QObject::tr("H001") +";" //:Don't translate this text! //ID for article description - ""+ QObject::tr("H002") +";" //:Don't translate this text! //ID for plant - ""+ QObject::tr("I001") +";" //:Don't translate this text! //ID for comment - ""+ QObject::tr("J001") +";" //:Don't translate this text! //ID for manufacturer - ""+ QObject::tr("K001") +";" //:Don't translate this text! //ID for article number - ""+ QObject::tr("L001") +";" //:Don't translate this text! //ID for quantity - ""+ QObject::tr("L002") +";" //:Don't translate this text! //ID for unity - ""+ QObject::tr("L003") +";" //:Don't translate this text! //ID for supplier - ""+ QObject::tr("M001") +";" //:Don't translate this text! //ID for auxiliary field 1 - ""+ QObject::tr("M002") +";" //:Don't translate this text! //ID for auxiliary field 2 - ""+ QObject::tr("N001")+";" //:Don't translate this text! //ID for internal number - ""+ QObject::tr("O001")+";" //:Don't translate this text! //ID for location - ""+ QObject::tr("P001") +"\n"; //:Don't translate this text! //ID for function - data += QObject::tr("Position du folio") +";" - ""+ QObject::tr("Titre de folio") +";" - ""+ QObject::tr("Numéro de folio") +";" - ""+ QObject::tr("Désignation qet") +";" - ""+ QObject::tr("Position") +";" - ""+ QObject::tr("Label") +";" - ""+ QObject::tr("Formule du label") +";" - ""+ QObject::tr("Désignation") +";" - ""+ QObject::tr("Description") +";" - ""+ QObject::tr("Installation") +";" - ""+ QObject::tr("Commentaire") +";" - ""+ QObject::tr("Fabricant") +";" - ""+ QObject::tr("Numéro de commande") +";" - ""+ QObject::tr("Fournisseur") +";" - ""+ QObject::tr("Quantité") +";" - ""+ QObject::tr("Unité") +";" - ""+ QObject::tr("Bloc auxiliaire 1") +";" - ""+ QObject::tr("Bloc auxiliaire 2") +";" - ""+ QObject::tr("Numéro interne") +";" - ""+ QObject::tr("Localisation") +";" - ""+ QObject::tr("Fonction") +"\n"; - - - if(m_list_diagram.isEmpty()) return data; - - foreach (Diagram *d, m_list_diagram) { - //Get only simple, master and unlinked slave element. - ElementProvider ep(d); - QSettings settings; - QList list_elements; - - if (settings.value("nomenclature/terminal-exportlist", true).toBool()){ - list_elements << ep.find(Element::Simple | Element::Master | Element::Terminale); - - }else{ - - list_elements << ep.find(Element::Simple | Element::Master); - - } - - list_elements << ep.freeElement(Element::Slave); - - foreach (Element *elmt, list_elements) { - data += getElementInfo(elmt); - } - } - - return data; -} - -/** - @brief nomenclature::getElementInfo - @param elmt : the element to getinfo - @return : QString with information about element formated to csv file -*/ -QString nomenclature::getElementInfo(Element *elmt) { - QString info; - - Diagram *diagram = elmt -> diagram(); - DiagramContext elmt_info = elmt -> elementInformations(); - autonum::sequentialNumbers empty_seq; - - info += QString::number(diagram -> folioIndex()+1) + ";"; - info += diagram -> title() + ";"; - info += autonum::AssignVariables::formulaToLabel(diagram->border_and_titleblock.folio(), empty_seq, diagram) + ";"; - info += elmt -> name() + ";"; - info += elmt-> diagram()-> convertPosition(elmt -> scenePos()).toString() + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["label"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["formula"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["designation"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["description"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["plant"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["comment"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["manufacturer"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["manufacturer_reference"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["supplier"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["quantity"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["unity"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["auxiliary1"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["auxiliary2"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["machine_manufacturer_reference"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["location"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + ";"; - info += autonum::AssignVariables::formulaToLabel(elmt_info["function"].toString(), elmt->rSequenceStruct(), elmt->diagram(), elmt) + "\n"; - - return info; -} diff --git a/sources/nomenclature.h b/sources/nomenclature.h deleted file mode 100644 index 1fccbef2e..000000000 --- a/sources/nomenclature.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2006-2020 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 NOMENCLATURE_H -#define NOMENCLATURE_H - -#include - -#include "qetproject.h" -#include "diagram.h" -#include "qetgraphicsitem/element.h" -#include "diagramcontent.h" -#include "diagramposition.h" - -class QETProject; -class Diagram; -class Element; - -/** - This class represents a nomenclature... -*/ -class nomenclature -{ - private: - QETProject *m_project; - QList m_list_diagram; - QWidget *m_parent; - - // constructors, destructor - public: - nomenclature(QETProject *project, QWidget *parent =nullptr); - virtual ~nomenclature(); - - // attributes - public: - - // methods - public: - bool saveToCSVFile(); - - - private: - QString getNomenclature (); - QString getElementInfo (Element *elmt); - -}; - -#endif -