D26339: [KFileWidgets] Port QRegExp to QRegularExpression

David Faure noreply at phabricator.kde.org
Wed Jan 1 10:10:02 GMT 2020


dfaure requested changes to this revision.
dfaure added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> kdiroperator.cpp:1482
>  
> -            for (; it != supported.end(); ++it) {
> -                r.setPattern(*it);
> -
> -                QStringList result = mimeTypes.filter(r);
> -                if (!result.isEmpty()) {   // matches! -> we want previews
> +                result = mimeTypes.filter(re);
> +                if (!result.isEmpty()) {  // matches! -> we want previews

const QStringList result =

rather than declaring result before the loop.

But while we're here, shouldn't we use indexOf() instead of filter()? All we care for is "there is at least one match".

> kdiroperator.cpp:1491
> +            QRegularExpressionMatch match;
> +            QMimeType mType;
> +            QString mime;

declare where used

> kdiroperator.cpp:1492
> +            QMimeType mType;
> +            QString mime;
>              // find the mimetypes of all the filter-patterns

declare where used

(this also makes refactoring easier btw)

> kdiroperator.cpp:1509
> +                    re.setPattern(QRegularExpression::wildcardToRegularExpression(str));
> +                    match = re.match(mime);
> +                    if (match.hasMatch()) {

You could combine this with the next line and kill the "match" variable. More compact and more readable IMHO.

> kfilewidget.cpp:2458
> +
> +    QRegularExpression rx;
> +    QRegularExpressionMatch match;

declare where used

> kfilewidget.cpp:2463
> +                                        QRegularExpression::wildcardToRegularExpression(p)));
> +        match = rx.match(filename);
> +        if (match.hasMatch()) {

(same)

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D26339

To: ahmadsamir, dfaure, apol
Cc: kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200101/65b4b8a8/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list