mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-21 09:20:13 +00:00
Ensure input is a valid regexp before enabling regexp filter mode
Checking whether the input contains '*', '?' or '[' alone will not do since there can be files with '[' in their name. REVIEW: 120986 BUG: 340470 FIXED-IN: 14.12
This commit is contained in:
parent
36f571a0ce
commit
cbe1d6aca4
|
@ -43,10 +43,7 @@ void KFileItemModelFilter::setPattern(const QString& filter)
|
|||
m_pattern = filter;
|
||||
m_lowerCasePattern = filter.toLower();
|
||||
|
||||
m_useRegExp = filter.contains('*') ||
|
||||
filter.contains('?') ||
|
||||
filter.contains('[');
|
||||
if (m_useRegExp) {
|
||||
if (filter.contains('*') || filter.contains('?') || filter.contains('[')) {
|
||||
if (!m_regExp) {
|
||||
m_regExp = new QRegExp();
|
||||
m_regExp->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
@ -54,6 +51,9 @@ void KFileItemModelFilter::setPattern(const QString& filter)
|
|||
m_regExp->setPatternSyntax(QRegExp::WildcardUnix);
|
||||
}
|
||||
m_regExp->setPattern(filter);
|
||||
m_useRegExp = m_regExp->isValid();
|
||||
} else {
|
||||
m_useRegExp = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue