BUG: 369542
Add requested filter to
KUrlRequester::setFilter
Lint Skipped |
Unit Tests Skipped |
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. |
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
To avoid the confusion, the best option may be to eliminate TorrentFileFilter() also and use MIME filters throughout (now that KUrlRequester::setMimeTypeFilters() is available).
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.
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?