QRegularExpression wildcard matching.
This commit is contained in:
parent
e280c309cb
commit
0335bcf571
|
@ -32,12 +32,15 @@
|
|||
#include <QLineEdit>
|
||||
#include <QList>
|
||||
#include <QMimeData>
|
||||
#include <QRegExp>
|
||||
#include <QSizePolicy>
|
||||
#include <QToolButton>
|
||||
#include <QUrl>
|
||||
#include <Qt>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
#include <QRegExp>
|
||||
#endif
|
||||
|
||||
VPE::VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory)
|
||||
: QWidget(parent), CurrentFilePath(), ToolButton(nullptr), FileLineEdit(nullptr), FileDialogFilter(), FilterList(),
|
||||
Directory(is_directory)
|
||||
|
@ -251,14 +254,16 @@ bool VPE::VFileEditWidget::checkFileFilter(const QString& file) const
|
|||
return false;
|
||||
}
|
||||
|
||||
for (auto &tmpFilter : FilterList)
|
||||
return std::any_of(FilterList.begin(), FilterList.end(), [file](const QString &tmpFilter)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
const QString wildcardFilter = QRegularExpression::wildcardToRegularExpression(tmpFilter);
|
||||
QRegularExpression tmpRegExpFilter(QRegularExpression::anchoredPattern(wildcardFilter),
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
return tmpRegExpFilter.match(file).hasMatch();
|
||||
#else
|
||||
QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
if (tmpRegExpFilter.exactMatch(file))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return tmpRegExpFilter.exactMatch(file);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user