Skip to content

Commit b4f51e1

Browse files
raymentpaceholder
authored andcommitted
Fixed broken context search and hide empty categories from filter.
Searching through the context menu was broken after 883e8a0 due to a mis-comparison on node data that is never inserted. This has been fixed by correctly comparing QTreeWidgetItem::text. Furthermore, the filtering system has been changed to hide empty categories, showing only those that are relevant (contain matching nodes). Signed-off-by: Finn Rayment <finn@rayment.fr>
1 parent 2dc6825 commit b4f51e1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/DataFlowGraphicsScene.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,24 @@ createSceneMenu(QPointF const scenePos)
140140
connect(txtBox, &QLineEdit::textChanged,
141141
[treeView](const QString& text)
142142
{
143+
QTreeWidgetItemIterator categoryIt(treeView, QTreeWidgetItemIterator::HasChildren);
144+
while (*categoryIt)
145+
(*categoryIt++)->setHidden(true);
143146
QTreeWidgetItemIterator it(treeView, QTreeWidgetItemIterator::NoChildren);
144147
while (*it)
145148
{
146-
auto modelName = (*it)->data(0, Qt::UserRole).toString();
149+
auto modelName = (*it)->text(0);
147150
const bool match = (modelName.contains(text, Qt::CaseInsensitive));
148151
(*it)->setHidden(!match);
149-
152+
if (match)
153+
{
154+
QTreeWidgetItem *parent = (*it)->parent();
155+
while (parent)
156+
{
157+
parent->setHidden(false);
158+
parent = parent->parent();
159+
}
160+
}
150161
++it;
151162
}
152163
});

0 commit comments

Comments
 (0)