@ -147,16 +147,17 @@ namespace GraphCanvas
return true ;
return true ;
}
}
QString test = model - > data ( index ) . toString ( ) ;
QString test = model - > data ( index ) . toString ( ) ;
bool showRow = false ;
bool showRow = false ;
int regexIndex = test. lastIndexOf ( m_filterRegex ) ;
int regexIndex = m_filterRegex. indexIn ( test ) ;
if ( regexIndex > = 0 )
if ( regexIndex > = 0 )
{
{
showRow = true ;
showRow = true ;
AZStd : : pair < int , int > highlight ( regexIndex , m_filter . size ( ) ) ;
AZStd : : pair < int , int > highlight ( regexIndex , m_filter Regex. matchedLength ( ) ) ;
currentItem - > SetHighlight ( highlight ) ;
currentItem - > SetHighlight ( highlight ) ;
}
}
else
else
@ -283,8 +284,20 @@ namespace GraphCanvas
void NodePaletteSortFilterProxyModel : : SetFilter ( const QString & filter )
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
m_filterRegex = QRegExp ( m_filter , Qt : : CaseInsensitive ) ;
// Then ignore all whitespace by adding \s* (regex optional whitespace match) in between every other character.
// We use \s* instead of simply removing all whitespace from the filter and node-names in order to preserve the node-name and accurately highlight the matching portion.
// Example: "OnGraphStart" or "On Graph Start"
m_filter = QRegExp : : escape ( filter . simplified ( ) . replace ( " " , " " ) ) ;
QString regExIgnoreWhitespace ( m_filter [ 0 ] ) ;
for ( int i = 1 ; i < m_filter . size ( ) ; + + i )
{
regExIgnoreWhitespace . append ( " \\ s* " ) ;
regExIgnoreWhitespace . append ( m_filter [ i ] ) ;
}
m_filterRegex = QRegExp ( regExIgnoreWhitespace , Qt : : CaseInsensitive ) ;
}
}
void NodePaletteSortFilterProxyModel : : ClearFilter ( )
void NodePaletteSortFilterProxyModel : : ClearFilter ( )