Merge pull request #471 from Kellermorph/makro-fix

Potential Isolation option for terminals
This commit is contained in:
Laurent Trinques
2026-05-28 09:45:04 +02:00
committed by GitHub
4 changed files with 4684 additions and 33 deletions
+4645 -31
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -788,6 +788,12 @@ QList<Terminal *> relatedPotentialTerminal (
// If terminal parent element is a Terminal element. // If terminal parent element is a Terminal element.
else if (terminal -> parentElement() -> linkType() & Element::Terminale) else if (terminal -> parentElement() -> linkType() & Element::Terminale)
{ {
// English: Check if the user activated the potential isolation checkbox for this terminal
if (terminal->parentElement()->elementInformations().value(QStringLiteral("potential_isolating")).toString() == QLatin1String("true")) {
// English: Potential is isolated. Return an empty list so it does not propagate to the other side.
return QList<Terminal *>();
}
QList <Terminal *> terminals = terminal->parentElement()->terminals(); QList <Terminal *> terminals = terminal->parentElement()->terminals();
terminals.removeAll(const_cast<Terminal *>(terminal)); terminals.removeAll(const_cast<Terminal *>(terminal));
return terminals; return terminals;
+31 -2
View File
@@ -16,7 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "elementinfowidget.h" #include "elementinfowidget.h"
#include <QCheckBox>
#include "../diagram.h" #include "../diagram.h"
#include "../qetapp.h" #include "../qetapp.h"
#include "../qetgraphicsitem/element.h" #include "../qetgraphicsitem/element.h"
@@ -161,6 +161,10 @@ void ElementInfoWidget::enableLiveEdit()
for (ElementInfoPartWidget *eipw : m_eipw_list) for (ElementInfoPartWidget *eipw : m_eipw_list)
connect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply); connect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply);
connect(ui->m_auto_num_locked_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply); connect(ui->m_auto_num_locked_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
if (m_potential_isolating_cb) {
connect(m_potential_isolating_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
} }
/** /**
@@ -172,6 +176,10 @@ void ElementInfoWidget::disableLiveEdit()
for (ElementInfoPartWidget *eipw : m_eipw_list) for (ElementInfoPartWidget *eipw : m_eipw_list)
disconnect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply); disconnect(eipw, &ElementInfoPartWidget::textChanged, this, &ElementInfoWidget::apply);
disconnect(ui->m_auto_num_locked_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply); disconnect(ui->m_auto_num_locked_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
if (m_potential_isolating_cb) {
disconnect(m_potential_isolating_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
} }
/** /**
@@ -195,14 +203,25 @@ void ElementInfoWidget::buildInterface()
} }
ui->scroll_vlayout->addStretch(); ui->scroll_vlayout->addStretch();
m_potential_isolating_cb = new QCheckBox(tr("Séparation de potentiel"), this);
m_potential_isolating_cb->setStyleSheet(QStringLiteral("margin: 5px; font-weight: bold;"));
if (QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(this->layout())) {
mainLayout->insertWidget(1, m_potential_isolating_cb);
}
// Show checkbox only if the element is a terminal // Show checkbox only if the element is a terminal
if (m_element.data()->elementData().m_type == ElementData::Terminal) { if (m_element.data()->elementData().m_type == ElementData::Terminal) {
ui->m_auto_num_locked_cb->setVisible(true); ui->m_auto_num_locked_cb->setVisible(true);
m_potential_isolating_cb->setVisible(true);
} else { } else {
ui->m_auto_num_locked_cb->setVisible(false); ui->m_auto_num_locked_cb->setVisible(false);
m_potential_isolating_cb->setVisible(false);
} }
} }
/** /**
@brief ElementInfoWidget::infoPartWidgetForKey @brief ElementInfoWidget::infoPartWidgetForKey
@param key @param key
@@ -243,6 +262,12 @@ void ElementInfoWidget::updateUi()
if (m_element->elementData().m_type == ElementData::Terminal) { if (m_element->elementData().m_type == ElementData::Terminal) {
QString lock_value = element_info.value(QStringLiteral("auto_num_locked")).toString(); QString lock_value = element_info.value(QStringLiteral("auto_num_locked")).toString();
ui->m_auto_num_locked_cb->setChecked(lock_value == QLatin1String("true")); ui->m_auto_num_locked_cb->setChecked(lock_value == QLatin1String("true"));
// English: Load the potential isolating status from the element information mapping
if (m_potential_isolating_cb) {
QString isolating_value = element_info.value(QStringLiteral("potential_isolating")).toString();
m_potential_isolating_cb->setChecked(isolating_value == QLatin1String("true"));
}
} }
if (m_live_edit) { if (m_live_edit) {
@@ -275,6 +300,10 @@ DiagramContext ElementInfoWidget::currentInfo() const
// Save the auto numbering lock status // Save the auto numbering lock status
if (m_element->elementData().m_type == ElementData::Terminal) { if (m_element->elementData().m_type == ElementData::Terminal) {
info_.addValue(QStringLiteral("auto_num_locked"), ui->m_auto_num_locked_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); info_.addValue(QStringLiteral("auto_num_locked"), ui->m_auto_num_locked_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
if (m_potential_isolating_cb) {
info_.addValue(QStringLiteral("potential_isolating"), m_potential_isolating_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
}
} }
return info_; return info_;
} }
+2
View File
@@ -27,6 +27,7 @@ class Element;
class QUndoCommand; class QUndoCommand;
class ElementInfoPartWidget; class ElementInfoPartWidget;
class ChangeElementInformationCommand; class ChangeElementInformationCommand;
class QCheckBox;
namespace Ui { namespace Ui {
class ElementInfoWidget; class ElementInfoWidget;
@@ -71,6 +72,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
private: private:
Ui::ElementInfoWidget *ui; Ui::ElementInfoWidget *ui;
QList <ElementInfoPartWidget *> m_eipw_list; QList <ElementInfoPartWidget *> m_eipw_list;
QCheckBox *m_potential_isolating_cb = nullptr;
bool m_first_activation; bool m_first_activation;
bool m_ui_builded = false; bool m_ui_builded = false;
}; };