diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 26a77f862..b26853f8b 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -283,6 +283,8 @@ void ConductorProperties::toXml(QDomElement &e) const e.setAttribute("num", text); e.setAttribute("text_color", text_color.name()); e.setAttribute("formula", m_formula); + e.setAttribute("cable", m_cable); + e.setAttribute("bus", m_bus); e.setAttribute("function", m_function); e.setAttribute("tension_protocol", m_tension_protocol); e.setAttribute("conductor_color", m_wire_color); @@ -340,6 +342,8 @@ void ConductorProperties::fromXml(QDomElement &e) QColor xml_text_color= QColor(e.attribute("text_color")); text_color = (xml_text_color.isValid()? xml_text_color : QColor(Qt::black)); m_formula = e.attribute("formula"); + m_cable = e.attribute("cable"); + m_bus = e.attribute("bus"); m_function = e.attribute("function"); m_tension_protocol = e.attribute("tension_protocol"); m_wire_color = e.attribute("conductor_color"); @@ -389,6 +393,8 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) settings.setValue(prefix + "text", text); settings.setValue(prefix + "text_color", text_color.name()); settings.setValue(prefix + "formula", m_formula); + settings.setValue(prefix + "cable", m_cable); + settings.setValue(prefix + "bus", m_bus); settings.setValue(prefix + "function", m_function); settings.setValue(prefix + "tension_protocol", m_tension_protocol); settings.setValue(prefix + "conductor_color", m_wire_color); @@ -431,6 +437,8 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString()); text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black)); m_formula = settings.value(prefix + "formula", "").toString(); + m_cable = settings.value(prefix + "cable", "").toString(); + m_bus = settings.value(prefix + "bus", "").toString(); m_function = settings.value(prefix + "function", "").toString(); m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString(); m_wire_color = settings.value(prefix + "conductor_color", "").toString(); @@ -485,6 +493,8 @@ void ConductorProperties::applyForEqualAttributes(QList lis text = cp.text; text_color = cp.text_color; m_formula = cp.m_formula; + m_cable = cp.m_cable; + m_bus = cp.m_bus; m_function = cp.m_function; m_tension_protocol = cp.m_tension_protocol; m_wire_color = cp.m_wire_color; @@ -586,7 +596,29 @@ void ConductorProperties::applyForEqualAttributes(QList lis m_formula = s_value; equal = true; - //function + //cable + s_value = clist.first().m_cable; + for(ConductorProperties cp : clist) + { + if (cp.m_cable != s_value) + equal = false; + } + if (equal) + m_cable = s_value; + equal = true; + + //bus + s_value = clist.first().m_bus; + for(ConductorProperties cp : clist) + { + if (cp.m_bus != s_value) + equal = false; + } + if (equal) + m_bus = s_value; + equal = true; + + //function s_value = clist.first().m_function; for(ConductorProperties cp : clist) { @@ -751,6 +783,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const other.text == text &&\ other.text_color == text_color &&\ other.m_formula == m_formula &&\ + other.m_cable == m_cable &&\ + other.m_bus == m_bus &&\ other.m_function == m_function &&\ other.m_tension_protocol == m_tension_protocol &&\ other.m_wire_color == m_wire_color && \ @@ -797,7 +831,7 @@ void ConductorProperties::readStyle(const QString &style_string) { QRegularExpression Rx("^(?[a-z-]+): (?[a-z-]+)$"); if (!Rx.isValid()) { - qWarning() <<"this is an error in the code" + qWarning() <. */ @@ -41,17 +41,17 @@ class SingleLineProperties { void fromXml(QDomElement &); void toSettings(QSettings &, const QString & = QString()) const; void fromSettings(QSettings &, const QString & = QString()); - + /// Whether the singleline conductor should display the ground symbol bool hasGround; /// Whether the singleline conductor should display the neutral symbol bool hasNeutral; /// Protective Earth Neutral: visually merge neutral and ground bool is_pen; - + int operator==(const SingleLineProperties &) const; int operator!=(const SingleLineProperties &) const; - + private: unsigned short int phases; void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal); @@ -69,7 +69,7 @@ class ConductorProperties public: ConductorProperties(); virtual ~ConductorProperties(); - + /** @brief The ConductorType enum Represents the kind of a particular conductor: @@ -81,36 +81,44 @@ class ConductorProperties //Attributes ConductorType type; - - QColor color, - m_color_2, - text_color; - - QString text, - m_function, - m_tension_protocol, - m_wire_color, - m_wire_section, - m_formula; - - int text_size, - m_dash_size = 1; - - double cond_size, - verti_rotate_text, - horiz_rotate_text; - - bool m_show_text, - m_one_text_per_folio, - m_bicolor = false; - - Qt::Alignment m_horizontal_alignment = Qt::AlignBottom, - m_vertical_alignment = Qt::AlignRight; - + + QColor + color, + m_color_2, + text_color; + + QString + text, + m_function, + m_tension_protocol, + m_wire_color, + m_wire_section, + m_formula, + m_bus, + m_cable; + + int + text_size, + m_dash_size = 1; + + double + cond_size, + verti_rotate_text, + horiz_rotate_text; + + bool + m_show_text, + m_one_text_per_folio, + m_bicolor = false; + + Qt::Alignment + m_horizontal_alignment = Qt::AlignBottom, + m_vertical_alignment = Qt::AlignRight; + Qt::PenStyle style; - + SingleLineProperties singleLineProperties; - + // methods void toXml(QDomElement &) const; void fromXml(QDomElement &); @@ -120,11 +128,11 @@ class ConductorProperties void applyForEqualAttributes(QList list); static ConductorProperties defaultProperties(); - + // operators bool operator==(const ConductorProperties &) const; bool operator!=(const ConductorProperties &) const; - + private: void readStyle(const QString &); QString writeStyle() const; diff --git a/sources/ui/conductorpropertieswidget.cpp b/sources/ui/conductorpropertieswidget.cpp index e8684d263..0af0dd27b 100644 --- a/sources/ui/conductorpropertieswidget.cpp +++ b/sources/ui/conductorpropertieswidget.cpp @@ -73,7 +73,7 @@ void ConductorPropertiesWidget::setProperties( { if (m_properties == properties) return; - + m_properties = properties; int index = ui -> m_line_style_cb -> findData(QPen(m_properties.style)); @@ -84,6 +84,8 @@ void ConductorPropertiesWidget::setProperties( ui->m_formula_le -> setText (m_properties.m_formula); ui->m_text_le -> setText (m_properties.text); ui->m_function_le -> setText (m_properties.m_function); + ui->m_cable_le -> setText (m_properties.m_cable); + ui->m_bus_le -> setText (m_properties.m_bus); 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); @@ -128,6 +130,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const properties_.text = ui -> m_text_le -> text(); properties_.text_color = ui -> m_text_color_kpb->color(); properties_.m_function = ui -> m_function_le->text(); + properties_.m_cable = ui -> m_cable_le->text(); + properties_.m_bus = ui -> m_bus_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(); @@ -237,6 +241,12 @@ void ConductorPropertiesWidget::initWidget() connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());}); ui->m_multiwires_gb->setChecked(true); ui->m_singlewire_gb->setChecked(true); +#if TODO_LIST +#pragma message("@TODO Add Kabel and Bus to qet") +#else + ui->m_cable_le->setDisabled(true); + ui->m_bus_le->setDisabled(true); +#endif } /** @@ -262,7 +272,7 @@ void ConductorPropertiesWidget::setConductorType(ConductorProperties::ConductorT @brief ConductorPropertiesWidget::updatePreview Update the preview for single lien @param b true: update from the value displayed by this widget - false: update from the properties given at the constructor of this widget + false: update from the properties given at the constructor of this widget */ void ConductorPropertiesWidget::updatePreview(bool b) { const QRect pixmap_rect(0, 0, 96, 96); diff --git a/sources/ui/conductorpropertieswidget.ui b/sources/ui/conductorpropertieswidget.ui index 7ef5cc3b9..a3df23e90 100644 --- a/sources/ui/conductorpropertieswidget.ui +++ b/sources/ui/conductorpropertieswidget.ui @@ -52,16 +52,50 @@ true - - + + + + Couleur du texte: + + - - + + + + Couleur du conducteur + + + + + + + + + + Texte + true + + + + Tension / Protocole : + + + + + + + Autonumérotation + + + + + + @@ -84,45 +118,17 @@ - - - - Texte : + + + + true - - + + - Formule du texte : - - - - - - - éditer les numérotations - - - - - - - :/ico/16x16/configure.png:/ico/16x16/configure.png - - - - - - - Tension / Protocole : - - - - - - - Couleur du conducteur + Section du conducteur @@ -139,32 +145,6 @@ - - - - - - - - - - Autonumérotation - - - - - - - - - - Couleur du texte: - - - - - - @@ -175,10 +155,14 @@ - - + + + + Fonction : + + - + @@ -220,6 +204,19 @@ + + + + + + + Texte : + + + + + + @@ -227,37 +224,60 @@ - - - - Section du conducteur - - - - - - - Fonction : - - - - - - - true - - - - - + + - Texte + éditer les numérotations + + + + + + :/ico/16x16/configure.png:/ico/16x16/configure.png + + + + + true + + + + + + + Formule du texte : + + + + + + + + + + cable + + + + + + + + + + bus + + + + + +