Changeset View
Changeset View
Standalone View
Standalone View
src/core/kcoredirlister.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | #include <klocalizedstring.h> | 26 | #include <klocalizedstring.h> | ||
27 | #include <kio/listjob.h> | 27 | #include <kio/listjob.h> | ||
28 | #include "kprotocolmanager.h" | 28 | #include "kprotocolmanager.h" | ||
29 | #include "kmountpoint.h" | 29 | #include "kmountpoint.h" | ||
30 | #include "kiocoredebug.h" | 30 | #include "kiocoredebug.h" | ||
31 | #include "../pathhelpers_p.h" | 31 | #include "../pathhelpers_p.h" | ||
32 | 32 | | |||
33 | #include <QRegExp> | 33 | #include <QRegularExpression> | ||
34 | #include <QFileInfo> | 34 | #include <QFileInfo> | ||
35 | #include <QFile> | 35 | #include <QFile> | ||
36 | #include <QTextStream> | 36 | #include <QTextStream> | ||
37 | #include <QDir> | 37 | #include <QDir> | ||
38 | #include <qmimedatabase.h> | 38 | #include <qmimedatabase.h> | ||
39 | 39 | | |||
40 | #include <list> | 40 | #include <list> | ||
41 | 41 | | |||
▲ Show 20 Lines • Show All 2255 Lines • ▼ Show 20 Line(s) | 2293 | { | |||
2297 | 2297 | | |||
2298 | d->prepareForSettingsChange(); | 2298 | d->prepareForSettingsChange(); | ||
2299 | 2299 | | |||
2300 | d->settings.lstFilters.clear(); | 2300 | d->settings.lstFilters.clear(); | ||
2301 | d->nameFilter = nameFilter; | 2301 | d->nameFilter = nameFilter; | ||
2302 | // Split on white space | 2302 | // Split on white space | ||
2303 | const QStringList list = nameFilter.split(QLatin1Char(' '), QString::SkipEmptyParts); | 2303 | const QStringList list = nameFilter.split(QLatin1Char(' '), QString::SkipEmptyParts); | ||
2304 | for (const QString &filter : list) { | 2304 | for (const QString &filter : list) { | ||
2305 | d->settings.lstFilters.append(QRegExp(filter, Qt::CaseInsensitive, QRegExp::Wildcard)); | 2305 | d->settings.lstFilters.append( | ||
2306 | QRegularExpression(QRegularExpression::wildcardToRegularExpression(filter), | ||||
dfaure: I think you said this would anchor twice, in another review? Needs to be fixed then.
(Good for… | |||||
Right. (I searched through all the porting commits, I missed this one as it hasn't committed yet...). ahmadsamir: Right. (I searched through all the porting commits, I missed this one as it hasn't committed… | |||||
2307 | QRegularExpression::CaseInsensitiveOption)); | ||||
2306 | } | 2308 | } | ||
2307 | } | 2309 | } | ||
2308 | 2310 | | |||
2309 | QString KCoreDirLister::nameFilter() const | 2311 | QString KCoreDirLister::nameFilter() const | ||
2310 | { | 2312 | { | ||
2311 | return d->nameFilter; | 2313 | return d->nameFilter; | ||
2312 | } | 2314 | } | ||
2313 | 2315 | | |||
Show All 30 Lines | |||||
2344 | 2346 | | |||
2345 | QStringList KCoreDirLister::mimeFilters() const | 2347 | QStringList KCoreDirLister::mimeFilters() const | ||
2346 | { | 2348 | { | ||
2347 | return d->settings.mimeFilter; | 2349 | return d->settings.mimeFilter; | ||
2348 | } | 2350 | } | ||
2349 | 2351 | | |||
2350 | bool KCoreDirLister::matchesFilter(const QString &name) const | 2352 | bool KCoreDirLister::matchesFilter(const QString &name) const | ||
2351 | { | 2353 | { | ||
2352 | return doNameFilter(name, d->settings.lstFilters); | 2354 | for (const QRegularExpression &filter : d->settings.lstFilters) { | ||
2355 | if (filter.match(name).hasMatch()) { | ||||
2356 | return true; | ||||
2357 | } | ||||
2358 | } | ||||
2359 | | ||||
2360 | return false; | ||||
2353 | } | 2361 | } | ||
2354 | 2362 | | |||
2355 | bool KCoreDirLister::matchesMimeFilter(const QString &mime) const | 2363 | bool KCoreDirLister::matchesMimeFilter(const QString &mime) const | ||
2356 | { | 2364 | { | ||
2357 | return doMimeFilter(mime, d->settings.mimeFilter) && | 2365 | return doMimeFilter(mime, d->settings.mimeFilter) && | ||
2358 | d->doMimeExcludeFilter(mime, d->settings.mimeExcludeFilter); | 2366 | d->doMimeExcludeFilter(mime, d->settings.mimeExcludeFilter); | ||
2359 | } | 2367 | } | ||
2360 | 2368 | | |||
▲ Show 20 Lines • Show All 453 Lines • Show Last 20 Lines |
I think you said this would anchor twice, in another review? Needs to be fixed then.
(Good for readability!)