diff --git a/qelectrotech.pro b/qelectrotech.pro index ce0ce47fd..a99029c9c 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -66,7 +66,7 @@ DEPENDPATH += . INCLUDEPATH += sources sources/editor sources/titleblock sources/ui sources/qetgraphicsitem sources/richtext sources/factory sources/properties sources/dvevent # Fichiers sources -HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*.h) $$files(sources/titleblock/*.h) $$files(sources/richtext/*.h) $$files(sources/qetgraphicsitem/*.h) $$files(sources/factory/*.cpp) \ +HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) $$files(sources/editor/*.h) $$files(sources/titleblock/*.h) $$files(sources/richtext/*.h) $$files(sources/qetgraphicsitem/*.h) $$files(sources/factory/*.h) \ $$files(sources/properties/*.h) \ $$files(sources/editor/ui/*.h) \ $$files(sources/dvevent/*.h) diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 195a836f9..942254d16 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1441,36 +1441,6 @@ QSet Conductor::relatedPotentialConductors(const bool all_diagram, return(other_conductors); } -/** - * @brief Conductor::relatedPotentialTerminal - * Return terminal at the same potential from the same - * parent element of @t. - * For folio report, return the terminal of linked other report. - * For Terminal element, return the other terminal of terminal element. - * @param t terminal to start search - * @param all_diagram :if true return all related terminal, - * false return only terminal in the same diagram of @t - * @return - */ -Terminal * Conductor::relatedPotentialTerminal (Terminal *t, const bool all_diagram) { - // If terminal parent element is a folio report. - if (all_diagram && t->parentElement()->linkType() & Element::AllReport) { - QList elmt_list = t->parentElement()->linkedElements(); - if (!elmt_list.isEmpty()) { - return (elmt_list.first()->terminals().first()); - } - } - // If terminal parent element is a Terminal element. - if (t->parentElement() -> linkType() & Element::Terminale) { - QList terminals = t->parentElement()->terminals(); - terminals.removeAll(t); - if (!terminals.isEmpty()) return terminals.first(); - else return nullptr; - } - - return nullptr; -} - /** * @return l'editeur de schemas parent ou 0 */ diff --git a/sources/qetgraphicsitem/conductor.h b/sources/qetgraphicsitem/conductor.h index 4095f10a7..34cc3556c 100644 --- a/sources/qetgraphicsitem/conductor.h +++ b/sources/qetgraphicsitem/conductor.h @@ -179,7 +179,6 @@ class Conductor : public QObject, public QGraphicsPathItem { static qreal conductor_bound(qreal, qreal, bool); static Qt::Corner movementType(const QPointF &, const QPointF &); static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &); - Terminal * relatedPotentialTerminal (Terminal *, const bool all_diagram = true); }; Conductor * longuestConductorInPotential (Conductor *conductor, bool all_diagram = false); diff --git a/sources/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp similarity index 93% rename from sources/terminal.cpp rename to sources/qetgraphicsitem/terminal.cpp index a6e7deaab..63a4a7d43 100644 --- a/sources/terminal.cpp +++ b/sources/qetgraphicsitem/terminal.cpp @@ -549,3 +549,33 @@ Element *Terminal::parentElement() const { return(parent_element_); } +/** + * @brief Conductor::relatedPotentialTerminal + * Return terminal at the same potential from the same + * parent element of @t. + * For folio report, return the terminal of linked other report. + * For Terminal element, return the other terminal of terminal element. + * @param t terminal to start search + * @param all_diagram :if true return all related terminal, + * false return only terminal in the same diagram of @t + * @return + */ +Terminal * relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram) { + // If terminal parent element is a folio report. + if (all_diagram && terminal -> parentElement() -> linkType() & Element::AllReport) { + QList elmt_list = terminal -> parentElement() -> linkedElements(); + if (!elmt_list.isEmpty()) { + return (elmt_list.first() -> terminals().first()); + } + } + // If terminal parent element is a Terminal element. + else if (terminal -> parentElement() -> linkType() & Element::Terminale) { + QList terminals = terminal -> parentElement() -> terminals(); + terminals.removeAll(const_cast (terminal)); + if (!terminals.isEmpty()) + return terminals.first(); + } + + return nullptr; +} + diff --git a/sources/terminal.h b/sources/qetgraphicsitem/terminal.h similarity index 98% rename from sources/terminal.h rename to sources/qetgraphicsitem/terminal.h index e0c2209dc..c690b2426 100644 --- a/sources/terminal.h +++ b/sources/qetgraphicsitem/terminal.h @@ -160,4 +160,6 @@ inline QString Terminal::name() const { return(name_terminal_); } +Terminal * relatedPotentialTerminal (const Terminal *terminal, const bool all_diagram = true); + #endif