mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Nomenclature, some improvement
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3348 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "nomenclature.h"
|
#include "nomenclature.h"
|
||||||
|
#include "elementprovider.h"
|
||||||
#define PR(x) qDebug() << #x " = " << x;
|
#define PR(x) qDebug() << #x " = " << x;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,10 +30,8 @@ nomenclature::nomenclature(QETProject *project, QWidget *parent):
|
|||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
if(!m_project->isEmpty()){
|
//get list of schema present in project
|
||||||
//get list of schema present in project
|
m_list_diagram = m_project -> diagrams();
|
||||||
m_list_diagram = m_project -> diagrams();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,21 +45,11 @@ nomenclature::~nomenclature() {
|
|||||||
@param true if success
|
@param true if success
|
||||||
*/
|
*/
|
||||||
bool nomenclature::saveToCSVFile() {
|
bool nomenclature::saveToCSVFile() {
|
||||||
if(m_list_diagram.isEmpty()) return false;
|
|
||||||
|
|
||||||
//Process...
|
|
||||||
QString data = tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
|
|
||||||
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation")+";"+ tr("Label") +";"+ tr("Commententaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference\n");
|
|
||||||
QStringList rows;
|
|
||||||
for(int i=0; i<m_list_diagram.count(); i++){
|
|
||||||
rows = getRows(m_list_diagram.at(i));
|
|
||||||
for(int j=0;j<rows.count();j++){
|
|
||||||
data += rows.at(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SAVE IN FILE
|
// SAVE IN FILE
|
||||||
QString name = tr("nomenclature_") + QString(m_project -> title());
|
QString name = tr("nomenclature_") + QString(m_project -> title());
|
||||||
|
if (!name.endsWith(".csv")) {
|
||||||
|
name += ".csv";
|
||||||
|
}
|
||||||
QString filename = QFileDialog::getSaveFileName(this->m_parent, tr("Enregister sous... "), name, tr("Fichiers csv (*.csv)"));
|
QString filename = QFileDialog::getSaveFileName(this->m_parent, tr("Enregister sous... "), name, tr("Fichiers csv (*.csv)"));
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if( !filename.isEmpty() ) {
|
if( !filename.isEmpty() ) {
|
||||||
@@ -75,7 +64,7 @@ bool nomenclature::saveToCSVFile() {
|
|||||||
}
|
}
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
stream << data << endl;
|
stream << getNomenclature() << endl;
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
@@ -85,27 +74,51 @@ bool nomenclature::saveToCSVFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
gets rows of nomenclature
|
* @brief nomenclature::getNomenclature
|
||||||
@return the list of rows
|
* Create and formated a nomenclature to csv file.
|
||||||
*/
|
* @return The QString of nomenclature
|
||||||
QStringList nomenclature::getRows(Diagram *schema) {
|
*/
|
||||||
QString row;
|
QString nomenclature::getNomenclature() {
|
||||||
QStringList list;
|
//Process...
|
||||||
QList<Element *> elements_list;
|
QString data = tr("NOMENCLATURE : ") + m_project -> title() + "\n\n";
|
||||||
|
data += tr("Folio") +";"+ tr("Sch\351ma") +";"+ tr("D\351signation")+";"+ tr("Label") +";"+ tr("Commententaire") +";"+ tr("Fabriquant") +";"+ tr("Reference") +";"+ tr("Machine-reference\n");
|
||||||
|
|
||||||
//elements_list = schema->customElements();
|
if(m_list_diagram.isEmpty()) return data;
|
||||||
elements_list = schema->content().elements.toList();
|
|
||||||
for(int j=0;j<elements_list.count();j++){
|
foreach (Diagram *d, m_list_diagram) {
|
||||||
row += QString::number(schema->folioIndex()+1) + ";";
|
//Get only simple, master and unlinked slave element.
|
||||||
row += schema->title() + ";";
|
ElementProvider ep(d);
|
||||||
row += elements_list.at(j)->name() + ";";
|
QList <Element *> list_elements;
|
||||||
row += elements_list.at(j)->elementInformations()["label"].toString() + ";";
|
list_elements << ep.find(Element::Simple | Element::Master);
|
||||||
row += elements_list.at(j)->elementInformations()["comment"].toString() + ";";
|
list_elements << ep.freeElement(Element::Slave);
|
||||||
row += elements_list.at(j)->elementInformations()["manufacturer"].toString() + ";";
|
|
||||||
row += elements_list.at(j)->elementInformations()["manufacturer-reference"].toString() + ";";
|
foreach (Element *elmt, list_elements) {
|
||||||
row += elements_list.at(j)->elementInformations()["machine-manufacturer-reference"].toString() + "\n";
|
data += getElementInfo(elmt);
|
||||||
list << row;
|
}
|
||||||
}
|
}
|
||||||
return list;
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief nomenclature::getElementInfo
|
||||||
|
* @param elmt : the element to getinfo
|
||||||
|
* @return : QString with information about element formated to csv file
|
||||||
|
*/
|
||||||
|
QString nomenclature::getElementInfo(const Element *elmt) {
|
||||||
|
QString info;
|
||||||
|
|
||||||
|
Diagram *diagram = elmt -> diagram();
|
||||||
|
DiagramContext elmt_info = elmt -> elementInformations();
|
||||||
|
|
||||||
|
info += QString::number(diagram -> folioIndex()+1) + ";";
|
||||||
|
info += diagram -> title() + ";";
|
||||||
|
info += elmt -> name() + ";";
|
||||||
|
info += elmt_info["label"].toString() + ";";
|
||||||
|
info += elmt_info["comment"].toString() + ";";
|
||||||
|
info += elmt_info["manufacturer"].toString() + ";";
|
||||||
|
info += elmt_info["manufacturer-reference"].toString() + ";";
|
||||||
|
info += elmt_info["machine-manufacturer-reference"].toString() + "\n";
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class nomenclature : public QObject {
|
|||||||
|
|
||||||
// constructors, destructor
|
// constructors, destructor
|
||||||
public:
|
public:
|
||||||
nomenclature(QETProject *project =0, QWidget *parent =0);
|
nomenclature(QETProject *project, QWidget *parent =0);
|
||||||
virtual ~nomenclature();
|
virtual ~nomenclature();
|
||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
@@ -57,7 +57,8 @@ class nomenclature : public QObject {
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList getRows(Diagram *schema);
|
QString getNomenclature ();
|
||||||
|
QString getElementInfo (const Element *elmt);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1806,10 +1806,8 @@ void QETDiagramEditor::cleanCurrentProject() {
|
|||||||
*/
|
*/
|
||||||
void QETDiagramEditor::nomenclatureProject() {
|
void QETDiagramEditor::nomenclatureProject() {
|
||||||
//TODO: Test nomenclature CYRIL F.
|
//TODO: Test nomenclature CYRIL F.
|
||||||
nomenclature *nomencl= new nomenclature(currentProject()->project() ,this);
|
nomenclature nomencl(currentProject()->project() ,this);
|
||||||
nomencl->saveToCSVFile();
|
nomencl.saveToCSVFile();
|
||||||
|
|
||||||
delete nomencl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user