diff --git a/sources/SearchAndReplace/searchandreplaceworker.cpp b/sources/SearchAndReplace/searchandreplaceworker.cpp index cd0e36c13..75c4d1508 100644 --- a/sources/SearchAndReplace/searchandreplaceworker.cpp +++ b/sources/SearchAndReplace/searchandreplaceworker.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright 2006-2018 The QElectroTech Team This file is part of QElectroTech. @@ -23,18 +23,12 @@ #include "qetapp.h" #include "independenttextitem.h" #include "diagramcommands.h" +#include "QPropertyUndoCommand/qpropertyundocommand.h" SearchAndReplaceWorker::SearchAndReplaceWorker() -{} - -/** - * @brief SearchAndReplaceWorker::clear - * All registred properties - */ -void SearchAndReplaceWorker::clear() { - m_titleblock_properties = TitleBlockProperties(); + m_conductor_properties = invalidConductorProperties(); } /** @@ -168,7 +162,7 @@ void SearchAndReplaceWorker::replaceElement(QList list) } } - project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer les propriétés d'éléments")); + project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer les propriétés d'éléments.")); for (Element *elmt : list) { //We apply change only for master, slave, and terminal element. @@ -244,3 +238,134 @@ void SearchAndReplaceWorker::replaceIndiText(IndependentTextItem *text) list.append(text); replaceIndiText(list); } + +/** + * @brief SearchAndReplaceWorker::replaceConductor + * Replace all properties of each conductor in @list + * All conductor must belong to the same project, if not this function do nothing. + * All change are made through a undo command append to undo list of the project. + * @param list + */ +void SearchAndReplaceWorker::replaceConductor(QList list) +{ + if (list.isEmpty() || !list.first()->diagram()) { + return; + } + + QETProject *project_ = list.first()->diagram()->project(); + for (Conductor *c : list) { + if (!c->diagram() || + c->diagram()->project() != project_) { + return; + } + } + + project_->undoStack()->beginMacro(QObject::tr("Chercher/remplacer les propriétés de conducteurs.")); + for (Conductor *c : list) + { + ConductorProperties cp = applyChange(c->properties(), m_conductor_properties); + + if (cp != c->properties()) + { + QSet conductors_list = c->relatedPotentialConductors(true); + conductors_list << c; + for (Conductor *cc : conductors_list) + { + QVariant old_value, new_value; + old_value.setValue(cc->properties()); + new_value.setValue(cp); + project_->undoStack()->push(new QPropertyUndoCommand(cc, "properties", old_value, new_value)); + } + } + } + project_->undoStack()->endMacro(); +} + +void SearchAndReplaceWorker::replaceConductor(Conductor *conductor) +{ + QListlist; + list.append(conductor); + replaceConductor(list); +} + +/** + * @brief SearchAndReplaceWorker::setupLineEdit + * With search and replace, when the variable to edit is a text, + * the editor is always the same no matter if it is for a folio, element or conductor. + * The editor is a QLineEdit to edit the text and checkbox to erase the text if checked. + * This function fill the editor + * @param l + * @param cb + * @param str + */ +void SearchAndReplaceWorker::setupLineEdit(QLineEdit *l, QCheckBox *cb, QString str) +{ + l->setText(str); + cb->setChecked(str == eraseText() ? true : false); +} + +ConductorProperties SearchAndReplaceWorker::invalidConductorProperties() +{ + ConductorProperties cp; + + //init with invalid value the conductor properties + cp.text_size = 0; + cp.text.clear(); + cp.m_vertical_alignment = Qt::AlignAbsolute; + cp.m_horizontal_alignment = Qt::AlignAbsolute; + cp.verti_rotate_text = -1; + cp.horiz_rotate_text = -1; + cp.color = QColor(); + cp.style = Qt::NoPen; + cp.cond_size = 0; + cp.m_color_2 = QColor(); + cp.m_dash_size = 0; + + return cp; +} + +/** + * @brief SearchAndReplaceWorker::applyChange + * @param original : the original properties + * @param change : the change properties, to be merged with @original + * @return a new conductor properties with the change applyed. + */ +ConductorProperties SearchAndReplaceWorker::applyChange(const ConductorProperties &original, const ConductorProperties &change) +{ + ConductorProperties new_properties = original; + + if (change.text_size > 2) {new_properties.text_size = change.text_size;} + new_properties.m_formula = applyChange(new_properties.m_formula, change.m_formula); + new_properties.text = applyChange(new_properties.text, change.text); + new_properties.m_show_text = change.m_show_text; + new_properties.m_function = applyChange(new_properties.m_function, change.m_function); + new_properties.m_tension_protocol = applyChange(new_properties.m_tension_protocol, change.m_tension_protocol); + if(change.m_vertical_alignment == Qt::AlignLeft || + change.m_vertical_alignment == Qt::AlignRight) {new_properties.m_vertical_alignment = change.m_vertical_alignment;} + if(change.m_horizontal_alignment == Qt::AlignTop || + change.m_horizontal_alignment == Qt::AlignBottom) {new_properties.m_horizontal_alignment = change.m_horizontal_alignment;} + if (change.verti_rotate_text >= 0) {new_properties.verti_rotate_text = change.verti_rotate_text;} + if (change.horiz_rotate_text >= 0) {new_properties.horiz_rotate_text = change.horiz_rotate_text;} + if (change.color.isValid()) {new_properties.color = change.color;} + if (change.style != Qt::NoPen) {new_properties.style = change.style;} + if (change.cond_size >= 0.4) {new_properties.cond_size = change.cond_size;} + new_properties.m_bicolor = change.m_bicolor; + if (change.m_color_2.isValid()) {new_properties.m_color_2 = change.m_color_2;} + if (change.m_dash_size >= 2) {new_properties.m_dash_size = change.m_dash_size;} + new_properties.singleLineProperties = change.singleLineProperties; + + return new_properties; +} + +/** + * @brief SearchAndReplaceWorker::applyChange + * @param original : the original string + * @param change : the changed string: + * @return the string to be use in the properties + */ +QString SearchAndReplaceWorker::applyChange(const QString &original, const QString &change) +{ + if (change.isEmpty()) {return original;} + else if (change == eraseText()) {return QString();} + else {return change;} +} diff --git a/sources/SearchAndReplace/searchandreplaceworker.h b/sources/SearchAndReplace/searchandreplaceworker.h index 5154fcc44..99400e988 100644 --- a/sources/SearchAndReplace/searchandreplaceworker.h +++ b/sources/SearchAndReplace/searchandreplaceworker.h @@ -21,10 +21,14 @@ #include #include "titleblockproperties.h" +#include "conductorproperties.h" class Diagram; class Element; class IndependentTextItem; +class Conductor; +class QLineEdit; +class QCheckBox; /** * @brief The SearchAndReplaceWorker class @@ -35,21 +39,28 @@ class SearchAndReplaceWorker public: SearchAndReplaceWorker(); - void clear(); void replaceDiagram(QList diagram_list); void replaceDiagram(Diagram *diagram); void replaceElement(QList list); void replaceElement(Element *element); void replaceIndiText(QList list); void replaceIndiText(IndependentTextItem *text); + void replaceConductor(QList list); + void replaceConductor(Conductor *conductor); static QString eraseText() {return QString("XXXXXXXXXXXXXXXXXXX");} static QDate eraseDate() {return QDate(1900, 1, 1);} + static void setupLineEdit(QLineEdit *l, QCheckBox *cb, QString str); + static ConductorProperties invalidConductorProperties(); + + static ConductorProperties applyChange(const ConductorProperties &original, const ConductorProperties &change); + static QString applyChange(const QString &original, const QString &change); private: TitleBlockProperties m_titleblock_properties; DiagramContext m_element_context; QString m_indi_text; + ConductorProperties m_conductor_properties; friend class SearchAndReplaceWidget; }; diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.cpp b/sources/SearchAndReplace/ui/replaceconductordialog.cpp new file mode 100644 index 000000000..6b1f17992 --- /dev/null +++ b/sources/SearchAndReplace/ui/replaceconductordialog.cpp @@ -0,0 +1,266 @@ +/* + Copyright 2006-2018 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#include "replaceconductordialog.h" +#include "ui_replaceconductordialog.h" +#include "searchandreplaceworker.h" + +#include +#include + +typedef SearchAndReplaceWorker sarw; + +/** + * @brief ReplaceConductorDialog::ReplaceConductorDialog + * @param parent + */ +ReplaceConductorDialog::ReplaceConductorDialog(const ConductorProperties &properties, QWidget *parent) : + QDialog(parent), + ui(new Ui::ReplaceConductorDialog) +{ + ui->setupUi(this); + initWidget(); + setProperties(properties); +} + +ReplaceConductorDialog::~ReplaceConductorDialog() +{ + delete ui; +} + +/** + * @brief ReplaceConductorDialog::updatePreview + * Update the preview for single line + * @param b true: update from the value displayed by this widget + * false: update from the properties given at the constructor of this widget + */ +void ReplaceConductorDialog::updatePreview(bool b) +{ + const QRect pixmap_rect(0, 0, 96, 96); + QPixmap pixmap(pixmap_rect.width(), pixmap_rect.height()); + QPainter painter; + painter.begin(&pixmap); + painter.eraseRect(pixmap_rect); + painter.drawRect(pixmap_rect.adjusted(0,0,-1,-1)); + painter.drawLine(QLineF(0, pixmap_rect.height() / 2, pixmap_rect.width(), pixmap_rect.height() / 2)); + + if (b) { + properties().singleLineProperties.draw(&painter, QET::Horizontal, pixmap_rect); + } else { + m_properties.singleLineProperties.draw(&painter, QET::Horizontal, pixmap_rect); + } + + painter.end(); + ui -> m_preview_label -> setPixmap(pixmap); +} + +void ReplaceConductorDialog::setProperties(const ConductorProperties &properties) +{ + m_properties = properties; + + if (m_properties.type == ConductorProperties::Single) { + ui->m_singlewire_gb->setChecked(true); + } else { + ui->m_multi_gb->setChecked(true); + } + ui->m_text_size_sb->setValue(m_properties.text_size); + ui->m_show_text->setChecked(m_properties.m_show_text); + sarw::setupLineEdit(ui->m_formula_le, ui->m_erase_formula_cb, m_properties.m_formula); + sarw::setupLineEdit(ui->m_text_le, ui->m_erase_text_cb, m_properties.text); + sarw::setupLineEdit(ui->m_function_le, ui->m_erase_function_cb, m_properties.m_function); + sarw::setupLineEdit(ui->m_tension_protocol_le, ui->m_erase_tension_protocol_cb, m_properties.m_tension_protocol); + switch (m_properties.m_vertical_alignment) { + case Qt::AlignLeft: ui->m_vertical_align_cb->setCurrentIndex(1);break; + case Qt::AlignRight: ui->m_vertical_align_cb->setCurrentIndex(2);break; + default: ui->m_vertical_align_cb->setCurrentIndex(0); break; + } + switch (m_properties.m_horizontal_alignment) { + case Qt::AlignTop: ui->m_horizontal_align_cb->setCurrentIndex(1); break; + case Qt::AlignBottom: ui->m_horizontal_align_cb->setCurrentIndex(2); break; + default: ui->m_horizontal_align_cb->setCurrentIndex(0); break; + } + ui->m_vertical_angle_sb->setValue(m_properties.verti_rotate_text); + ui->m_horizontal_angle_sb->setValue(m_properties.horiz_rotate_text); + if (m_properties.color.isValid()) + { + setColorButton(m_properties.color); + ui->m_mod_color_cb->setChecked(true); + } + int index = ui->m_line_style_cb->findData(QPen(m_properties.style)); + if (index != -1) { + ui->m_line_style_cb->setCurrentIndex(index); + } + ui->m_second_color_gb->setChecked(m_properties.m_bicolor); + if (m_properties.m_color_2.isValid()) + { + setColorButton2(m_properties.m_color_2); + ui->m_mod_color_2_cb->setChecked(true); + } + ui->m_color_2_dash_size_sb->setValue(m_properties.m_dash_size); + + ui->m_earth_cb ->setChecked (m_properties.singleLineProperties.hasGround); + ui->m_neutral_cb ->setChecked (m_properties.singleLineProperties.hasNeutral); + ui->m_pen_cb ->setChecked (m_properties.singleLineProperties.isPen()); + ui->m_phase_cb ->setChecked (m_properties.singleLineProperties.phasesCount()); + ui->m_phase_slider->setValue (m_properties.singleLineProperties.phasesCount()); + + updatePreview(false); +} + +/** + * @brief ReplaceConductorDialog::properties + * @return the properties edited by this widget + */ +ConductorProperties ReplaceConductorDialog::properties() const +{ + ConductorProperties properties_; + if (ui->m_multi_gb->isChecked()) { + properties_.type = ConductorProperties::Multi; + } else { + properties_.type = ConductorProperties::Single; + } + + properties_.text_size = ui->m_text_size_sb->value(); + properties_.m_formula = ui->m_formula_le->text(); + properties_.text = ui->m_text_le->text(); + properties_.m_show_text = ui->m_show_text->isChecked(); + properties_.m_function = ui->m_function_le->text(); + properties_.m_tension_protocol = ui->m_tension_protocol_le->text(); + switch (ui->m_vertical_align_cb->currentIndex()) { + case 0: properties_.m_vertical_alignment = Qt::AlignAbsolute; break; + case 1: properties_.m_vertical_alignment = Qt::AlignLeft; break; + case 2: properties_.m_vertical_alignment = Qt::AlignRight; break; + default:break; + } + switch (ui->m_horizontal_align_cb->currentIndex()) { + case 0: properties_.m_horizontal_alignment = Qt::AlignAbsolute; break; + case 1: properties_.m_horizontal_alignment = Qt::AlignTop; break; + case 2: properties_.m_horizontal_alignment = Qt::AlignBottom; break; + default: break; + } + properties_.verti_rotate_text = ui->m_vertical_angle_sb->value(); + properties_.horiz_rotate_text = ui->m_horizontal_angle_sb->value(); + properties_.color = ui->m_mod_color_cb->isChecked() ? ui->m_color_pb->palette().color(QPalette::Button) : QColor(); + properties_.style = ui->m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value().style(); + properties_.cond_size = ui->m_cond_size_sb->value(); + properties_.m_bicolor = ui->m_second_color_gb->isChecked(); + properties_.m_color_2 = ui->m_mod_color_2_cb->isChecked() ? ui->m_color_2_pb->palette().color(QPalette::Button) : QColor(); + properties_.m_dash_size = ui->m_color_2_dash_size_sb->value(); + + properties_.singleLineProperties.hasGround = ui->m_earth_cb->isChecked(); + properties_.singleLineProperties.hasNeutral = ui->m_neutral_cb->isChecked(); + properties_.singleLineProperties.is_pen = ui->m_pen_cb->isChecked(); + properties_.singleLineProperties.setPhasesCount(ui->m_phase_cb->isChecked() ? ui->m_phase_sb->value() : 0); + + return properties_; +} + +void ReplaceConductorDialog::initWidget() +{ + connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) { + this->done(ui->m_button_box->buttonRole(button_)); + }); + + ui->m_update_preview_pb->setHidden(true); + + ui->m_line_style_cb->addItem(tr("Inchanger"), QPen(Qt::NoPen)); + ui->m_line_style_cb->addItem(tr("Trait plein", "conductor style: solid line"), QPen(Qt::SolidLine)); + ui->m_line_style_cb->addItem(tr("Trait en pointillés", "conductor style: dashed line"), QPen(Qt::DashLine)); + ui->m_line_style_cb->addItem(tr("Traits et points", "conductor style: dashed and dotted line"), QPen(Qt::DashDotLine)); + + connect(ui->m_multi_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_singlewire_gb->setChecked(!toggle);}); + connect(ui->m_singlewire_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_multi_gb->setChecked(!toggle);}); + connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());}); + ui->m_multi_gb->setChecked(true); + ui->m_singlewire_gb->setChecked(true); +} + +void ReplaceConductorDialog::setColorButton(const QColor &color) +{ + QPalette palette; + palette.setColor(QPalette::Button, color); + ui->m_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name())); +} + +void ReplaceConductorDialog::setColorButton2(const QColor &color) +{ + QPalette palette; + palette.setColor(QPalette::Button, color); + ui->m_color_2_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name())); +} + +void ReplaceConductorDialog::on_m_erase_formula_cb_clicked() +{ + ui->m_formula_le->setText(ui->m_erase_formula_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_formula_le->setDisabled(ui->m_erase_formula_cb->isChecked()); +} + +void ReplaceConductorDialog::on_m_erase_text_cb_clicked() +{ + ui->m_text_le->setText(ui->m_erase_text_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_text_le->setDisabled(ui->m_erase_text_cb->isChecked()); +} + +void ReplaceConductorDialog::on_m_erase_function_cb_clicked() +{ + ui->m_function_le->setText(ui->m_erase_function_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_function_le->setDisabled(ui->m_erase_function_cb->isChecked()); +} + +void ReplaceConductorDialog::on_m_erase_tension_protocol_cb_clicked() +{ + ui->m_tension_protocol_le->setText(ui->m_erase_tension_protocol_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_tension_protocol_le->setDisabled(ui->m_erase_tension_protocol_cb->isChecked()); +} + +void ReplaceConductorDialog::on_m_earth_cb_toggled(bool checked) +{ + if (checked && ui->m_neutral_cb -> isChecked()) { + ui -> m_pen_cb -> setEnabled(true); + } else { + ui -> m_pen_cb -> setDisabled(true); + } +} + +void ReplaceConductorDialog::on_m_neutral_cb_toggled(bool checked) +{ + if (checked && ui->m_earth_cb->isChecked()) { + ui->m_pen_cb->setEnabled(true); + } else { + ui->m_pen_cb->setDisabled(true); + } +} + +void ReplaceConductorDialog::on_m_update_preview_pb_clicked() { + updatePreview(); +} + +void ReplaceConductorDialog::on_m_color_pb_clicked() +{ + QColor color = QColorDialog::getColor(m_properties.color, this); + if (color.isValid()) { + setColorButton(color); + } +} + +void ReplaceConductorDialog::on_m_color_2_pb_clicked() +{ + QColor color = QColorDialog::getColor(m_properties.m_color_2, this); + if (color.isValid()) { + setColorButton2(color); + } +} diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.h b/sources/SearchAndReplace/ui/replaceconductordialog.h new file mode 100644 index 000000000..cb72133cf --- /dev/null +++ b/sources/SearchAndReplace/ui/replaceconductordialog.h @@ -0,0 +1,65 @@ +/* + Copyright 2006-2018 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#ifndef REPLACECONDUCTORDIALOG_H +#define REPLACECONDUCTORDIALOG_H + +#include "conductorproperties.h" + +#include + +namespace Ui { + class ReplaceConductorDialog; +} + +/** + * @brief The ReplaceConductorDialog class + * A Qdialog to edit a conductor properties, use for the search and replace feature of QElectrotech. + */ +class ReplaceConductorDialog : public QDialog +{ + Q_OBJECT + + public: + explicit ReplaceConductorDialog(const ConductorProperties &properties, QWidget *parent = 0); + ~ReplaceConductorDialog(); + void updatePreview(bool b=true); + void setProperties(const ConductorProperties &properties); + ConductorProperties properties() const; + + private: + void initWidget(); + void setColorButton(const QColor &color); + void setColorButton2(const QColor &color); + + private slots: + void on_m_erase_formula_cb_clicked(); + void on_m_erase_text_cb_clicked(); + void on_m_erase_function_cb_clicked(); + void on_m_erase_tension_protocol_cb_clicked(); + void on_m_earth_cb_toggled(bool checked); + void on_m_neutral_cb_toggled(bool checked); + void on_m_update_preview_pb_clicked(); + void on_m_color_pb_clicked(); + void on_m_color_2_pb_clicked(); + + private: + Ui::ReplaceConductorDialog *ui; + ConductorProperties m_properties; +}; + +#endif // REPLACECONDUCTORDIALOG_H diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.ui b/sources/SearchAndReplace/ui/replaceconductordialog.ui new file mode 100644 index 000000000..55263df7a --- /dev/null +++ b/sources/SearchAndReplace/ui/replaceconductordialog.ui @@ -0,0 +1,753 @@ + + + ReplaceConductorDialog + + + + 0 + 0 + 636 + 523 + + + + Dialog + + + + + + 0 + + + + Type + + + + + + true + + + &Multifilaire + + + true + + + false + + + + + + + Inchanger + + + + + En haut + + + + + En bas + + + + + + + + Texte sur conducteur horizontal : + + + + + + + Non modifier + + + true + + + + + + + Tension / protocol : + + + + + + + Non modifier + + + true + + + + + + + Supprimer ce texte + + + + + + + + + + Fonction : + + + + + + + Formule du texte : + + + + + + + Texte visible + + + + + + + + + + Angle : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Non modifier + + + true + + + + + + + Inchanger + + + false + + + 2 + + + 2 + + + + + + + Texte sur conducteur vertical : + + + + + + + Taille du texte : + + + + + + + Texte : + + + + + + + Supprimer ce texte + + + + + + + + + + Supprimer ce texte + + + + + + + + + + + Inchanger + + + + + À gauche + + + + + À droite + + + + + + + + Supprimer ce texte + + + + + + + + + + Angle : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + Inchanger + + + ° + + + + + + -1 + + + 359 + + + -1 + + + + + + + true + + + Inchanger + + + ° + + + -1 + + + 359 + + + -1 + + + + + + + Non modifier + + + true + + + + + + + + + + Unifilaire + + + false + + + true + + + false + + + + + + Protective Earth Neutral + + + PEN + + + + + + + Phase + + + phase + + + + :/ico/16x16/phase.png:/ico/16x16/phase.png + + + + + + + Nombre de phase + + + 1 + + + 3 + + + + + + + Neutre + + + neutre + + + + :/ico/16x16/neutral.png:/ico/16x16/neutral.png + + + + + + + + 0 + 0 + + + + Nombre de phase + + + 1 + + + 3 + + + Qt::Horizontal + + + + + + + Terre + + + terre + + + + :/ico/16x16/ground.png:/ico/16x16/ground.png + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + PushButton + + + + + + + + + + + Apparence + + + + + + Taille : + + + + + + + Couleur : + + + + + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Style : + + + + + + + Modifier + + + + + + + + + + Couleur secondaire : + + + true + + + false + + + + + + false + + + + + + + + + + Taille de trait : + + + + + + + Couleur : + + + + + + + Modifier + + + + + + + + + + Inchanger + + + px + + + 1 + + + 1 + + + + + + + + + + Inchanger + + + 0.200000000000000 + + + 0.200000000000000 + + + 0.200000000000000 + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset + + + + + + + + + + + m_mod_color_cb + toggled(bool) + m_color_pb + setEnabled(bool) + + + 605 + 57 + + + 328 + 58 + + + + + m_earth_cb + clicked() + m_update_preview_pb + click() + + + 243 + 372 + + + 392 + 373 + + + + + m_neutral_cb + clicked() + m_update_preview_pb + click() + + + 243 + 404 + + + 392 + 373 + + + + + m_phase_cb + clicked() + m_update_preview_pb + click() + + + 243 + 434 + + + 392 + 373 + + + + + m_pen_cb + clicked() + m_update_preview_pb + click() + + + 392 + 404 + + + 392 + 373 + + + + + m_phase_slider + valueChanged(int) + m_update_preview_pb + click() + + + 392 + 434 + + + 392 + 373 + + + + + m_phase_sb + valueChanged(int) + m_update_preview_pb + click() + + + 540 + 435 + + + 392 + 373 + + + + + m_phase_slider + sliderMoved(int) + m_phase_sb + setValue(int) + + + 392 + 434 + + + 540 + 435 + + + + + m_phase_sb + valueChanged(int) + m_phase_slider + setValue(int) + + + 540 + 435 + + + 392 + 434 + + + + + m_mod_color_2_cb + toggled(bool) + m_color_2_pb + setEnabled(bool) + + + 597 + 200 + + + 341 + 201 + + + + + diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp index 9eb5605bb..b72a6d98d 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp @@ -27,6 +27,7 @@ #include "replacefoliowidget.h" #include "replaceelementdialog.h" #include "qetapp.h" +#include "replaceconductordialog.h" #include @@ -911,6 +912,14 @@ void SearchAndReplaceWidget::on_m_replace_pb_clicked() } } + else if (ui->m_conductor_pb->text().endsWith(tr(" [édité]")) && + m_conductor_hash.keys().contains(qtwi)) + { + QPointer c = m_conductor_hash.value(qtwi); + if (c) { + m_worker.replaceConductor(c.data()); + } + } } activateNextChecked(); ui->m_replace_pb->setEnabled(ui->m_next_pb->isEnabled()); @@ -972,6 +981,23 @@ void SearchAndReplaceWidget::on_m_replace_all_pb_clicked() m_worker.replaceIndiText(text_list ); } + //Replace conductor + if (ui->m_conductor_pb->text().endsWith(tr(" [édité]"))) + { + QList conductor_list; + for (QTreeWidgetItem *qtwi : m_conductor_hash.keys()) + { + if (!qtwi->isHidden() && qtwi->checkState(0) == Qt::Checked) + { + QPointer c = m_conductor_hash.value(qtwi); + if (c) { + conductor_list.append(c.data()); + } + } + } + m_worker.replaceConductor(conductor_list); + } + //Change was made, we reload the panel //and search again to keep up to date the tree widget //and the match item of search @@ -1027,3 +1053,32 @@ void SearchAndReplaceWidget::on_m_case_sensitive_cb_stateChanged(int arg1) Q_UNUSED(arg1); search(); } + +/** + * @brief SearchAndReplaceWidget::on_m_conductor_pb_clicked + * Open a dialog to edit the condutor properties + */ +void SearchAndReplaceWidget::on_m_conductor_pb_clicked() +{ + ReplaceConductorDialog *dialog = new ReplaceConductorDialog(m_worker.m_conductor_properties, this); + int result = dialog->exec(); + + if (result == QDialogButtonBox::AcceptRole) + { + QString text = ui->m_conductor_pb->text(); + if (!text.endsWith(tr(" [édité]"))) { + text.append(tr(" [édité]")); + } + ui->m_conductor_pb->setText(text); + m_worker.m_conductor_properties = dialog->properties(); + } + else if (result == QDialogButtonBox::ResetRole) + { + QString text = ui->m_conductor_pb->text(); + if (text.endsWith(tr(" [édité]"))) { + text.remove(tr(" [édité]")); + } + ui->m_conductor_pb->setText(text); + m_worker.m_conductor_properties = m_worker.invalidConductorProperties(); + } +} diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.h b/sources/SearchAndReplace/ui/searchandreplacewidget.h index 6f5185779..ac00a648b 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.h +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.h @@ -77,6 +77,7 @@ class SearchAndReplaceWidget : public QWidget void on_m_element_pb_clicked(); void on_m_mode_cb_currentIndexChanged(int index); void on_m_case_sensitive_cb_stateChanged(int arg1); + void on_m_conductor_pb_clicked(); private: Ui::SearchAndReplaceWidget *ui; diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.ui b/sources/SearchAndReplace/ui/searchandreplacewidget.ui index f11fc68af..cc44a5821 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.ui +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.ui @@ -35,7 +35,7 @@ - + :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png @@ -49,7 +49,7 @@ - + :/ico/16x16/go-bottom.png:/ico/16x16/go-bottom.png @@ -66,7 +66,7 @@ - + :/ico/16x16/configure-toolbars.png:/ico/16x16/configure-toolbars.png @@ -110,7 +110,7 @@ - + :/ico/16x16/go-top.png:/ico/16x16/go-top.png @@ -140,7 +140,7 @@ - + :/ico/16x16/window-close.svg:/ico/16x16/window-close.svg @@ -196,9 +196,6 @@ - - false - <html><head/><body><p>Définir les propriétés à remplacer dans les conducteurs</p></body></html> @@ -291,8 +288,6 @@ - - - +