Bug fix 369542
Needs ReviewPublic

Authored by jivatotin on Jan 3 2018, 6:22 PM.

Details

Summary

BUG: 369542

Add requested filter to
KUrlRequester::setFilter

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
jivatotin requested review of this revision.Jan 3 2018, 6:22 PM
jivatotin created this revision.
stikonas edited reviewers, added: stikonas, trufanov; removed: KDE Developers.Jan 3 2018, 6:47 PM
stikonas added a reviewer: marten.

Well, I must say again, thank you. :)

Function TorrentFileFilter is not working at all, so it's better to fix it.

ktorrent/CMakeLists.txt
19 ↗(On Diff #24680)

Don't change.

ktorrent/dialogs/importdialog.cpp
58

Don't change.

libktcore/interfaces/functions.cpp
182
QString ret = i18nc("*.torrent", "Torrents") + QLatin1String(" *.torrent");
183

Don't change.

184
ret += QLatin1String("\n") + i18n("All files") + QLatin1String(" *.*");

+ Correct indentation.

188–194

Remove

libktcore/interfaces/functions.h
40–44

Remove.

ngraham edited the summary of this revision. (Show Details)Jan 3 2018, 7:47 PM
marten added a comment.Jan 4 2018, 1:18 PM

Function TorrentFileFilter is not working at all, so it's better to fix it.

Was there anything wrong with TorrentFileFilter() originally? That seems to be generating a Qt format filter string "description (*.ext);;", which is suitable for passing to a QFileDialog. I assume that the suggested addition TorrentFileFilterKFileDialog() is to generate a KDE format filter string "*.ext|description\n", which is the format that KUrlRequester accepts. Changing TorrentFileFilter() will only work if it is is not used anywhere else.

If TorrentFileFilter() is not used elsewhere and can be repurposed to return a KDE filter string then see inline comments (assuming that they compile with the project's Qt string cast options).

libktcore/interfaces/functions.cpp
182

QString ret = QLatin1String("*.torrent|") + i18nc("*.torrent", "Torrents");

with correct indentation.

184

ret += QLatin1String("\n") + QLatin1String("*|") + i18n("All files");

with correct indentation.

But KUrlRequester::setFilter expects KFilter syntax. So split it will end up with a QStringList { "Torrents (*.torrent);; (*)" } which is invalid for QFileDialog::setNameFilters

marten added a comment.EditedJan 4 2018, 1:32 PM

To avoid the confusion, the best option may be to eliminate TorrentFileFilter() also and use MIME filters throughout (now that KUrlRequester::setMimeTypeFilters() is available).

I've tried setMimeTypeFilters, but the filter did not worked also.

jivatotin updated this revision to Diff 29947.Mar 19 2018, 9:18 PM

Added fix for:
https://bugs.launchpad.net/ubuntu/+source/ktorrent/+bug/1740737
https://bugs.kde.org/show_bug.cgi?id=384452

Please ignore changes for:
void setDialogMode();

Also ignore this files changes.
functions.h
functions.cpp
importdialog.cpp

Thank you.

marten resigned from this revision.Feb 27 2019, 4:33 PM

Not sure why I'm being asked to review?

Is this still actual or should be closed as completed?

I think, this can be closed as completed.

ngraham added a subscriber: ngraham.Dec 6 2019, 1:39 PM

https://bugs.kde.org/show_bug.cgi?id=369542 isn't closed, though. Should this be merged as-is, or does it need more review?