From a10e1d9a8753757c12c261bea035c52403391197 Mon Sep 17 00:00:00 2001 From: Gene Walters Date: Fri, 4 Jun 2021 14:10:34 -0700 Subject: [PATCH] Script Canvas node palette search will ignore whitespace --- .../Model/NodePaletteSortFilterProxyModel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp index ca5e962685..9e1e0688b4 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp @@ -147,8 +147,9 @@ namespace GraphCanvas return true; } - QString test = model->data(index).toString(); - + // Ignore whitespace when filtering node names + QString test = model->data(index).toString().simplified().replace(" ", ""); + bool showRow = false; int regexIndex = test.lastIndexOf(m_filterRegex); @@ -283,7 +284,10 @@ namespace GraphCanvas void NodePaletteSortFilterProxyModel::SetFilter(const QString& filter) { - m_filter = QRegExp::escape(filter); + // Remove whitespace and escape() so every regexp special character is escaped with a backslash + // Removing the whitespace will allow us to find nodes even if the node is written with or without spaces. + // Example: "OnGraphStart" or "On Graph Start" + m_filter = QRegExp::escape(filter.simplified().replace(" ", "")); m_filterRegex = QRegExp(m_filter, Qt::CaseInsensitive); }