diff --git a/sources/ui/bomexportdialog.cpp b/sources/ui/bomexportdialog.cpp index 8725d095b..970ae5cab 100644 --- a/sources/ui/bomexportdialog.cpp +++ b/sources/ui/bomexportdialog.cpp @@ -39,11 +39,11 @@ @param parent widget */ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) : - QDialog(parent), - ui(new Ui::BOMExportDialog), - m_project(project) + QDialog(parent), + ui(new Ui::BOMExportDialog), + m_project(project) { - ui->setupUi(this); + ui->setupUi(this); m_export_info.insert("pos", tr("Position")); m_export_info.insert("folio_title", tr("Titre du folio")); @@ -59,10 +59,14 @@ BOMExportDialog::BOMExportDialog(QETProject *project, QWidget *parent) : m_button_group.addButton(ui->m_coil_cb, 4); m_button_group.addButton(ui->m_protection_cb, 5); #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) // ### Qt 6: remove - connect(&m_button_group, static_cast(&QButtonGroup::buttonClicked), [this](int id) + connect(&m_button_group, + static_cast(&QButtonGroup::buttonClicked), + [this](int id) #else #pragma message("@TODO remove code for QT 5.15 or later") - connect(&m_button_group, static_cast(&QButtonGroup::idClicked), [this](int id) + connect(&m_button_group, + static_cast(&QButtonGroup::idClicked), + [this](int id) #endif { auto check_box = static_cast(m_button_group.button(0)); @@ -352,7 +356,7 @@ QString BOMExportDialog::headers() const header_string += "\n"; } - else if (!queryStr().isEmpty()) //Try to retreive the header according to the sql query + else if (!queryStr().isEmpty())//Try to retreive the header according to the sql query { if (queryStr().startsWith("SELECT ") && queryStr().contains("FROM")) { diff --git a/sources/ui/bomexportdialog.h b/sources/ui/bomexportdialog.h index 92dabe42d..830bd9258 100644 --- a/sources/ui/bomexportdialog.h +++ b/sources/ui/bomexportdialog.h @@ -33,44 +33,46 @@ class BOMExportDialog; class BOMExportDialog : public QDialog { - Q_OBJECT + Q_OBJECT - public: - explicit BOMExportDialog(QETProject *project, QWidget *parent = nullptr); - ~BOMExportDialog() override; + public: + explicit BOMExportDialog(QETProject *project, + QWidget *parent = nullptr); + ~BOMExportDialog() override; virtual int exec() override; QStringList selectedKeys() const; QString translatedKeys(const QString &key) const; - private slots: - void on_m_add_pb_clicked(); - void on_m_remove_pb_clicked(); - void on_m_up_pb_clicked(); - void on_m_down_pb_clicked(); - void on_m_save_name_le_textChanged(const QString &arg1); - void on_m_format_as_nomenclature_rb_toggled(bool checked); - void on_m_edit_sql_query_cb_clicked(); - void on_m_save_current_conf_pb_clicked(); - void on_m_load_pb_clicked(); + private slots: + void on_m_add_pb_clicked(); + void on_m_remove_pb_clicked(); + void on_m_up_pb_clicked(); + void on_m_down_pb_clicked(); + void on_m_save_name_le_textChanged(const QString &arg1); + void on_m_format_as_nomenclature_rb_toggled(bool checked); + void on_m_edit_sql_query_cb_clicked(); + void on_m_save_current_conf_pb_clicked(); + void on_m_load_pb_clicked(); private: - void setUpItems(); - QString getBom(); - QString headers() const; - bool createDataBase(); - void populateDataBase(); - QHash elementInfoToString(Element *elmt) const; - QString queryStr() const; - void updateQueryLine(); - void fillSavedQuery(); + void setUpItems(); + QString getBom(); + QString headers() const; + bool createDataBase(); + void populateDataBase(); + QHash elementInfoToString( + Element *elmt) const; + QString queryStr() const; + void updateQueryLine(); + void fillSavedQuery(); - private: - Ui::BOMExportDialog *ui; - QETProject *m_project = nullptr; - QSqlDatabase m_data_base; + private: + Ui::BOMExportDialog *ui; + QETProject *m_project = nullptr; + QSqlDatabase m_data_base; QSqlQuery m_insert_query; - QString m_custom_query; + QString m_custom_query; QHash m_export_info; QButtonGroup m_button_group; QList m_items_list; diff --git a/sources/ui/configsaveloaderwidget.cpp b/sources/ui/configsaveloaderwidget.cpp index 9621d8644..cb9631eb6 100644 --- a/sources/ui/configsaveloaderwidget.cpp +++ b/sources/ui/configsaveloaderwidget.cpp @@ -19,10 +19,10 @@ #include "ui_configsaveloaderwidget.h" ConfigSaveLoaderWidget::ConfigSaveLoaderWidget(QWidget *parent) : - QGroupBox(parent), - ui(new Ui::ConfigSaveLoaderWidget) + QGroupBox(parent), + ui(new Ui::ConfigSaveLoaderWidget) { - ui->setupUi(this); + ui->setupUi(this); } ConfigSaveLoaderWidget::~ConfigSaveLoaderWidget() diff --git a/sources/ui/configsaveloaderwidget.h b/sources/ui/configsaveloaderwidget.h index 7209d9db5..a9926b2ad 100644 --- a/sources/ui/configsaveloaderwidget.h +++ b/sources/ui/configsaveloaderwidget.h @@ -34,7 +34,7 @@ class ConfigSaveLoaderWidget; */ class ConfigSaveLoaderWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT public: explicit ConfigSaveLoaderWidget(QWidget *parent = nullptr); diff --git a/sources/ui/diagrampropertiesdialog.cpp b/sources/ui/diagrampropertiesdialog.cpp index 5b1f4cbb6..0b1ab5257 100644 --- a/sources/ui/diagrampropertiesdialog.cpp +++ b/sources/ui/diagrampropertiesdialog.cpp @@ -46,7 +46,7 @@ DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *pare setWindowFlags(Qt::Sheet); #endif - setWindowTitle(tr("Propriétés du folio", "window title")); + setWindowTitle(tr("Propriétés du folio", "window title")); //Border widget BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this); @@ -148,8 +148,8 @@ void DiagramPropertiesDialog::editAutonum() Open folio autonum editor */ void DiagramPropertiesDialog::editAutoFolioNum () { - ProjectPropertiesDialog ppd (m_diagram->project(), this); - ppd.setCurrentPage(ProjectPropertiesDialog::Autonum); - ppd.changeToFolio(); - ppd.exec(); + ProjectPropertiesDialog ppd (m_diagram->project(), this); + ppd.setCurrentPage(ProjectPropertiesDialog::Autonum); + ppd.changeToFolio(); + ppd.exec(); } diff --git a/sources/ui/diagrampropertiesdialog.h b/sources/ui/diagrampropertiesdialog.h index 85dab08d4..612bb474c 100644 --- a/sources/ui/diagrampropertiesdialog.h +++ b/sources/ui/diagrampropertiesdialog.h @@ -37,7 +37,7 @@ class DiagramPropertiesDialog : public QDialog { public slots: void editAutonum (); - void editAutoFolioNum (); + void editAutoFolioNum (); private: Diagram *m_diagram; diff --git a/sources/ui/diagramselection.cpp b/sources/ui/diagramselection.cpp index 72be98369..42b3a5d15 100644 --- a/sources/ui/diagramselection.cpp +++ b/sources/ui/diagramselection.cpp @@ -66,7 +66,8 @@ void diagramselection::load_TableDiagram() { QTableWidgetItem *item_State = new QTableWidgetItem(); QString diagram_title = list_diagram_.at(i) -> title(); - if (diagram_title.isEmpty()) diagram_title = tr("Folio sans titre"); + if (diagram_title.isEmpty()) + diagram_title = tr("Folio sans titre"); item_Name -> setData(Qt::DisplayRole, diagram_title); item_State -> setData(Qt::CheckStateRole, Qt::Checked); diff --git a/sources/ui/dynamicelementtextitemeditor.cpp b/sources/ui/dynamicelementtextitemeditor.cpp index b61df0243..8145ee5a6 100644 --- a/sources/ui/dynamicelementtextitemeditor.cpp +++ b/sources/ui/dynamicelementtextitemeditor.cpp @@ -32,15 +32,15 @@ #include DynamicElementTextItemEditor::DynamicElementTextItemEditor(Element *element, QWidget *parent) : - AbstractElementPropertiesEditorWidget(parent), - ui(new Ui::DynamicElementTextItemEditor) + AbstractElementPropertiesEditorWidget(parent), + ui(new Ui::DynamicElementTextItemEditor) { - ui->setupUi(this); + ui->setupUi(this); - ui->m_tree_view->setItemDelegate(new DynamicTextItemDelegate(ui->m_tree_view)); + ui->m_tree_view->setItemDelegate(new DynamicTextItemDelegate(ui->m_tree_view)); ui->m_remove_selection->setDisabled(true); - setElement(element); + setElement(element); } DynamicElementTextItemEditor::~DynamicElementTextItemEditor() @@ -50,17 +50,17 @@ DynamicElementTextItemEditor::~DynamicElementTextItemEditor() void DynamicElementTextItemEditor::setElement(Element *element) { - if (m_element == element) - return; - - m_element = element; - - DynamicElementTextModel *old_model = m_model; - m_model = new DynamicElementTextModel(element, ui->m_tree_view); + if (m_element == element) + return; + + m_element = element; + + DynamicElementTextModel *old_model = m_model; + m_model = new DynamicElementTextModel(element, ui->m_tree_view); connect(m_model, &DynamicElementTextModel::dataChanged, this, &DynamicElementTextItemEditor::dataEdited); - ui->m_tree_view->setModel(m_model); - - if(old_model) + ui->m_tree_view->setModel(m_model); + + if(old_model) delete old_model; } @@ -198,10 +198,10 @@ void DynamicElementTextItemEditor::dataEdited() */ void DynamicElementTextItemEditor::on_m_add_text_clicked() { - if (!m_element) - return; + if (!m_element) + return; - DynamicElementTextItem *deti = new DynamicElementTextItem(m_element); + DynamicElementTextItem *deti = new DynamicElementTextItem(m_element); if (m_element->diagram()) { m_element->diagram()->undoStack().push(new AddElementTextCommand(m_element, deti)); @@ -219,9 +219,9 @@ void DynamicElementTextItemEditor::on_m_add_text_clicked() */ void DynamicElementTextItemEditor::on_m_remove_selection_clicked() { - DynamicElementTextItem *deti = m_model->textFromIndex(ui->m_tree_view->currentIndex()); - if(deti) - { + DynamicElementTextItem *deti = m_model->textFromIndex(ui->m_tree_view->currentIndex()); + if(deti) + { if(m_element->diagram()) { DiagramContent dc; @@ -229,7 +229,7 @@ void DynamicElementTextItemEditor::on_m_remove_selection_clicked() m_element->diagram()->undoStack().push(new DeleteQGraphicsItemCommand(m_element->diagram(), dc)); } return; - } + } ElementTextItemGroup *group = m_model->groupFromIndex(ui->m_tree_view->currentIndex()); if(group && m_element.data()->diagram()) m_element.data()->diagram()->undoStack().push(new RemoveTextsGroupCommand(m_element.data(), group)); @@ -259,10 +259,10 @@ void DynamicElementTextItemEditor::on_m_tree_view_clicked(const QModelIndex &ind void DynamicElementTextItemEditor::on_m_export_pb_clicked() { - ExportElementTextPattern eetp(m_element); + ExportElementTextPattern eetp(m_element); } void DynamicElementTextItemEditor::on_m_import_pb_clicked() { - ImportElementTextPattern ietp(m_element); + ImportElementTextPattern ietp(m_element); } diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index 935a33560..020aebac8 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -61,12 +61,12 @@ DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *pare QStandardItemModel(parent), m_element(element) { - setColumnCount(2); - setHeaderData(0, Qt::Horizontal, tr("Propriété"), Qt::DisplayRole); - setHeaderData(1, Qt::Horizontal, tr("Valeur"), Qt::DisplayRole); - + setColumnCount(2); + setHeaderData(0, Qt::Horizontal, tr("Propriété"), Qt::DisplayRole); + setHeaderData(1, Qt::Horizontal, tr("Valeur"), Qt::DisplayRole); + connect(this, &DynamicElementTextModel::itemChanged, this, &DynamicElementTextModel::itemDataChanged); - + connect(m_element.data(), &Element::textsGroupAdded, this, &DynamicElementTextModel::addGroup, Qt::DirectConnection); connect(m_element.data(), &Element::textsGroupAboutToBeRemoved, this, &DynamicElementTextModel::removeGroup, Qt::DirectConnection); connect(m_element.data(), &Element::textRemoved, this, &DynamicElementTextModel::removeText, Qt::DirectConnection); @@ -77,7 +77,7 @@ DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *pare for (ElementTextItemGroup *grp : m_element.data()->textGroups()) addGroup(grp); - for (DynamicElementTextItem *deti : m_element.data()->dynamicTextItems()) + for (DynamicElementTextItem *deti : m_element.data()->dynamicTextItems()) this->appendRow(itemsForText(deti)); } @@ -115,61 +115,79 @@ bool DynamicElementTextModel::indexIsInGroup(const QModelIndex &index) const /** @brief DynamicElementTextModel::itemsForText @param deti - @return The items for the text @deti, if the text @deti is already managed by this model + @return The items for the text deti, + if the text deti is already managed by this model the returned list is empty - The returned items haven't got the same number of childs if the text is in a group or not. + The returned items haven't got the same number + of childs if the text is in a group or not. */ -QList DynamicElementTextModel::itemsForText(DynamicElementTextItem *deti) +QList DynamicElementTextModel::itemsForText( + DynamicElementTextItem *deti) { QList qsi_list; if(m_texts_list.keys().contains(deti)) - return qsi_list; - + return qsi_list; + QStandardItem *qsi = new QStandardItem(deti->toPlainText()); - qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled |Qt::ItemIsDragEnabled); + qsi->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + |Qt::ItemIsDragEnabled); qsi->setIcon(QET::Icons::PartText); - //Source of text - QStandardItem *src = new QStandardItem(tr("Source du texte")); - src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - + //Source of text + QStandardItem *src = new QStandardItem(tr("Source du texte")); + src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + QString title; - if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr("Texte utilisateur"); - else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr("Information de l'élément"); + if (deti->textFrom() == DynamicElementTextItem::UserText) + title = tr("Texte utilisateur"); + else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) + title = tr("Information de l'élément"); else title = tr("Texte composé"); - QStandardItem *srca = new QStandardItem(title); - srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - srca->setData(textFrom, Qt::UserRole+1); - - qsi_list << src << srca; - qsi->appendRow(qsi_list); - - //User text + QStandardItem *srca = new QStandardItem(title); + srca->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + srca->setData(textFrom, Qt::UserRole+1); + + qsi_list << src << srca; + qsi->appendRow(qsi_list); + + //User text QStandardItem *usr = new QStandardItem(tr("Texte")); - usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QStandardItem *usra = new QStandardItem(deti->toPlainText()); - usra->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1); - + usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QStandardItem *usra = new QStandardItem(deti->toPlainText()); + usra->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1); + qsi_list.clear(); - qsi_list << usr << usra; - qsi->appendRow(qsi_list); - + qsi_list << usr << usra; + qsi->appendRow(qsi_list); + //Info text QStandardItem *info = new QStandardItem(tr("Information")); - info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QStandardItem *infoa = new QStandardItem(QETApp::elementTranslatedInfoKey(deti->infoName())); - infoa->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1); //Use to know the edited thing - infoa->setData(deti->infoName(), Qt::UserRole+2); //Use to know to element info name - + info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QStandardItem *infoa = + new QStandardItem( + QETApp::elementTranslatedInfoKey( + deti->infoName())); + infoa->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + //Use to know the edited thing + infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1); + //Use to know to element info name + infoa->setData(deti->infoName(), Qt::UserRole+2); + qsi_list.clear(); - qsi_list << info << infoa; - qsi->appendRow(qsi_list); + qsi_list << info << infoa; + qsi->appendRow(qsi_list); //Composite text QStandardItem *composite = new QStandardItem(tr("Texte composé")); @@ -178,28 +196,36 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI DiagramContext dc; if(deti->elementUseForInfo()) dc = deti->elementUseForInfo()->elementInformations(); - QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() ? - tr("Mon texte composé") : - autonum::AssignVariables::replaceVariable(deti->compositeText(), dc)); - compositea->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - compositea->setData(DynamicElementTextModel::compositeText, Qt::UserRole+1); //Use to know the edited thing - compositea->setData(deti->compositeText(), Qt::UserRole+2); //Use to know to element composite formula + QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() + ? tr("Mon texte composé") + : autonum::AssignVariables::replaceVariable( + deti->compositeText(), dc)); + compositea->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + //Use to know the edited thing + compositea->setData(DynamicElementTextModel::compositeText, + Qt::UserRole+1); + //Use to know to element composite formula + compositea->setData(deti->compositeText(), Qt::UserRole+2); qsi_list.clear(); qsi_list << composite << compositea; qsi->appendRow(qsi_list); - - //Size + + //Size QStandardItem *size = new QStandardItem(tr("Taille")); - size->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QStandardItem *siza = new QStandardItem(); + size->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QStandardItem *siza = new QStandardItem(); siza->setData(deti->font().pointSize(), Qt::EditRole); - siza->setData(DynamicElementTextModel::size, Qt::UserRole+1); - siza->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - - qsi_list.clear(); - qsi_list << size << siza; + siza->setData(DynamicElementTextModel::size, Qt::UserRole+1); + siza->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + + qsi_list.clear(); + qsi_list << size << siza; qsi->appendRow(qsi_list); //Font @@ -216,18 +242,20 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI qsi_list << font << fonta; qsi->appendRow(qsi_list); - //Color - QStandardItem *color = new QStandardItem(tr("Couleur")); - color->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QStandardItem *colora = new QStandardItem; - colora->setData(deti->color(), Qt::ForegroundRole); - colora->setData(deti->color(), Qt::EditRole); - colora->setData(DynamicElementTextModel::color, Qt::UserRole+1); - colora->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - - qsi_list.clear(); - qsi_list << color << colora; + //Color + QStandardItem *color = new QStandardItem(tr("Couleur")); + color->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + + QStandardItem *colora = new QStandardItem; + colora->setData(deti->color(), Qt::ForegroundRole); + colora->setData(deti->color(), Qt::EditRole); + colora->setData(DynamicElementTextModel::color, Qt::UserRole+1); + colora->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + + qsi_list.clear(); + qsi_list << color << colora; qsi->appendRow(qsi_list); //Frame @@ -238,7 +266,9 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI frame_a->setCheckable(true); frame_a->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked); frame_a->setData(DynamicElementTextModel::frame, Qt::UserRole+1); - frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); + frame_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsUserCheckable); qsi_list.clear(); qsi_list << frame << frame_a; @@ -251,7 +281,9 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI QStandardItem *width_a = new QStandardItem; width_a->setData(deti->textWidth(), Qt::EditRole); width_a->setData(DynamicElementTextModel::textWidth, Qt::UserRole+1); - width_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + width_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << width << width_a; @@ -266,7 +298,9 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI QStandardItem *x_pos_a = new QStandardItem; x_pos_a->setData(deti->pos().x(), Qt::EditRole); x_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1); - x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + x_pos_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << x_pos << x_pos_a; @@ -279,7 +313,9 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI QStandardItem *y_pos_a = new QStandardItem; y_pos_a->setData(deti->pos().y(), Qt::EditRole); y_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1); - y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + y_pos_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << y_pos << y_pos_a; @@ -291,8 +327,11 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI QStandardItem *rot_a = new QStandardItem; rot_a->setData(deti->rotation(), Qt::EditRole); - rot_a->setData(DynamicElementTextModel::rotation, Qt::UserRole+1); - rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + rot_a->setData(DynamicElementTextModel::rotation, + Qt::UserRole+1); + rot_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear();; qsi_list << rot << rot_a; @@ -303,9 +342,13 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); QStandardItem *alignmenta = new QStandardItem(tr("Éditer")); - alignmenta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - alignmenta->setData(DynamicElementTextModel::txtAlignment, Qt::UserRole+1); - alignmenta->setData(QVariant::fromValue(deti->alignment()), Qt::UserRole+2); + alignmenta->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + alignmenta->setData(DynamicElementTextModel::txtAlignment, + Qt::UserRole+1); + alignmenta->setData(QVariant::fromValue(deti->alignment()), + Qt::UserRole+2); qsi_list.clear(); qsi_list << alignment << alignmenta; @@ -318,7 +361,7 @@ QList DynamicElementTextModel::itemsForText(DynamicElementTextI empty_qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); qsi_list << qsi << empty_qsi; - m_texts_list.insert(deti, qsi); + m_texts_list.insert(deti, qsi); blockSignals(true); enableSourceText(deti, deti->textFrom()); blockSignals(false); @@ -343,41 +386,45 @@ void DynamicElementTextModel::addText(DynamicElementTextItem *deti) void DynamicElementTextModel::removeText(DynamicElementTextItem *deti) { if (!m_texts_list.contains(deti)) - return; - - QModelIndex text_index = m_texts_list.value(deti)->index(); - this->removeRow(text_index.row(), text_index.parent()); - m_texts_list.remove(deti); + return; + + QModelIndex text_index = m_texts_list.value(deti)->index(); + this->removeRow(text_index.row(), text_index.parent()); + m_texts_list.remove(deti); setConnection(deti, false); } /** @brief DynamicElementTextModel::textFromIndex @param index - @return the text associated with @index. Returned value can be nullptr - @Index can be a child of an index associated with a text and can be the column 0 or 1. + @return the text associated with index. Returned value can be nullptr + Index can be a child of an index associated with a text + and can be the column 0 or 1. */ -DynamicElementTextItem *DynamicElementTextModel::textFromIndex(const QModelIndex &index) const +DynamicElementTextItem *DynamicElementTextModel::textFromIndex( + const QModelIndex &index) const { - if(!index.isValid()) - return nullptr; - - if (QStandardItem *item = itemFromIndex(index)) - return textFromItem(item); - else - return nullptr; + if(!index.isValid()) + return nullptr; + + if (QStandardItem *item = itemFromIndex(index)) + return textFromItem(item); + else + return nullptr; } /** @brief DynamicElementTextModel::textFromItem @param item - @return the text associated with @item. Return value can be nullptr - @item can be a child of an item associated with a text and can be the column 0 or 1. + @return the text associated with item. Return value can be nullptr + item can be a child of an item associated with a text + and can be the column 0 or 1. Note can return nullptr */ -DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *item) const +DynamicElementTextItem *DynamicElementTextModel::textFromItem( + QStandardItem *item) const { - //Get the item of the column 0 + //Get the item of the column 0 if(item->column() == 1) { if(item->parent()) @@ -385,7 +432,7 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite else item = itemFromIndex(index(item->row(),0)); } - //Item haven't got parent, so they can be only a text or a group + //Item haven't got parent, so they can be only a text or a group if(!item->parent()) { if(m_texts_list.values().contains(item)) @@ -426,9 +473,10 @@ DynamicElementTextItem *DynamicElementTextModel::textFromItem(QStandardItem *ite /** @brief DynamicElementTextModel::indexFromText @param text - @return the QModelIndex for @text, or a default QModelIndex if not match + @return the QModelIndex for text, or a default QModelIndex if not match */ -QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text) const +QModelIndex DynamicElementTextModel::indexFromText( + DynamicElementTextItem *text) const { if(m_texts_list.contains(text)) return m_texts_list.value(text)->index(); @@ -439,11 +487,14 @@ QModelIndex DynamicElementTextModel::indexFromText(DynamicElementTextItem *text) /** @brief DynamicElementTextModel::undoForEditedText @param deti - @return A QUndoCommand that describe all changes made for @deti. - Each change made for @deti is append as a child of the returned QUndoCommand. - In other word, if the returned QUndoCommand have no child, that mean there is no change. + @return A QUndoCommand that describe all changes made for deti. + Each change made for deti is append as a child of the returned QUndoCommand. + In other word, if the returned QUndoCommand have no child, + that mean there is no change. */ -QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo) const +QUndoCommand *DynamicElementTextModel::undoForEditedText( + DynamicElementTextItem *deti, + QUndoCommand *parent_undo) const { QUndoCommand *undo = nullptr; @@ -565,11 +616,14 @@ QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem @brief DynamicElementTextModel::undoForEditedGroup @param group @param parent_undo - @return A QUndoCommand that describe all changes made for @group. - Each change made for @group is append as a child of the returned QUndoCommand. - In other word, if the returned QUndoCommand have no child, that mean there is no change. + @return A QUndoCommand that describe all changes made for group. + Each change made for group is append as a child of the returned QUndoCommand. + In other word, if the returned QUndoCommand have no child, + that mean there is no change. */ -QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo) const +QUndoCommand *DynamicElementTextModel::undoForEditedGroup( + ElementTextItemGroup *group, + QUndoCommand *parent_undo) const { QUndoCommand *undo = nullptr; if(parent_undo) @@ -640,7 +694,10 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) //Group QStandardItem *grp = new QStandardItem(group->name()); - grp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable); + grp->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsDropEnabled + | Qt::ItemIsEditable); grp->setIcon(QET::Icons::textGroup); QStandardItem *empty_qsi = new QStandardItem(0); @@ -664,8 +721,11 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) default: break;} QStandardItem *alignment_a = new QStandardItem(text); - alignment_a->setData(DynamicElementTextModel::grpAlignment, Qt::UserRole+1); - alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + alignment_a->setData(DynamicElementTextModel::grpAlignment, + Qt::UserRole+1); + alignment_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << alignment << alignment_a; grp->appendRow(qsi_list); @@ -677,7 +737,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) QStandardItem *x_pos_a = new QStandardItem; x_pos_a->setData(group->pos().x(), Qt::EditRole); x_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1); - x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + x_pos_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << x_pos << x_pos_a; @@ -690,7 +752,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) QStandardItem *y_pos_a = new QStandardItem; y_pos_a->setData(group->pos().y(), Qt::EditRole); y_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1); - y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + y_pos_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << y_pos << y_pos_a; @@ -703,7 +767,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) QStandardItem *rot_a = new QStandardItem; rot_a->setData(group->rotation(), Qt::EditRole); rot_a->setData(DynamicElementTextModel::grpRotation, Qt::UserRole+1); - rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + rot_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << rot << rot_a; grp->appendRow(qsi_list); @@ -715,7 +781,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) QStandardItem *v_adj_a = new QStandardItem; v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole); v_adj_a->setData(DynamicElementTextModel::grpVAdjust, Qt::UserRole+1); - v_adj_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + v_adj_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); qsi_list.clear(); qsi_list << v_adj << v_adj_a; grp->appendRow(qsi_list); @@ -728,7 +796,9 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) frame_a->setCheckable(true); frame_a->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked); frame_a->setData(DynamicElementTextModel::grpFrame, Qt::UserRole+1); - frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); + frame_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsUserCheckable); qsi_list.clear(); qsi_list << frame_ << frame_a; grp->appendRow(qsi_list); @@ -740,9 +810,14 @@ void DynamicElementTextModel::addGroup(ElementTextItemGroup *group) QStandardItem *hold_bottom_a = new QStandardItem(); hold_bottom_a->setCheckable(true); - hold_bottom_a->setCheckState(group->holdToBottomPage() ? Qt::Checked : Qt::Unchecked); - hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, Qt::UserRole+1); - hold_bottom_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); + hold_bottom_a->setCheckState(group->holdToBottomPage() + ? Qt::Checked + : Qt::Unchecked); + hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, + Qt::UserRole+1); + hold_bottom_a->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsUserCheckable); qsi_list.clear(); qsi_list << hold_bottom << hold_bottom_a; grp->appendRow(qsi_list); @@ -780,13 +855,15 @@ void DynamicElementTextModel::removeGroup(ElementTextItemGroup *group) @param deti @param group */ -void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group) +void DynamicElementTextModel::addTextToGroup(DynamicElementTextItem *deti, + ElementTextItemGroup *group) { QStandardItem *group_item = m_groups_list.value(group); group_item->appendRow(itemsForText(deti)); } -void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group) +void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti, + ElementTextItemGroup *group) { Q_UNUSED(group) @@ -802,29 +879,33 @@ void DynamicElementTextModel::removeTextFromGroup(DynamicElementTextItem *deti, /** @brief DynamicElementTextModel::groupFromIndex @param index - @return the group associated with @index. Return value can be nullptr - @Index can be a child of an index associated with a group and can be the column 0 or 1. + @return the group associated with index. Return value can be nullptr + @Index can be a child of an index associated with a group + and can be the column 0 or 1. */ -ElementTextItemGroup *DynamicElementTextModel::groupFromIndex(const QModelIndex &index) const +ElementTextItemGroup *DynamicElementTextModel::groupFromIndex( + const QModelIndex &index) const { if(!index.isValid()) - return nullptr; - - if (QStandardItem *item = itemFromIndex(index)) - return groupFromItem(item); - else - return nullptr; + return nullptr; + + if (QStandardItem *item = itemFromIndex(index)) + return groupFromItem(item); + else + return nullptr; } /** @brief DynamicElementTextModel::groupFromItem @param item - @return the group associated with @item. Return value can be nullptr - @item can be a child of an item associated with a group and can be the column 0 or 1. + @return the group associated with item. Return value can be nullptr + item can be a child of an item associated with a group + and can be the column 0 or 1. */ -ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item) const +ElementTextItemGroup *DynamicElementTextModel::groupFromItem( + QStandardItem *item) const { - //Get the item of the column 0 + //Get the item of the column 0 if(item->column() == 1) { if(item->parent()) @@ -845,10 +926,11 @@ ElementTextItemGroup *DynamicElementTextModel::groupFromItem(QStandardItem *item /** @brief DynamicElementTextModel::indexFromGroup @param group - @return The index associated to the group @group + @return The index associated to the group group or a default QModelIndex if not match */ -QModelIndex DynamicElementTextModel::indexFromGroup(ElementTextItemGroup *group) const +QModelIndex DynamicElementTextModel::indexFromGroup( + ElementTextItemGroup *group) const { if(m_groups_list.keys().contains(group)) return m_groups_list.value(group)->index(); @@ -870,7 +952,10 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const if(index.column() == 1) { if(index.parent().isValid()) - item = itemFromIndex(index.parent().QModelIndex::model()->index(index.row(),0)); + item = itemFromIndex(index.parent() + .QModelIndex::model()->index( + index.row(), + 0)); else item = itemFromIndex(this->index(index.row(),0)); } @@ -886,8 +971,8 @@ bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const /** @brief DynamicElementTextModel::indexIsGroup @param index - @return True if @index represente a group, both for the column 0 and 1. - Return false if @index is a child of an index associated to a group. + @return True if index represente a group, both for the column 0 and 1. + Return false if index is a child of an index associated to a group. */ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const { @@ -897,7 +982,9 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const if(index.column() == 1) { if(index.parent().isValid()) - item = itemFromIndex(index.parent().QModelIndex::model()->index(index.row(),0)); + item = itemFromIndex(index.parent() + .QModelIndex::model()->index( + index.row(),0)); else item = itemFromIndex(this->index(index.row(),0)); } @@ -910,7 +997,12 @@ bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const return false; } -bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const +bool DynamicElementTextModel::canDropMimeData( + const QMimeData *data, + Qt::DropAction action, + int row, + int column, + const QModelIndex &parent) const { Q_UNUSED(action); @@ -963,9 +1055,14 @@ bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAct @param row @param column @param parent - @return In any case return false, for overwrite the default behavior of model. + @return In any case return false, + for overwrite the default behavior of model. */ -bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) +bool DynamicElementTextModel::dropMimeData(const QMimeData *data, + Qt::DropAction action, + int row, + int column, + const QModelIndex &parent) { Q_UNUSED(action) @@ -1093,11 +1190,14 @@ QStringList DynamicElementTextModel::mimeTypes() const /** @brief DynamicElementTextModel::enableSourceText - Enable the good field, according to the current source of text, for the edited text @deti + Enable the good field, according to the current source of text, + for the edited text @deti @param deti @param tf */ -void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf) +void DynamicElementTextModel::enableSourceText( + DynamicElementTextItem *deti, + DynamicElementTextItem::TextFrom tf) { if (!m_texts_list.contains(deti)) return; @@ -1128,7 +1228,8 @@ void DynamicElementTextModel::enableSourceText(DynamicElementTextItem *deti, Dyn Enable/disable the item "group rotation" according the option hold to bottom @param group */ -void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *group) +void DynamicElementTextModel::enableGroupRotationAndPos( + ElementTextItemGroup *group) { if(!m_groups_list.contains(group)) return; @@ -1146,12 +1247,21 @@ void DynamicElementTextModel::enableGroupRotationAndPos(ElementTextItemGroup *gr } else { - qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled); + qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled); + qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); + qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled); + qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable + | Qt::ItemIsEnabled + | Qt::ItemIsEditable); } } @@ -1210,11 +1320,14 @@ void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi) } } - //We emit the signal only if @qsi is in the second column, because the data are stored on this column - //the first column is use only for display the title of the property, except for the name of texts group - if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged) + //We emit the signal only if @qsi is in the second column, + //because the data are stored on this column + //the first column is use only for display the title of the property, + //except for the name of texts group + if((m_groups_list.values().contains(qsi) || qsi->column() == 1) + && !m_block_dataChanged) emit dataChanged(); - if(deti) deti->updateXref(); + if(deti) deti->updateXref(); } /** @@ -1295,7 +1408,8 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se } } -void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, ValueType type) +void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, + ValueType type) { QStandardItem *qsi = m_texts_list.value(deti); if (!qsi) @@ -1387,7 +1501,9 @@ void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, V m_block_dataChanged = false; } -void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type) +void DynamicElementTextModel::updateDataFromGroup( + ElementTextItemGroup *group, + DynamicElementTextModel::ValueType type) { QStandardItem *qsi = m_groups_list.value(group); if (!qsi) @@ -1445,10 +1561,13 @@ void DynamicElementTextModel::updateDataFromGroup(ElementTextItemGroup *group, D ***************************************************/ DynamicTextItemDelegate::DynamicTextItemDelegate(QObject *parent) : - QStyledItemDelegate(parent) + QStyledItemDelegate(parent) {} -QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +QWidget *DynamicTextItemDelegate::createEditor( + QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { switch (index.data(Qt::UserRole+1).toInt()) { @@ -1615,7 +1734,10 @@ QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOpti return QStyledItemDelegate::createEditor(parent, option, index); } -void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const +void DynamicTextItemDelegate::setModelData( + QWidget *editor, + QAbstractItemModel *model, + const QModelIndex &index) const { if (index.isValid()) { @@ -1725,10 +1847,11 @@ void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel * bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event) { - //This is a bad hack, for change the normal behavior : - //in normal behavior, the value is commited when the spinbox lose focus or enter key is pressed - //With this hack the value is commited each time the value change without the need to validate. - //then the change is apply in live + //This is a bad hack, for change the normal behavior : + //in normal behavior, + //the value is commited when the spinbox lose focus or enter key is pressed + //With this hack the value is commited each time the value change without the need to validate. + //then the change is apply in live if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox" || \ object->objectName() == "group_rotation" || object->objectName() == "group_v_adjustment" || object->objectName() == "width_spinbox" ||\ object->objectName() == "group_pos") @@ -1752,7 +1875,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event) return true; } - //Like the hack above, change the current index of the combobox, apply the change immediately, no need to lose focus or press enter. + //Like the hack above, change the current index of the combobox, + // apply the change immediately, no need to lose focus or press enter. if((object->objectName() == "text_from" || object->objectName() == "info_text" || object->objectName() == "group_alignment") && event->type() == QEvent::FocusIn) { QComboBox *qcb = static_cast(object); @@ -1767,7 +1891,8 @@ bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event) @param deti @return A list of available info of element */ -QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) const +QStringList DynamicTextItemDelegate::availableInfo( + DynamicElementTextItem *deti) const { QStringList qstrl; diff --git a/sources/ui/elementinfopartwidget.cpp b/sources/ui/elementinfopartwidget.cpp index f2b3c1a20..7d905c368 100644 --- a/sources/ui/elementinfopartwidget.cpp +++ b/sources/ui/elementinfopartwidget.cpp @@ -135,6 +135,8 @@ Qt::CheckState ElementInfoPartWidget::EraseTextCheckState() const { void ElementInfoPartWidget::on_m_erase_text_clicked() { - ui->line_edit->setText(ui->m_erase_text->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->line_edit->setText(ui->m_erase_text->isChecked() + ? SearchAndReplaceWorker::eraseText() + : QString()); ui->line_edit->setDisabled(ui->m_erase_text->isChecked()); } diff --git a/sources/ui/elementpropertieswidget.cpp b/sources/ui/elementpropertieswidget.cpp index 1e8dd26af..8acc93de2 100644 --- a/sources/ui/elementpropertieswidget.cpp +++ b/sources/ui/elementpropertieswidget.cpp @@ -292,7 +292,7 @@ void ElementPropertiesWidget::updateUi() default: break; } - m_list_editor << new DynamicElementTextItemEditor(m_element, this); + m_list_editor << new DynamicElementTextItemEditor(m_element, this); //Add each editors in tab widget for (AbstractElementPropertiesEditorWidget *aepew : m_list_editor) @@ -376,7 +376,7 @@ QWidget *ElementPropertiesWidget::generalWidget() connect(find_in_panel, SIGNAL(clicked()), this, SLOT(findInPanel())); QPushButton *edit_element = new QPushButton(QET::Icons::ElementEdit, tr("Éditer l'élément"), general_widget); connect(edit_element, SIGNAL(clicked()), this, SLOT(editElement())); - QHBoxLayout *hlayout_ = new QHBoxLayout; + QHBoxLayout *hlayout_ = new QHBoxLayout; hlayout_->addWidget(find_in_panel); hlayout_->addWidget(edit_element); vlayout_->addLayout(hlayout_); diff --git a/sources/ui/inditextpropertieswidget.cpp b/sources/ui/inditextpropertieswidget.cpp index 8afb321ef..cc2213c56 100644 --- a/sources/ui/inditextpropertieswidget.cpp +++ b/sources/ui/inditextpropertieswidget.cpp @@ -427,7 +427,7 @@ void IndiTextPropertiesWidget::on_m_advanced_editor_pb_clicked() { void IndiTextPropertiesWidget::on_m_break_html_pb_clicked() { - if (m_text) { + if (m_text) { m_text->setPlainText(m_text->toPlainText()); } for (QPointer piti : m_text_list) { diff --git a/sources/ui/linksingleelementwidget.cpp b/sources/ui/linksingleelementwidget.cpp index f95e52a47..b70ae1189 100644 --- a/sources/ui/linksingleelementwidget.cpp +++ b/sources/ui/linksingleelementwidget.cpp @@ -33,7 +33,8 @@ @param parent the parent widget */ -LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) : +LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, + QWidget *parent) : AbstractElementPropertiesEditorWidget(parent), ui(new Ui::LinkSingleElementWidget) { @@ -46,8 +47,14 @@ LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) m_show_element = new QAction(tr("Montrer l'élément esclave"), this); m_save_header_state = new QAction(tr("Enregistrer la disposition"), this); - connect(m_show_qtwi, &QAction::triggered, [this]() {this->on_m_tree_widget_itemDoubleClicked(this->m_qtwi_at_context_menu, 0);}); - connect(m_link_action, &QAction::triggered, this, &LinkSingleElementWidget::linkTriggered); + connect(m_show_qtwi, + &QAction::triggered, + [this]() + {this->on_m_tree_widget_itemDoubleClicked(this->m_qtwi_at_context_menu, 0);}); + connect(m_link_action, + &QAction::triggered, + this, + &LinkSingleElementWidget::linkTriggered); connect(m_show_element, &QAction::triggered, [this]() { @@ -59,7 +66,10 @@ LinkSingleElementWidget::LinkSingleElementWidget(Element *elmt, QWidget *parent) QHeaderView *qhv = ui->m_tree_widget->header(); qhv->setContextMenuPolicy(Qt::CustomContextMenu); - connect(qhv, &QHeaderView::customContextMenuRequested, this, &LinkSingleElementWidget::headerCustomContextMenuRequested); + connect(qhv, + &QHeaderView::customContextMenuRequested, + this, + &LinkSingleElementWidget::headerCustomContextMenuRequested); connect(m_save_header_state, &QAction::triggered, [this, qhv]() { QByteArray qba = qhv->saveState(); @@ -105,8 +115,14 @@ void LinkSingleElementWidget::setElement(Element *element) //Remove connection of previous edited element if (m_element) { - disconnect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject); - disconnect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi); + disconnect(m_element->diagram()->project(), + &QETProject::diagramRemoved, + this, + &LinkSingleElementWidget::diagramWasRemovedFromProject); + disconnect(m_element.data(), + &Element::linkedElementChanged, + this, + &LinkSingleElementWidget::updateUi); m_element->setHighlighted(false); } @@ -124,12 +140,16 @@ void LinkSingleElementWidget::setElement(Element *element) if (m_element->linkType() & Element::Slave) m_filter = Element::Master; else if (m_element->linkType() & Element::AllReport) - m_filter = m_element->linkType() == Element::NextReport? Element::PreviousReport : Element::NextReport; + m_filter = m_element->linkType() == Element::NextReport + ? Element::PreviousReport + : Element::NextReport; else m_filter = Element::Simple; - connect(m_element->diagram()->project(), &QETProject::diagramRemoved, this, &LinkSingleElementWidget::diagramWasRemovedFromProject); - connect(m_element.data(), &Element::linkedElementChanged, this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection); + connect(m_element->diagram()->project(), &QETProject::diagramRemoved, + this, &LinkSingleElementWidget::diagramWasRemovedFromProject); + connect(m_element.data(), &Element::linkedElementChanged, + this, &LinkSingleElementWidget::updateUi, Qt::QueuedConnection); updateUi(); } @@ -234,7 +254,8 @@ void LinkSingleElementWidget::buildTree() if (settings.value("genericpanel/folio", false).toBool()) { autonum::sequentialNumbers seq; - QString F =autonum::AssignVariables::formulaToLabel(diag->border_and_titleblock.folio(), seq, diag, elmt); + QString F =autonum::AssignVariables::formulaToLabel( + diag->border_and_titleblock.folio(), seq, diag, elmt); str_list << F; } else @@ -415,11 +436,19 @@ void LinkSingleElementWidget::setUpHeaderLabels() { if (settings.value("genericpanel/folio", false).toBool()) { - list << tr("Label") << tr("Commentaire") << tr("Label de folio") << tr("Position") << tr("Titre de folio"); + list << tr("Label") + << tr("Commentaire") + << tr("Label de folio") + << tr("Position") + << tr("Titre de folio"); } else { - list << tr("Label") << tr("Commentaire") << tr("N° de folio") << tr("Position") << tr("Titre de folio"); + list << tr("Label") + << tr("Commentaire") + << tr("N° de folio") + << tr("Position") + << tr("Titre de folio"); } } @@ -427,11 +456,25 @@ void LinkSingleElementWidget::setUpHeaderLabels() { if (settings.value("genericpanel/folio", false).toBool()) { - list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << tr("Couleur du conducteur") << tr("Section du conducteur") << tr("Label de folio") << tr("Position") << tr("Titre de folio"); + list << tr("N° de fil") + << tr("Fonction") + << tr("Tension / Protocole") + << tr("Couleur du conducteur") + << tr("Section du conducteur") + << tr("Label de folio") + << tr("Position") + << tr("Titre de folio"); } else { - list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << tr("Couleur du conducteur") << tr("Section du conducteur") << tr("N° de folio") << tr("Position") << tr("Titre de folio"); + list << tr("N° de fil") + << tr("Fonction") + << tr("Tension / Protocole") + << tr("Couleur du conducteur") + << tr("Section du conducteur") + << tr("N° de folio") + << tr("Position") + << tr("Titre de folio"); } } @@ -440,13 +483,16 @@ void LinkSingleElementWidget::setUpHeaderLabels() /** @brief LinkSingleElementWidget::diagramWasRemovedFromProject - * This slot is called when a diagram is removed from the parent project of edited element + This slot is called when a diagram + is removed from the parent project of edited element to update the content of this widget */ void LinkSingleElementWidget::diagramWasRemovedFromProject() { - //We use a timer because if the removed diagram contain the master element linked to the edited element - //we must to wait for this elements be unlinked, else the list of available master isn't up to date + // We use a timer because if the removed diagram + // contain the master element linked to the edited element + // we must to wait for this elements be unlinked, + // else the list of available master isn't up to date QTimer::singleShot(10, this, SLOT(updateUi())); } @@ -473,19 +519,25 @@ void LinkSingleElementWidget::linkTriggered() } else { - //In no live edit mode, we set the background of the qtwi green, to inform the user - //which element will be linked when he press the apply button + //In no live edit mode, we set the background of the qtwi green, + // to inform the user + // which element will be linked when he press the apply button if (m_pending_qtwi) { for(int i=0 ; i<6 ; i++) { - m_pending_qtwi->setBackground(i,QBrush(Qt::white, Qt::NoBrush)); + m_pending_qtwi->setBackground(i, + QBrush( + Qt::white, + Qt::NoBrush)); } } for (int i=0 ; i<6 ; i++) { - m_qtwi_at_context_menu->setBackground(i,QBrush(Qt::green,Qt::SolidPattern)); + m_qtwi_at_context_menu->setBackground(i, + QBrush(Qt::green, + Qt::SolidPattern)); } m_pending_qtwi = m_qtwi_at_context_menu; } @@ -518,7 +570,8 @@ void LinkSingleElementWidget::showButtons() ui->m_search_field->hide(); } -void LinkSingleElementWidget::headerCustomContextMenuRequested(const QPoint &pos) +void LinkSingleElementWidget::headerCustomContextMenuRequested( + const QPoint &pos) { m_context_menu->clear(); m_context_menu->addAction(m_save_header_state); @@ -544,13 +597,16 @@ void LinkSingleElementWidget::on_m_unlink_pb_clicked() @param item @param column */ -void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem *item, int column) +void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked( + QTreeWidgetItem *item, + int column) { Q_UNUSED(column); if (m_showed_element) { - disconnect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted())); + disconnect(m_showed_element, SIGNAL(destroyed()), + this, SLOT(showedElementWasDeleted())); m_showed_element->setHighlighted(false); } @@ -558,14 +614,18 @@ void LinkSingleElementWidget::on_m_tree_widget_itemDoubleClicked(QTreeWidgetItem elmt->diagram()->showMe(); elmt->setHighlighted(true); m_showed_element = elmt; - connect(m_showed_element, SIGNAL(destroyed()), this, SLOT(showedElementWasDeleted())); + connect(m_showed_element, SIGNAL(destroyed()), + this, SLOT(showedElementWasDeleted())); } -void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested(const QPoint &pos) +void LinkSingleElementWidget::on_m_tree_widget_customContextMenuRequested( + const QPoint &pos) { - //add the size of the header to display the topleft of the QMenu at the position of the mouse. - //See doc about QWidget::customContextMenuRequested section related to QAbstractScrollArea + //add the size of the header to display the topleft of the QMenu + //at the position of the mouse. + //See doc about QWidget::customContextMenuRequested + //section related to QAbstractScrollArea QPoint point = pos; point.ry()+=ui->m_tree_widget->header()->height(); point = ui->m_tree_widget->mapToGlobal(point); @@ -600,8 +660,9 @@ void LinkSingleElementWidget::on_m_show_this_pb_clicked() /** @brief LinkSingleElementWidget::on_m_search_field_textEdited - Search all items which match with @arg1 and shows it, other items is hidden. - If @arg1 is empty, show all items. + Search all items which match with arg1 and shows it, + other items is hidden. + If arg1 is empty, show all items. @param arg1 */ void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1) diff --git a/sources/ui/marginseditdialog.cpp b/sources/ui/marginseditdialog.cpp index d9e3660b8..ab64241ef 100644 --- a/sources/ui/marginseditdialog.cpp +++ b/sources/ui/marginseditdialog.cpp @@ -21,10 +21,10 @@ #include MarginsEditDialog::MarginsEditDialog(QMargins margins, QWidget *parent) : - QDialog(parent), - ui(new Ui::MarginsEditDialog) + QDialog(parent), + ui(new Ui::MarginsEditDialog) { - ui->setupUi(this); + ui->setupUi(this); ui->m_top_sb->setValue(margins.top()); ui->m_left_sb->setValue(margins.left()); ui->m_right_sb->setValue(margins.right()); @@ -37,7 +37,10 @@ MarginsEditDialog::~MarginsEditDialog() } QMargins MarginsEditDialog::margins() const { - return QMargins(ui->m_left_sb->value(), ui->m_top_sb->value(), ui->m_right_sb->value(), ui->m_bottom_sb->value()); + return QMargins(ui->m_left_sb->value(), + ui->m_top_sb->value(), + ui->m_right_sb->value(), + ui->m_bottom_sb->value()); } /** @@ -45,11 +48,15 @@ QMargins MarginsEditDialog::margins() const { @param margins : margins to set by default @param accepted : bool to know if dialog is accepted @param parent : parent widget. - @return The a margins with the edited value if dialog is accepted or a default constructed QMargins() if dialog is rejected + @return The a margins with the edited value if dialog is accepted + or a default constructed QMargins() if dialog is rejected */ -QMargins MarginsEditDialog::getMargins(QMargins margins, bool *accepted, QWidget *parent) +QMargins MarginsEditDialog::getMargins(QMargins margins, + bool *accepted, + QWidget *parent) { - QScopedPointer d(new MarginsEditDialog(margins, parent)); + QScopedPointer d( + new MarginsEditDialog(margins, parent)); if (d->exec()) { if (accepted) { diff --git a/sources/ui/marginseditdialog.h b/sources/ui/marginseditdialog.h index dc4e82409..31bc27fa3 100644 --- a/sources/ui/marginseditdialog.h +++ b/sources/ui/marginseditdialog.h @@ -31,18 +31,21 @@ class MarginsEditDialog; */ class MarginsEditDialog : public QDialog { - Q_OBJECT + Q_OBJECT - public: - explicit MarginsEditDialog(QMargins margins = QMargins(), QWidget *parent = nullptr); - ~MarginsEditDialog(); + public: + explicit MarginsEditDialog(QMargins margins = QMargins(), + QWidget *parent = nullptr); + ~MarginsEditDialog(); QMargins margins() const; - static QMargins getMargins(QMargins margins = QMargins(), bool *accepted = nullptr, QWidget *parent = nullptr); + static QMargins getMargins(QMargins margins = QMargins(), + bool *accepted = nullptr, + QWidget *parent = nullptr); - private: - Ui::MarginsEditDialog *ui; + private: + Ui::MarginsEditDialog *ui; }; #endif // MARGINSEDITDIALOG_H diff --git a/sources/ui/multipastedialog.cpp b/sources/ui/multipastedialog.cpp index 7370f40d7..9f66a0519 100644 --- a/sources/ui/multipastedialog.cpp +++ b/sources/ui/multipastedialog.cpp @@ -93,7 +93,7 @@ void MultiPasteDialog::updatePreview() void MultiPasteDialog::on_m_button_box_accepted() { - if(m_pasted_content.count()) + if(m_pasted_content.count()) { m_diagram->undoStack().beginMacro(tr("Multi-collage")); diff --git a/sources/ui/potentialselectordialog.cpp b/sources/ui/potentialselectordialog.cpp index c047477c1..b3263e9cd 100644 --- a/sources/ui/potentialselectordialog.cpp +++ b/sources/ui/potentialselectordialog.cpp @@ -221,7 +221,9 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QListm_conductor_number_1)); + QString text1(tr("%n conducteurs composent le potentiel suivant :", + "", + m_potential_selector->m_conductor_number_1)); ConductorProperties cp1; if(!m_potential_selector->m_properties_list_1.isEmpty()) @@ -275,13 +282,18 @@ void PotentialSelectorDialog::buildWidget() if(!cp1.m_function.isEmpty()) text1.append(tr("\nFonction : %1").arg(cp1.m_function)); if(!cp1.m_tension_protocol.isEmpty()) - text1.append(tr("\nTension/protocole : %1").arg(cp1.m_tension_protocol)); + text1.append(tr("\nTension/protocole : %1") + .arg(cp1.m_tension_protocol)); if(!cp1.m_wire_color.isEmpty()) - text1.append(tr("\nCouleur du conducteur : %1").arg(cp1.m_wire_color)); + text1.append(tr("\nCouleur du conducteur : %1") + .arg(cp1.m_wire_color)); if(!cp1.m_wire_section.isEmpty()) - text1.append(tr("\nSection du conducteur : %1").arg(cp1.m_wire_section)); + text1.append(tr("\nSection du conducteur : %1") + .arg(cp1.m_wire_section)); - QString text2(tr("%n conducteurs composent le potentiel suivant :", "", m_potential_selector->m_conductor_number_2)); + QString text2(tr("%n conducteurs composent le potentiel suivant :", + "", + m_potential_selector->m_conductor_number_2)); ConductorProperties cp2; if(!m_potential_selector->m_properties_list_2.isEmpty()) cp2 = m_potential_selector->m_properties_list_2.first(); @@ -291,11 +303,14 @@ void PotentialSelectorDialog::buildWidget() if(!cp2.m_function.isEmpty()) text2.append(tr("\nFonction : %1").arg(cp2.m_function)); if(!cp2.m_tension_protocol.isEmpty()) - text2.append(tr("\nTension/protocole : %1").arg(cp2.m_tension_protocol)); + text2.append(tr("\nTension/protocole : %1") + .arg(cp2.m_tension_protocol)); if(!cp2.m_wire_color.isEmpty()) - text2.append(tr("\nCouleur du conducteur : %1").arg(cp2.m_wire_color)); + text2.append(tr("\nCouleur du conducteur : %1") + .arg(cp2.m_wire_color)); if(!cp2.m_wire_section.isEmpty()) - text2.append(tr("\nSection du conducteur : %1").arg(cp2.m_wire_section)); + text2.append(tr("\nSection du conducteur : %1") + .arg(cp2.m_wire_section)); QRadioButton *rb1 = new QRadioButton(text1, this); QRadioButton *rb2 = new QRadioButton(text2, this); @@ -304,24 +319,35 @@ void PotentialSelectorDialog::buildWidget() { if(t) { - this->m_sequential_num = this->m_potential_selector->m_seq_num_1; - this->m_properties_list = this->m_potential_selector->m_properties_list_1; - this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_2; + this->m_sequential_num = + this->m_potential_selector->m_seq_num_1; + this->m_properties_list = + this->m_potential_selector + ->m_properties_list_1; + this->m_conductors_to_change = + this->m_potential_selector + ->m_conductors_list_2; } }); connect(rb2, &QRadioButton::toggled, [this](bool t) { if(t) { - this->m_sequential_num = this->m_potential_selector->m_seq_num_2; - this->m_properties_list = this->m_potential_selector->m_properties_list_2; - this->m_conductors_to_change = this->m_potential_selector->m_conductors_list_1; + this->m_sequential_num = + this->m_potential_selector->m_seq_num_2; + this->m_properties_list = + this->m_potential_selector + ->m_properties_list_2; + this->m_conductors_to_change = + this->m_potential_selector + ->m_conductors_list_1; } }); - //Set the radio button of potential with the bigger number of conductors, - //at first position, and check it - if (m_potential_selector->m_conductor_number_1 >= m_potential_selector->m_conductor_number_2) + //Set the radio button of potential with the bigger number of conductors, + //at first position, and check it + if (m_potential_selector->m_conductor_number_1 >= + m_potential_selector->m_conductor_number_2) { ui->verticalLayout->insertWidget(1, rb1); ui->verticalLayout->insertWidget(2, rb2); @@ -348,13 +374,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted() if (m_parent_undo) undo = m_parent_undo; else - undo = new QUndoCommand(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption")); + undo = new QUndoCommand( + tr("Modifier les propriétés de plusieurs conducteurs", + "undo caption")); Diagram * diagram = nullptr; if (m_report) { - if ((m_report->linkType() & Element::AllReport) && !m_report->isFree()) + if ((m_report->linkType() & Element::AllReport) + && !m_report->isFree()) { if (m_report->diagram()) diagram = m_report->diagram(); @@ -363,7 +392,7 @@ void PotentialSelectorDialog::on_buttonBox_accepted() QVariant old_seq, new_seq; new_seq.setValue(m_sequential_num); - //Set the new properties for each conductors of the new potential + //Set the new properties for each conductors of the new potential foreach(Conductor *cond, m_conductors_to_change) { ConductorProperties new_properties = cond->properties(); @@ -371,18 +400,33 @@ void PotentialSelectorDialog::on_buttonBox_accepted() old_value.setValue(cond->properties()); new_value.setValue(new_properties); old_seq.setValue(cond->sequenceNum()); - new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo); - new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); + new QPropertyUndoCommand(cond, + "sequenceNum", + old_seq, + new_seq, + undo); + new QPropertyUndoCommand(cond, + "properties", + old_value, + new_value, + undo); } - //Check if formula of the new potential have incompatible variable with folio report + //Check if formula of the new potential + // have incompatible variable with folio report QRegularExpression rx ("%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM"); foreach(ConductorProperties cp, m_properties_list) { if (cp.m_formula.contains(rx)) { QStringList forbidden_str; - forbidden_str << "%sequf_" << "%seqtf_" << "%seqhf_" << "%id" << "%F" << "%M" << "%LM"; + forbidden_str << "%sequf_" + << "%seqtf_" + << "%seqhf_" + << "%id" + << "%F" + << "%M" + << "%LM"; QString text(tr("La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n" "Veuillez saisir une formule compatible pour ce potentiel.\n" @@ -403,7 +447,11 @@ void PotentialSelectorDialog::on_buttonBox_accepted() ConductorProperties new_properties = cond->properties(); new_properties.m_formula = new_formula; new_value.setValue(new_properties); - new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); + new QPropertyUndoCommand(cond, + "properties", + old_value, + new_value, + undo); } break; @@ -428,8 +476,16 @@ void PotentialSelectorDialog::on_buttonBox_accepted() old_seq.setValue(m_conductor->sequenceNum()); new_seq.setValue(m_sequential_num); - new QPropertyUndoCommand(m_conductor, "sequenceNum", old_seq, new_seq, undo); - new QPropertyUndoCommand(m_conductor, "properties", old_value, new_value, undo); + new QPropertyUndoCommand(m_conductor, + "sequenceNum", + old_seq, + new_seq, + undo); + new QPropertyUndoCommand(m_conductor, + "properties", + old_value, + new_value, + undo); //Set the new properties for each conductors of the new potential foreach(Conductor *cond, m_conductor->relatedPotentialConductors()) @@ -439,15 +495,24 @@ void PotentialSelectorDialog::on_buttonBox_accepted() old_value.setValue(cond->properties()); new_value.setValue(new_properties); old_seq.setValue(cond->sequenceNum()); - new QPropertyUndoCommand(cond, "sequenceNum", old_seq, new_seq, undo); - new QPropertyUndoCommand(cond, "properties", old_value, new_value, undo); + new QPropertyUndoCommand(cond, + "sequenceNum", + old_seq, + new_seq, + undo); + new QPropertyUndoCommand(cond, + "properties", + old_value, + new_value, + undo); } } - //There is an undo parent, we stop here, the owner of m_parent_undo will push it to an undo stack + //There is an undo parent, we stop here, + //the owner of m_parent_undo will push it to an undo stack if (m_parent_undo) return; - //There isn't a parent, we push the undo command to diagram undo stack. + //There isn't a parent, we push the undo command to diagram undo stack. if (diagram) diagram->undoStack().push(undo); } diff --git a/sources/ui/potentialselectordialog.h b/sources/ui/potentialselectordialog.h index 9794674d3..2638d625d 100644 --- a/sources/ui/potentialselectordialog.h +++ b/sources/ui/potentialselectordialog.h @@ -28,13 +28,16 @@ class Element; class AbstractPotentialSelector { public: - AbstractPotentialSelector() : m_conductor_number_1(0), m_conductor_number_2(0) {} + AbstractPotentialSelector() + : m_conductor_number_1(0) + , m_conductor_number_2(0) {} virtual ~AbstractPotentialSelector() {} virtual bool isValid() const = 0; autonum::sequentialNumbers m_seq_num_1, m_seq_num_2; int m_conductor_number_1, m_conductor_number_2; - QList m_properties_list_1, m_properties_list_2; + QList m_properties_list_1, + m_properties_list_2; QList m_conductors_list_1, m_conductors_list_2; }; @@ -44,41 +47,54 @@ namespace Ui { /** @brief The PotentialSelectorDialog class - This dialog is used when user try to connect two existing potential together. - The dialog ask to user to make a choice between the properties of the two existing potential, + This dialog is used when user try to connect + two existing potential together. + The dialog ask to user to make a choice between + the properties of the two existing potential, to apply it for the new potential. - * + Each constructor have a QUndoCommand @parent_undo for parameter - If @parent_undo isn't null, when user click on OK button, the dialog will use the parent-undo + If @parent_undo isn't null, when user click on OK button, + the dialog will use the parent-undo as parent of the undo command that describe the changes. - If @parent_undo is null, the created undo-command is push to the undo stack of the parent diagram of a conductor in potential. + If parent_undo is null, the created undo-command is push + to the undo stack of the parent diagram of a conductor in potential. else we apply the change without a QUndoCommand. - the static function chosenProperties, open a dialog who ask user to make a choice between the given + the static function chosenProperties, + open a dialog who ask user to make a choice between the given properties */ class PotentialSelectorDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: - static ConductorProperties chosenProperties(QList list, QWidget *parent = nullptr); + static ConductorProperties chosenProperties( + QList list, + QWidget *parent = nullptr); - public: - explicit PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr); - explicit PotentialSelectorDialog(Element *report, QUndoCommand *parent_undo = nullptr, QWidget *parent = nullptr); - ~PotentialSelectorDialog() override; + public: + explicit PotentialSelectorDialog( + Conductor *conductor, + QUndoCommand *parent_undo = nullptr, + QWidget *parent = nullptr); + explicit PotentialSelectorDialog( + Element *report, + QUndoCommand *parent_undo = nullptr, + QWidget *parent = nullptr); + ~PotentialSelectorDialog() override; private slots: void on_buttonBox_accepted(); private: - void buildWidget(); + void buildWidget(); - private: - Ui::PotentialSelectorDialog *ui; - Conductor *m_conductor; + private: + Ui::PotentialSelectorDialog *ui; + Conductor *m_conductor; Element *m_report; QUndoCommand *m_parent_undo; autonum::sequentialNumbers m_sequential_num; diff --git a/sources/ui/projectpropertiesdialog.cpp b/sources/ui/projectpropertiesdialog.cpp index 866f14358..fd9fa7c45 100644 --- a/sources/ui/projectpropertiesdialog.cpp +++ b/sources/ui/projectpropertiesdialog.cpp @@ -28,18 +28,17 @@ @param parent : parent widget of this dialog */ ProjectPropertiesDialog::ProjectPropertiesDialog(QETProject *project, QWidget *parent) { - NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this); - ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project); + NewDiagramPage *newDiagramPage = new NewDiagramPage(project,parent,this); + ProjectAutoNumConfigPage *projectAutoNumConfigPage = new ProjectAutoNumConfigPage (project); m_properties_dialog = new ConfigDialog (parent); m_properties_dialog -> setWindowTitle(QObject::tr("Propriétés du projet", "window title")); m_properties_dialog -> addPage(new ProjectMainConfigPage (project)); - m_properties_dialog -> addPage(newDiagramPage); - m_properties_dialog -> addPage(projectAutoNumConfigPage); - connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString))); - connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp())); - connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp())); + m_properties_dialog -> addPage(newDiagramPage); + m_properties_dialog -> addPage(projectAutoNumConfigPage); + connect(projectAutoNumConfigPage,SIGNAL(setAutoNum(QString)),newDiagramPage,SLOT(setFolioAutonum(QString))); + connect(projectAutoNumConfigPage,SIGNAL(saveCurrentTbp()),newDiagramPage,SLOT(saveCurrentTbp())); + connect(projectAutoNumConfigPage,SIGNAL(loadSavedTbp()),newDiagramPage,SLOT(loadSavedTbp())); m_properties_dialog->setMinimumHeight(690); - } /** @@ -72,6 +71,8 @@ void ProjectPropertiesDialog::setCurrentPage(ProjectPropertiesDialog::Page p) { Change the current displayed tab to folio tab. */ void ProjectPropertiesDialog::changeToFolio() { - ProjectAutoNumConfigPage *autoNumPage = static_cast (m_properties_dialog->pages.at(2)); + ProjectAutoNumConfigPage *autoNumPage = + static_cast ( + m_properties_dialog->pages.at(2)); autoNumPage->changeToTab(3); } diff --git a/sources/ui/projectpropertiesdialog.h b/sources/ui/projectpropertiesdialog.h index 90d7d8e90..14ee66f98 100644 --- a/sources/ui/projectpropertiesdialog.h +++ b/sources/ui/projectpropertiesdialog.h @@ -39,7 +39,7 @@ class ProjectPropertiesDialog : public QObject { ~ProjectPropertiesDialog() override; void exec(); void setCurrentPage(ProjectPropertiesDialog::Page); - void changeToFolio(); + void changeToFolio(); private: ConfigDialog *m_properties_dialog; diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index da3164c2f..2e0159d91 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -427,7 +427,7 @@ void TitleBlockPropertiesWidget::on_m_date_now_pb_clicked() { Open Auto Folio Num dialog */ void TitleBlockPropertiesWidget::on_m_edit_autofolionum_pb_clicked() { - emit openAutoNumFolioEditor(ui->auto_page_cb->currentText()); + emit openAutoNumFolioEditor(ui->auto_page_cb->currentText()); if (ui->auto_page_cb->currentText()!=tr("Créer un Folio Numérotation Auto")) { //still to implement: load current auto folio num settings diff --git a/sources/ui/xrefpropertieswidget.cpp b/sources/ui/xrefpropertieswidget.cpp index c0dc80330..1d6dd434a 100644 --- a/sources/ui/xrefpropertieswidget.cpp +++ b/sources/ui/xrefpropertieswidget.cpp @@ -58,7 +58,8 @@ XRefPropertiesWidget::~XRefPropertiesWidget() set new properties for this widget @param properties */ -void XRefPropertiesWidget::setProperties(const QHash &properties) { +void XRefPropertiesWidget::setProperties(const QHash &properties) { m_properties = properties; updateDisplay(); m_previous_type_index = ui->m_type_cb->currentIndex(); @@ -94,18 +95,18 @@ void XRefPropertiesWidget::setReadOnly(bool ro) { */ void XRefPropertiesWidget::buildUi() { - ui -> m_type_cb -> addItem(tr("Bobine"), "coil"); + ui -> m_type_cb -> addItem(tr("Bobine"), "coil"); ui -> m_type_cb -> addItem(tr("Organe de protection"), "protection"); ui -> m_type_cb -> addItem(tr("Commutateur / bouton"), "commutator"); - ui -> m_snap_to_cb -> addItem(tr("En bas de page"), "bottom"); + ui -> m_snap_to_cb -> addItem(tr("En bas de page"), "bottom"); ui -> m_snap_to_cb -> addItem(tr("Sous le label de l'élément"), "label"); ui -> m_xrefpos_cb -> addItem(tr("Top"),"top"); ui -> m_xrefpos_cb -> addItem(tr("Bottom"),"bottom"); ui -> m_xrefpos_cb -> addItem(tr("Left"),"left"); ui -> m_xrefpos_cb -> addItem(tr("Rigth"),"right"); - ui -> m_xrefpos_cb -> addItem(tr("Text alignment"),"alignment"); + ui -> m_xrefpos_cb -> addItem(tr("Text alignment"),"alignment"); m_previous_type_index = ui -> m_type_cb -> currentIndex(); } @@ -118,11 +119,16 @@ void XRefPropertiesWidget::saveProperties(int index) { QString type = ui->m_type_cb->itemData(index).toString(); XRefProperties xrp = m_properties[type]; - if (ui->m_display_has_cross_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Cross); - else if (ui->m_display_has_contacts_rb->isChecked()) xrp.setDisplayHas(XRefProperties::Contacts); - if (ui->m_snap_to_cb->itemData(ui->m_snap_to_cb->currentIndex()).toString() == "bottom") - xrp.setSnapTo(XRefProperties::Bottom); - else xrp.setSnapTo(XRefProperties::Label); + if (ui->m_display_has_cross_rb->isChecked()) + xrp.setDisplayHas(XRefProperties::Cross); + else if (ui->m_display_has_contacts_rb->isChecked()) + xrp.setDisplayHas(XRefProperties::Contacts); + if (ui->m_snap_to_cb->itemData( + ui->m_snap_to_cb->currentIndex()).toString() + == "bottom") + xrp.setSnapTo(XRefProperties::Bottom); + else + xrp.setSnapTo(XRefProperties::Label);