From 3c1c29f6c30b312503279cf34a471d783c52b04f Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Sun, 13 Sep 2026 21:32:34 +0200 Subject: [PATCH] connect searchfield --- sources/ui/plclinkwidget.cpp | 23 ++++++++++++++++++----- sources/ui/plclinkwidget.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sources/ui/plclinkwidget.cpp b/sources/ui/plclinkwidget.cpp index 4949be237..b0736f273 100644 --- a/sources/ui/plclinkwidget.cpp +++ b/sources/ui/plclinkwidget.cpp @@ -175,6 +175,7 @@ void PlcLinkWidget::buildPlcTree() { m_tree_widget->clear(); m_io_entry_hash.clear(); + m_linked_children.clear(); if (!m_element || !m_element->diagram() || !m_element->diagram()->project()) return; @@ -248,6 +249,7 @@ void PlcLinkWidget::buildPlcTree() // If this IO is already linked to a slave if (used_io_indices.contains(i)) { + m_linked_children.insert(child_item); if (m_hide_linked_cb->isChecked()) { child_item->setHidden(true); } else { @@ -288,6 +290,11 @@ void PlcLinkWidget::buildPlcTree() } } +bool PlcLinkWidget::isChildLinked(QTreeWidgetItem *child) const +{ + return m_linked_children.contains(child); +} + void PlcLinkWidget::hideButtons() { m_label->hide(); @@ -321,15 +328,21 @@ void PlcLinkWidget::on_m_search_field_textEdited(const QString &text) } } } - child->setHidden(!match); - if (match) any_child_visible = true; + bool hidden = m_hide_linked_cb->isChecked() && isChildLinked(child); + child->setHidden(!match || hidden); + if (match && !hidden) any_child_visible = true; } // Also check if parent label matches if (!text.isEmpty() && parent->text(0).contains(text, Qt::CaseInsensitive)) { - any_child_visible = true; - for (int j = 0; j < parent->childCount(); ++j) - parent->child(j)->setHidden(false); + for (int j = 0; j < parent->childCount(); ++j) { + QTreeWidgetItem *child = parent->child(j); + bool hidden = m_hide_linked_cb->isChecked() && isChildLinked(child); + if (!hidden) { + any_child_visible = true; + child->setHidden(false); + } + } } parent->setHidden(!any_child_visible); diff --git a/sources/ui/plclinkwidget.h b/sources/ui/plclinkwidget.h index a3f74ed20..37a4a9cb3 100644 --- a/sources/ui/plclinkwidget.h +++ b/sources/ui/plclinkwidget.h @@ -59,6 +59,7 @@ class PlcLinkWidget : public AbstractElementPropertiesEditorWidget void buildPlcTree(); void hideButtons(); void showButtons(); + bool isChildLinked(QTreeWidgetItem *child) const; private slots: void on_m_search_field_textEdited(const QString &text); @@ -82,6 +83,7 @@ class PlcLinkWidget : public AbstractElementPropertiesEditorWidget int ioIndex = -1; }; QHash m_io_entry_hash; + QSet m_linked_children; Element *m_element_to_link = nullptr; int m_pending_io_index = -1;