diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 27560a43c..ab53ac8bd 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -224,7 +224,7 @@ void QETDiagramEditor::actions() { prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un sch\351ma"), this); prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le sch\351ma"), this); prj_clean = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this); - prj_diagramNum = new QAction(QET::Icons::ConductorSettings, tr("Annoter les sch\351mas (beta)"), this); + prj_diagramNum = new QAction(QET::Icons::ConductorSettings, tr("Annoter les sch\351mas"), this); prj_nomenclature = new QAction(QET::Icons::DocumentExport, tr("Exporter une nomenclature (beta)"), this); zoom_in = new QAction(QET::Icons::ZoomIn, tr("Zoom avant"), this); @@ -1153,7 +1153,6 @@ void QETDiagramEditor::slot_updateActions() { //display the beta feature only in debug mode #ifdef QT_NO_DEBUG - prj_diagramNum -> setVisible(false); prj_nomenclature -> setVisible(false); #endif diff --git a/sources/ui/diagramselection.cpp b/sources/ui/diagramselection.cpp index 0c0d331fc..0fca3c11e 100644 --- a/sources/ui/diagramselection.cpp +++ b/sources/ui/diagramselection.cpp @@ -20,13 +20,12 @@ diagramselection::diagramselection(QETProject *prj, QWidget *parent) : QWidget(parent), - ui(new Ui::diagramselection) + ui(new Ui::diagramselection), + prj_ (prj), + list_diagram_ (prj -> diagrams()) { ui -> setupUi(this); - prj_ = prj; - // list all diagrams presents in project - list_diagram_ = prj_ -> diagrams(); - + QString project_title = prj_ -> title(); if (project_title.isEmpty()) project_title = tr("Projet sans titre"); diff --git a/sources/ui/dialogautonum.cpp b/sources/ui/dialogautonum.cpp index a2a9e67a0..e843c7293 100644 --- a/sources/ui/dialogautonum.cpp +++ b/sources/ui/dialogautonum.cpp @@ -20,6 +20,7 @@ #include "conductorautonumerotation.h" #include "qetmessagebox.h" +#include "ui/selectautonumw.h" /** * @brief DialogAutoNum::DialogAutoNum @@ -28,14 +29,15 @@ */ DialogAutoNum::DialogAutoNum(Diagram *dg, QWidget *parent) : QDialog(parent), - ui(new Ui::DialogAutoNum) + ui(new Ui::DialogAutoNum), + dg_ (dg) { ui -> setupUi(this); - dg_ = dg; - // create widget of diagram selection - dgselect_ = new diagramselection( dg_ -> project(), this ); - ui -> verticalLayout_Selection -> addWidget( dgselect_ ); + ui -> configuration_layout -> addWidget (new SelectAutonumW(dg_ -> project() -> diagrams(), ui -> configuration_tab)); + + dgselect_ = new diagramselection( dg_ -> project(), ui -> annotation_tab); + ui -> verticalLayout_Selection -> addWidget(dgselect_); } /** @@ -63,7 +65,7 @@ void DialogAutoNum::on_pushButton_delete_clicked() { this, tr("Suppression des annotations conducteurs", "Attention"), QString( - tr("Voulez vraiment supprimer les annotations conducteurs de :\n\n%1 ?") + tr("Voulez-vous vraiment supprimer les annotations conducteurs de :\n\n%1 ?") ).arg(diagramsTitle), QMessageBox::Yes | QMessageBox::No, QMessageBox::No @@ -96,7 +98,7 @@ void DialogAutoNum::on_pushButton_annotation_clicked(){ this, tr("Annotation des conducteurs", "Attention"), QString( - tr("Voulez vraiment annoter les conducteurs de :\n\n%1 ?") + tr("Voulez-vous vraiment annoter les conducteurs de :\n\n%1 ?") ).arg(diagramsTitle), QMessageBox::Yes | QMessageBox::No, QMessageBox::No @@ -104,6 +106,10 @@ void DialogAutoNum::on_pushButton_annotation_clicked(){ // if yes numerate all if( answer == QMessageBox::Yes) { + foreach (Diagram *d, listDiag) { + ConductorAutoNumerotation can(d); + can.numerateDiagram(); + } } } @@ -113,16 +119,3 @@ void DialogAutoNum::on_pushButton_annotation_clicked(){ void DialogAutoNum::on_pushButton_close_clicked() { close(); } - -/* - NumerotationContext num; - for(int i=0; isetNumerotation(Diagram::Conductors, num); - qDebug() << "ok"; - } -*/ - diff --git a/sources/ui/dialogautonum.h b/sources/ui/dialogautonum.h index d1c4e9112..d6178f9ae 100644 --- a/sources/ui/dialogautonum.h +++ b/sources/ui/dialogautonum.h @@ -43,8 +43,7 @@ class DialogAutoNum : public QDialog private: Ui::DialogAutoNum *ui; Diagram *dg_; - diagramselection *dgselect_; - + diagramselection *dgselect_; }; #endif // DialogAutoNum_H diff --git a/sources/ui/dialogautonum.ui b/sources/ui/dialogautonum.ui index cbc37783e..691baae24 100644 --- a/sources/ui/dialogautonum.ui +++ b/sources/ui/dialogautonum.ui @@ -23,17 +23,21 @@ 0 - + Configuration - + + + 0 + + - + Annotation @@ -88,8 +92,11 @@ + + <html><head/><body><p>Numérotée les folio sélectionné</p></body></html> + - Annotation + Annotation (alpha) @@ -99,6 +106,9 @@ + + <html><head/><body><p>Supprimé la numérotation des folio sélectionné</p></body></html> + Supprimer l'annotation @@ -116,19 +126,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/sources/ui/numparteditorw.cpp b/sources/ui/numparteditorw.cpp new file mode 100644 index 000000000..924f4a966 --- /dev/null +++ b/sources/ui/numparteditorw.cpp @@ -0,0 +1,142 @@ +#include +#include "numparteditorw.h" +#include "ui_numparteditorw.h" + +/** + * Constructor + */ +NumPartEditorW::NumPartEditorW(QWidget *parent) : + QWidget(parent), + ui(new Ui::NumPartEditorW), + intValidator (new QIntValidator(0,99999,this)) +{ + ui -> setupUi(this); + setType(NumPartEditorW::unit); +} + +/** + * Constructor + * Build with value of @context at position i + */ +NumPartEditorW::NumPartEditorW (NumerotationContext &context, int i, QWidget *parent): + QWidget(parent), + ui(new Ui::NumPartEditorW), + intValidator (new QIntValidator(0,99999,this)) +{ + ui -> setupUi(this); + + //if @context contains nothing build with default value + if(context.size()==0) setType(NumPartEditorW::unit); + + else { + QStringList strl = context.itemAt(i); + if (strl.at(0)=="unit") setType(NumPartEditorW::unit); + else if (strl.at(0)=="ten") setType(NumPartEditorW::ten); + else if (strl.at(0)=="hundred") setType(NumPartEditorW::hundred); + else if (strl.at(0)=="string") setType(NumPartEditorW::string); + else if (strl.at(0)== "folio") setType(NumPartEditorW::folio); + ui -> value_field -> setText(strl.at(1)); + ui -> increase_spinBox -> setValue(strl.at(2).toInt()); + } +} + +/** + * Destructor + */ +NumPartEditorW::~NumPartEditorW() +{ + delete intValidator; + delete ui; +} + +/** + * @brief NumPartEditorW::toNumContext + * @return the display to NumerotationContext + */ +NumerotationContext NumPartEditorW::toNumContext() { + NumerotationContext nc; + nc.addValue(type_str, ui -> value_field -> displayText(), ui -> increase_spinBox -> value()); + return nc; +} + +/** + * @brief NumPartEditorW::on_type_combo_activated + * Action when user change the type comboBox + */ +void NumPartEditorW::on_type_combo_activated(int index) { + emit changed(); + switch (index) { + case unit: + setType(unit); + break; + case ten: + setType(ten); + break; + case hundred: + setType(hundred); + break; + case string: + setType(string); + break; + case folio: + setType(folio); + break; + }; +} + +/** + * @brief NumPartEditorW::on_value_field_textChanged + * emit changed when @value_field text changed + */ +void NumPartEditorW::on_value_field_textChanged() { + emit changed(); +} + +/** + * @brief NumPartEditorW::on_increase_spinBox_valueChanged + *emit changed when @increase_spinBox value changed + */ +void NumPartEditorW::on_increase_spinBox_valueChanged() { + emit changed(); +} + +/** + * @brief NumPartEditorW::setType + * Set good behavior by type @t + */ +void NumPartEditorW::setType(NumPartEditorW::type t) { + ui -> type_combo -> setCurrentIndex(t); + ui -> value_field -> clear(); + ui -> increase_spinBox -> setValue(1); + switch (t) { + case unit: + ui -> value_field -> setEnabled(true); + ui ->value_field -> setValidator(intValidator); + ui -> increase_spinBox -> setEnabled(true); + type_str = "unit"; + break; + case ten: + ui -> value_field -> setEnabled(true); + ui ->value_field -> setValidator(intValidator); + ui -> increase_spinBox -> setEnabled(true); + type_str = "ten"; + break; + case hundred: + ui -> value_field -> setEnabled(true); + ui ->value_field -> setValidator(intValidator); + ui -> increase_spinBox -> setEnabled(true); + type_str = "hundred"; + break; + case string: + ui -> value_field -> setValidator(0); + ui -> value_field -> setEnabled(true); + ui -> increase_spinBox -> setDisabled(true); + type_str = "string"; + break; + case folio: + ui -> value_field -> setDisabled(true); + ui -> increase_spinBox -> setDisabled(true); + type_str = "folio"; + break; + }; +} diff --git a/sources/ui/numparteditorw.h b/sources/ui/numparteditorw.h new file mode 100644 index 000000000..30da03cd8 --- /dev/null +++ b/sources/ui/numparteditorw.h @@ -0,0 +1,41 @@ +#ifndef NUMPARTEDITORW_H +#define NUMPARTEDITORW_H + +#include +#include +#include "numerotationcontext.h" + +namespace Ui { + class NumPartEditorW; +} + +class NumPartEditorW : public QWidget +{ + Q_OBJECT + + //METHODS + public: + explicit NumPartEditorW(QWidget *parent = 0); + NumPartEditorW (NumerotationContext &, int, QWidget *parent=0); + ~NumPartEditorW(); + + enum type {unit,ten,hundred,string,folio}; + NumerotationContext toNumContext(); + + private slots: + void on_type_combo_activated(int); + void on_value_field_textChanged(); + void on_increase_spinBox_valueChanged(); + void setType (NumPartEditorW::type t); + + signals: + void changed (); + + private: + Ui::NumPartEditorW *ui; + QValidator *intValidator; + QString type_str; + +}; + +#endif // NUMPARTEDITORW_H diff --git a/sources/ui/numparteditorw.ui b/sources/ui/numparteditorw.ui new file mode 100644 index 000000000..6dff681c7 --- /dev/null +++ b/sources/ui/numparteditorw.ui @@ -0,0 +1,107 @@ + + + NumPartEditorW + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + 0 + 0 + + + + + Unité + + + + + Dizaine + + + + + Centaine + + + + + Texte + + + + + N° folio + + + + + + + + + 0 + 0 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + false + + + Qt::AlignCenter + + + + + + true + + + + + + 1 + + + + + + + + + + diff --git a/sources/ui/selectautonumw.cpp b/sources/ui/selectautonumw.cpp new file mode 100644 index 000000000..721819816 --- /dev/null +++ b/sources/ui/selectautonumw.cpp @@ -0,0 +1,135 @@ +#include "selectautonumw.h" +#include "ui_selectautonumw.h" +#include "diagram.h" + +/** + * Constructor + */ +SelectAutonumW::SelectAutonumW(const QList &diagrams, QWidget *parent) : + QWidget(parent), + ui(new Ui::SelectAutonumW), + diagram_list(diagrams) +{ + ui->setupUi(this); + + initDiagramChooser(); + setCurrentContext(); +} + +/** + * Destructor + */ +SelectAutonumW::~SelectAutonumW() +{ + delete ui; +} + +/** + * @brief SelectAutonumW::setDiagramChooser + * build the content of QComboBox @diagram_chooser. + */ +void SelectAutonumW::initDiagramChooser() { + for (int i=0; i title(); + if (diagram_title.isEmpty()) diagram_title = (tr("Sch\351ma sans titre")); + ui -> diagram_chooser -> addItem(diagram_title); + } +} + +/** + * @brief SelectAutonumW::setCurrentContext + * build the context of current diagram selected in the @diagram_chooser QcomboBox + */ +void SelectAutonumW::setCurrentContext() { + NumerotationContext nc = diagram_list.at(ui->diagram_chooser->currentIndex()) -> getNumerotation(Diagram::Conductors); + + if (nc.size() == 0) { //@nc contain nothing, build a default numPartEditor + on_add_button_clicked(); + applyEnable(false); + return; + } + for (int i=0; i editor_layout -> addWidget(part); + } + applyEnable(false); +} + +/** + * @brief SelectAutonumW::toNumContext + * @return the content to @num_part_list to NumerotationContext + */ +NumerotationContext SelectAutonumW::toNumContext() const { + NumerotationContext nc; + foreach (NumPartEditorW *npew, num_part_list_) nc << npew -> toNumContext(); + return nc; +} + +/** + * @brief SelectAutonumW::on_add_button_clicked + * Action on add_button, add a @NumPartEditor + */ +void SelectAutonumW::on_add_button_clicked() { + applyEnable(); + NumPartEditorW *part = new NumPartEditorW(this); + connect (part, SIGNAL(changed()), this, SLOT(applyEnable())); + num_part_list_ << part; + ui -> editor_layout -> addWidget(part); +} + +/** + * @brief SelectAutonumW::on_remove_button_clicked + * Action on remove button, remove the last @NumPartEditor + */ +void SelectAutonumW::on_remove_button_clicked() { + applyEnable(); + //remove if @num_part_list contains more than one item + if (num_part_list_.size() > 1) { + NumPartEditorW *part = num_part_list_.takeLast(); + disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable())); + delete part; + } +} + +/** + * @brief SelectAutonumW::on_diagram_chooser_activated + * Action on diagram_chooser + */ +void SelectAutonumW::on_diagram_chooser_activated() { + foreach(NumPartEditorW *npew, num_part_list_) delete npew; + num_part_list_.clear(); + setCurrentContext(); +} + +/** + * @brief SelectAutonumW::on_buttonBox_clicked + * Action on @buttonBox clicked + */ +void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) { + //transform button to int + int answer = ui -> buttonBox -> buttonRole(button); + + switch (answer) { + //reset the displayed context to default context of @diagram_chooser. + case QDialogButtonBox::ResetRole: + on_diagram_chooser_activated(); + applyEnable(false); + break; + //apply the context in the diagram displayed by @diagram_chooser. + case QDialogButtonBox::ApplyRole: + NumerotationContext nc = toNumContext(); + diagram_list.at(ui -> diagram_chooser -> currentIndex()) -> setNumerotation(Diagram::Conductors, nc); + applyEnable(false); + break; + }; +} + +/** + * @brief SelectAutonumW::applyEnable + * enable/disable the apply button + */ +void SelectAutonumW::applyEnable(bool b) { + ui -> buttonBox -> button(QDialogButtonBox::Apply) -> setEnabled(b); +} diff --git a/sources/ui/selectautonumw.h b/sources/ui/selectautonumw.h new file mode 100644 index 000000000..670546fa1 --- /dev/null +++ b/sources/ui/selectautonumw.h @@ -0,0 +1,41 @@ +#ifndef SELECTAUTONUMW_H +#define SELECTAUTONUMW_H + +#include +#include "diagram.h" +#include "ui/numparteditorw.h" + +namespace Ui { + class SelectAutonumW; +} + +class SelectAutonumW : public QWidget +{ + Q_OBJECT + + //METHODS + public: + explicit SelectAutonumW(const QList &, QWidget *parent = 0); + ~SelectAutonumW(); + + private: + void initDiagramChooser(); + void setCurrentContext (); + NumerotationContext toNumContext() const; + + //SLOT + private slots: + void on_add_button_clicked(); + void on_remove_button_clicked(); + void on_diagram_chooser_activated(); + void on_buttonBox_clicked(QAbstractButton *); + void applyEnable (bool = true); + + //ATTRIBUTS + private: + Ui::SelectAutonumW *ui; + const QList diagram_list; + QList num_part_list_; +}; + +#endif // SELECTAUTONUMW_H diff --git a/sources/ui/selectautonumw.ui b/sources/ui/selectautonumw.ui new file mode 100644 index 000000000..a73187c7f --- /dev/null +++ b/sources/ui/selectautonumw.ui @@ -0,0 +1,173 @@ + + + SelectAutonumW + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + 0 + + + + + Folio: + + + + + + + <html><head/><body><p>Choisir le folio</p></body></html> + + + 5 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p>Supprimer une variable de numérotation</p></body></html> + + + + + + + :/ico/22x22/list-remove.png:/ico/22x22/list-remove.png + + + false + + + + + + + <html><head/><body><p>Ajouter une variable de numérotation</p></body></html> + + + + + + + :/ico/22x22/list-add.png:/ico/22x22/list-add.png + + + false + + + + + + + + + Définition + + + + + + 0 + + + + + 0 + + + + + Type + + + Qt::AlignCenter + + + + + + + Valeur + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Incrémentation + + + Qt::AlignCenter + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QDialogButtonBox::Apply|QDialogButtonBox::Help|QDialogButtonBox::Reset + + + + + + + + + +