From 6b16f5b46d7fc59544ab037467b9d332dfd36de3 Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Mon, 25 May 2020 12:06:27 +0200 Subject: [PATCH] Add new conductors properties color and section --- .../searchandreplaceworker.cpp | 4 + .../ui/replaceconductordialog.cpp | 16 + .../ui/replaceconductordialog.h | 2 + .../ui/replaceconductordialog.ui | 354 ++++++++++-------- .../ui/searchandreplacewidget.cpp | 2 + sources/conductorproperties.cpp | 35 ++ sources/conductorproperties.h | 2 + sources/qetgraphicsitem/conductor.cpp | 2 + .../dynamicelementtextitem.cpp | 8 + sources/ui/conductorpropertieswidget.cpp | 4 + sources/ui/conductorpropertieswidget.ui | 126 ++++--- sources/ui/dynamicelementtextmodel.cpp | 4 + sources/ui/linksingleelementwidget.cpp | 10 +- sources/ui/potentialselectordialog.cpp | 12 + sources/undocommand/linkelementcommand.cpp | 2 + 15 files changed, 368 insertions(+), 215 deletions(-) diff --git a/sources/SearchAndReplace/searchandreplaceworker.cpp b/sources/SearchAndReplace/searchandreplaceworker.cpp index be15ce960..c2c58ee6e 100644 --- a/sources/SearchAndReplace/searchandreplaceworker.cpp +++ b/sources/SearchAndReplace/searchandreplaceworker.cpp @@ -400,6 +400,8 @@ ConductorProperties SearchAndReplaceWorker::applyChange(const ConductorPropertie 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); + new_properties.m_wire_color = applyChange(new_properties.m_wire_color, change.m_wire_color); + new_properties.m_wire_section = applyChange(new_properties.m_wire_section, change.m_wire_section); 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 || @@ -501,6 +503,8 @@ ConductorProperties SearchAndReplaceWorker::replaceAdvanced(Conductor *conductor else if (what == "text") {properties.text.replace(rx, replace);} else if (what == "function") {properties.m_function.replace(rx, replace);} else if (what == "tension/protocol") {properties.m_tension_protocol.replace(rx, replace);} + else if (what == "couleur-conducteur") {properties.m_wire_color.replace(rx, replace);} + else if (what == "section-conducteur") {properties.m_wire_section.replace(rx, replace);} } return properties; diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.cpp b/sources/SearchAndReplace/ui/replaceconductordialog.cpp index fb7c813e5..0653b685a 100644 --- a/sources/SearchAndReplace/ui/replaceconductordialog.cpp +++ b/sources/SearchAndReplace/ui/replaceconductordialog.cpp @@ -83,6 +83,8 @@ void ReplaceConductorDialog::setProperties(const ConductorProperties &properties 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); + sarw::setupLineEdit(ui->m_wire_color_le, ui->m_erase_wire_color_cb, m_properties.m_wire_color); + sarw::setupLineEdit(ui->m_wire_section_le,ui->m_erase_wire_section_cb,m_properties.m_wire_section); 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; @@ -140,6 +142,8 @@ ConductorProperties ReplaceConductorDialog::properties() const 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(); + properties_.m_wire_color =ui->m_wire_color_le->text(); + properties_.m_wire_section =ui->m_wire_section_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; @@ -227,6 +231,18 @@ void ReplaceConductorDialog::on_m_erase_tension_protocol_cb_clicked() ui->m_tension_protocol_le->setDisabled(ui->m_erase_tension_protocol_cb->isChecked()); } +void ReplaceConductorDialog::on_m_erase_m_wire_color_cb_clicked() +{ + ui->m_wire_color_le->setText(ui->m_erase_wire_color_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_wire_color_le->setDisabled(ui->m_erase_wire_color_cb->isChecked()); +} + +void ReplaceConductorDialog::on_m_erase_m_wire_section_cb_clicked() +{ + ui->m_wire_section_le->setText(ui->m_erase_wire_section_cb->isChecked() ? SearchAndReplaceWorker::eraseText() : QString()); + ui->m_wire_section_le->setDisabled(ui->m_erase_wire_section_cb->isChecked()); +} + void ReplaceConductorDialog::on_m_earth_cb_toggled(bool checked) { if (checked && ui->m_neutral_cb -> isChecked()) { diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.h b/sources/SearchAndReplace/ui/replaceconductordialog.h index 21f05e4e0..bd2743500 100644 --- a/sources/SearchAndReplace/ui/replaceconductordialog.h +++ b/sources/SearchAndReplace/ui/replaceconductordialog.h @@ -51,6 +51,8 @@ class ReplaceConductorDialog : public QDialog 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_erase_m_wire_color_cb_clicked(); + void on_m_erase_m_wire_section_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(); diff --git a/sources/SearchAndReplace/ui/replaceconductordialog.ui b/sources/SearchAndReplace/ui/replaceconductordialog.ui index 334ea841a..4be6a94d3 100644 --- a/sources/SearchAndReplace/ui/replaceconductordialog.ui +++ b/sources/SearchAndReplace/ui/replaceconductordialog.ui @@ -36,49 +36,6 @@ false - - - - - Ne pas modifier - - - - - En haut - - - - - En bas - - - - - - - - Texte sur conducteur horizontal : - - - - - - - Ne pas modifier - - - true - - - - - - - Tension / protocol : - - - @@ -89,83 +46,6 @@ - - - - Supprimer ce texte - - - - - - - - - - Fonction : - - - - - - - Formule du texte : - - - - - - - Texte visible - - - - - - - - - - Angle : - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Ne pas modifier - - - true - - - - - - - Ne pas modifier - - - false - - - 2 - - - 2 - - - - - - - Texte sur conducteur vertical : - - - @@ -173,34 +53,7 @@ - - - - Texte : - - - - - - - Supprimer ce texte - - - - - - - - - - Supprimer ce texte - - - - - - - + Ne pas modifier @@ -222,6 +75,30 @@ + + + + Angle : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Couleur du conducteur + + + + + + + Texte : + + + @@ -232,17 +109,7 @@ - - - - Angle : - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - + true @@ -267,7 +134,56 @@ - + + + + Supprimer ce texte + + + + + + + + + + + Ne pas modifier + + + + + En haut + + + + + En bas + + + + + + + + Supprimer ce texte + + + + + + + + + + Ne pas modifier + + + true + + + + true @@ -289,6 +205,23 @@ + + + + Formule du texte : + + + + + + + Supprimer ce texte + + + + + + @@ -299,6 +232,107 @@ + + + + Texte sur conducteur vertical : + + + + + + + Ne pas modifier + + + false + + + 2 + + + 2 + + + + + + + Fonction : + + + + + + + Angle : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Texte visible + + + + + + + + + + Ne pas modifier + + + true + + + + + + + Texte sur conducteur horizontal : + + + + + + + Tension / protocol : + + + + + + + Section du conducteur + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp index 94ee7f2a6..d06590fe2 100644 --- a/sources/SearchAndReplace/ui/searchandreplacewidget.cpp +++ b/sources/SearchAndReplace/ui/searchandreplacewidget.cpp @@ -793,6 +793,8 @@ QStringList SearchAndReplaceWidget::searchTerms(Conductor *conductor) list.append(properties.text); list.append(properties.m_function); list.append(properties.m_tension_protocol); + list.append(properties.m_wire_color); + list.append(properties.m_wire_section); return list; } diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index e6686281a..035287d63 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -262,6 +262,8 @@ void ConductorProperties::toXml(QDomElement &e) const e.setAttribute("formula", m_formula); e.setAttribute("function", m_function); e.setAttribute("tension-protocol", m_tension_protocol); + e.setAttribute("couleur-conducteur", m_wire_color); + e.setAttribute("section-conducteur", m_wire_section); e.setAttribute("numsize", QString::number(text_size)); e.setAttribute("condsize", QString::number(cond_size)); e.setAttribute("displaytext", m_show_text); @@ -314,6 +316,8 @@ void ConductorProperties::fromXml(QDomElement &e) m_formula = e.attribute("formula"); m_function = e.attribute("function"); m_tension_protocol = e.attribute("tension-protocol"); + m_wire_color = e.attribute("couleur-conducteur"); + m_wire_section = e.attribute("section-conducteur"); text_size = e.attribute("numsize", QString::number(9)).toInt(); cond_size = e.attribute("condsize", QString::number(1)).toDouble(); m_show_text = e.attribute("displaytext", QString::number(1)).toInt(); @@ -347,6 +351,8 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) settings.setValue(prefix + "formula", m_formula); settings.setValue(prefix + "function", m_function); settings.setValue(prefix + "tension-protocol", m_tension_protocol); + settings.setValue(prefix + "couleur-conducteur", m_wire_color); + settings.setValue(prefix + "section-conducteur", m_wire_section); settings.setValue(prefix + "textsize", QString::number(text_size)); settings.setValue(prefix + "size", QString::number(cond_size)); settings.setValue(prefix + "displaytext", m_show_text); @@ -385,6 +391,8 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi m_formula = settings.value(prefix + "formula", "").toString(); m_function = settings.value(prefix + "function", "").toString(); m_tension_protocol = settings.value(prefix + "tension-protocol", "").toString(); + m_wire_color = settings.value(prefix + "couleur-conducteur", "").toString(); + m_wire_section = settings.value(prefix + "section-conducteur", "").toString(); text_size = settings.value(prefix + "textsize", "7").toInt(); cond_size = settings.value(prefix + "size", "1").toInt(); m_show_text = settings.value(prefix + "displaytext", true).toBool(); @@ -436,6 +444,8 @@ void ConductorProperties::applyForEqualAttributes(QList lis m_formula = cp.m_formula; m_function = cp.m_function; m_tension_protocol = cp.m_tension_protocol; + m_wire_color = cp.m_wire_color; + m_wire_section = cp.m_wire_section; text_size = cp.text_size; cond_size = cp.cond_size; m_show_text = cp.m_show_text; @@ -544,6 +554,29 @@ void ConductorProperties::applyForEqualAttributes(QList lis m_tension_protocol = s_value; equal = true; + //couleur-conducteur + s_value = clist.first().m_wire_color; + for(ConductorProperties cp : clist) + { + if (cp.m_wire_color != s_value) + equal = false; + } + if (equal) + m_wire_color = s_value; + equal = true; + + //section-conducteur + s_value = clist.first().m_wire_section; + for(ConductorProperties cp : clist) + { + if (cp.m_wire_section != s_value) + equal = false; + } + if (equal) + m_wire_section = s_value; + equal = true; + + //text size i_value = clist.first().text_size; for(ConductorProperties cp : clist) @@ -665,6 +698,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const other.m_formula == m_formula &&\ other.m_function == m_function &&\ other.m_tension_protocol == m_tension_protocol &&\ + other.m_wire_color == m_wire_color && \ + other.m_wire_section == m_wire_section && \ other.m_show_text == m_show_text &&\ other.text_size == text_size &&\ other.cond_size == cond_size &&\ diff --git a/sources/conductorproperties.h b/sources/conductorproperties.h index e392359bf..514f50eae 100644 --- a/sources/conductorproperties.h +++ b/sources/conductorproperties.h @@ -85,6 +85,8 @@ class ConductorProperties QString text, m_function, m_tension_protocol, + m_wire_color, + m_wire_section, m_formula; int text_size, diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 2a6d97fe5..c58dca881 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1478,6 +1478,8 @@ void Conductor::setPropertyToPotential(const ConductorProperties &property, bool other_properties.text = m_properties.text; other_properties.m_function = m_properties.m_function; other_properties.m_tension_protocol = m_properties.m_tension_protocol; + other_properties.m_wire_color = m_properties.m_wire_color; + other_properties.m_wire_section = m_properties.m_wire_section; other_conductor->setProperties(other_properties); } else diff --git a/sources/qetgraphicsitem/dynamicelementtextitem.cpp b/sources/qetgraphicsitem/dynamicelementtextitem.cpp index dcf87dccb..20f6e11c9 100644 --- a/sources/qetgraphicsitem/dynamicelementtextitem.cpp +++ b/sources/qetgraphicsitem/dynamicelementtextitem.cpp @@ -1150,6 +1150,10 @@ void DynamicElementTextItem::conductorPropertiesChanged() setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_function : ""); else if (m_info_name == "tension-protocol") setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_tension_protocol : ""); + else if (m_info_name == "couleur-conducteur") + setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_wire_color : ""); + else if (m_info_name == "section-conducteur") + setPlainText(m_watched_conductor? m_watched_conductor.data()->properties().m_wire_section : ""); } else if (m_text_from == CompositeText) { setPlainText(reportReplacedCompositeText()); @@ -1184,6 +1188,10 @@ QString DynamicElementTextItem::reportReplacedCompositeText() const string.replace("%{function}", m_watched_conductor.data()->properties().m_function); if(string.contains("%{tension-protocol}")) string.replace("%{tension-protocol}", m_watched_conductor.data()->properties().m_tension_protocol); + if(string.contains("%{}couleur-conducteur")) + string.replace("%{couleur-conducteur}", m_watched_conductor.data()->properties().m_wire_color); + if(string.contains("%{}section-conducteur")) + string.replace("%{section-conducteur}", m_watched_conductor.data()->properties().m_wire_section); } } diff --git a/sources/ui/conductorpropertieswidget.cpp b/sources/ui/conductorpropertieswidget.cpp index 571669106..6b08051fe 100644 --- a/sources/ui/conductorpropertieswidget.cpp +++ b/sources/ui/conductorpropertieswidget.cpp @@ -82,6 +82,8 @@ void ConductorPropertiesWidget::setProperties(const ConductorProperties &propert ui->m_text_le -> setText (m_properties.text); ui->m_function_le -> setText (m_properties.m_function); ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol); + ui->m_wire_color_le -> setText (m_properties.m_wire_color); + ui->m_wire_section_le -> setText (m_properties.m_wire_section); ui->m_text_size_sb -> setValue (m_properties.text_size); ui->m_cond_size_sb -> setValue (m_properties.cond_size); ui->m_show_text_cb -> setChecked (m_properties.m_show_text); @@ -122,6 +124,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const properties_.text = ui -> m_text_le -> text(); properties_.m_function = ui -> m_function_le->text(); properties_.m_tension_protocol = ui -> m_tension_protocol_le->text(); + properties_.m_wire_color = ui -> m_wire_color_le->text(); + properties_.m_wire_section = ui -> m_wire_section_le->text(); properties_.text_size = ui -> m_text_size_sb -> value(); properties_.cond_size = ui -> m_cond_size_sb -> value(); properties_.m_show_text = ui -> m_show_text_cb -> isChecked(); diff --git a/sources/ui/conductorpropertieswidget.ui b/sources/ui/conductorpropertieswidget.ui index 2553ae63b..26521c38b 100644 --- a/sources/ui/conductorpropertieswidget.ui +++ b/sources/ui/conductorpropertieswidget.ui @@ -17,7 +17,7 @@ - 1 + 0 @@ -37,7 +37,14 @@ - + + + + + Autonumérotation + + + @@ -45,6 +52,26 @@ + + + + Couleur du conducteur + + + + + + + + + + + + + Fonction : + + + @@ -52,6 +79,16 @@ + + + + Texte + + + true + + + @@ -59,6 +96,27 @@ + + + + Tension / Protocole : + + + + + + + Texte : + + + + + + + Formule du texte : + + + @@ -104,57 +162,6 @@ - - - - - - - Texte - - - true - - - - - - - Texte : - - - - - - - Fonction : - - - - - - - Formule du texte : - - - - - - - Tension / Protocole : - - - - - - - Autonumérotation - - - - - - @@ -169,6 +176,19 @@ + + + + Section du conducteur + + + + + + + + + diff --git a/sources/ui/dynamicelementtextmodel.cpp b/sources/ui/dynamicelementtextmodel.cpp index 22396290d..562682abf 100644 --- a/sources/ui/dynamicelementtextmodel.cpp +++ b/sources/ui/dynamicelementtextmodel.cpp @@ -1782,6 +1782,10 @@ QStringList DynamicTextItemDelegate::availableInfo(DynamicElementTextItem *deti) qstrl << "function"; if(!cond->properties().m_tension_protocol.isEmpty()) qstrl << "tension-protocol"; + if(!cond->properties().m_wire_color.isEmpty()) + qstrl << "couleur-conducteur"; + if(!cond->properties().m_wire_section.isEmpty()) + qstrl << "section-conducteur"; } return qstrl; diff --git a/sources/ui/linksingleelementwidget.cpp b/sources/ui/linksingleelementwidget.cpp index e6ef812ca..8bccee90a 100644 --- a/sources/ui/linksingleelementwidget.cpp +++ b/sources/ui/linksingleelementwidget.cpp @@ -279,6 +279,12 @@ void LinkSingleElementWidget::buildTree() str_list << cp.m_tension_protocol; if (!str_list.last().isEmpty()) search_list << str_list.last(); + str_list << cp.m_wire_color; + if (!str_list.last().isEmpty()) + search_list << str_list.last(); + str_list << cp.m_wire_section; + if (!str_list.last().isEmpty()) + search_list << str_list.last(); } else str_list << "" << "" << ""; @@ -421,11 +427,11 @@ void LinkSingleElementWidget::setUpHeaderLabels() { if (settings.value("genericpanel/folio", false).toBool()) { - list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << 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("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"); } } diff --git a/sources/ui/potentialselectordialog.cpp b/sources/ui/potentialselectordialog.cpp index a11387dff..fc632d083 100644 --- a/sources/ui/potentialselectordialog.cpp +++ b/sources/ui/potentialselectordialog.cpp @@ -191,6 +191,10 @@ ConductorProperties PotentialSelectorDialog::chosenProperties(QListm_conductor_number_2)); ConductorProperties cp2; @@ -284,6 +292,10 @@ void PotentialSelectorDialog::buildWidget() 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)); + if(!cp2.m_wire_color.isEmpty()) + 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)); QRadioButton *rb1 = new QRadioButton(text1, this); QRadioButton *rb2 = new QRadioButton(text2, this); diff --git a/sources/undocommand/linkelementcommand.cpp b/sources/undocommand/linkelementcommand.cpp index 08dea2ee4..de92baca6 100644 --- a/sources/undocommand/linkelementcommand.cpp +++ b/sources/undocommand/linkelementcommand.cpp @@ -205,6 +205,8 @@ void LinkElementCommand::redo() str_txt << c->properties().text; str_funct << c->properties().m_function; str_tens << c->properties().m_tension_protocol; + str_tens << c->properties().m_wire_color; + str_tens << c->properties().m_wire_section; } //check text list, isn't same in potential, ask user what to do