Bug 369542 - Anomaly: KUrlRequester::setFilter() still needs a KDE format filter string
Summary: Anomaly: KUrlRequester::setFilter() still needs a KDE format filter string
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-29 20:26 UTC by Jonathan Marten
Modified: 2023-06-23 15:50 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2016-09-29 20:26:52 UTC
KFileDialog is now deprecated in favour of QFileDialog, which takes a Qt format filter string ("description (*.ext);;").  However, the only way to set a filter on a KUrlRequester is by using KUrlRequester:setFilter(), which still requires a KDE format filter string ("*.ext|description\n").  This appears to be the only place within Frameworks libraries (excepting kdelibs4support) where the KDE filter string is still used.

As well as being an anomaly, this is a problem in the case where an application may use both QFileDialog and KUrlRequester, because it is not possible to share the same filter strings between both.  This is a source of duplication and possible out-of-sync errors.

Changing KUrlRequester::setFilter() to take a Qt format filter string would be an incompatible API change, unless it could be reliably autodetected.  One possible option to fix this would be to deprecate KUrlRequester::setFilter() and add KUrlRequester::setNameFilter() analogous to QFileDialog::setNameFilter, taking a Qt format filter string.


Reproducible: Always
Comment 1 Jonathan Marten 2017-02-12 19:18:36 UTC
KUrlRequester::setMimeTypeFilters() was added by https://phabricator.kde.org/D4431, which partly solves the problem.  Leaving this bug report open pending a decision as to whether to deprecate setFilter().
Comment 2 postix 2019-11-21 19:57:45 UTC
There's a fix hanging in the pipeline: https://phabricator.kde.org/D9645
But it's questionable if it's still needed.
Comment 3 Bug Janitor Service 2019-12-06 04:33:09 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Jonathan Marten 2019-12-09 20:25:08 UTC
Confirming because still an API anomaly.
Comment 5 Friedrich W. H. Kossebau 2023-06-14 20:36:27 UTC
https://invent.kde.org/frameworks/kio/-/merge_requests/1321 is a MR to approach this issue.
Comment 6 Bug Janitor Service 2023-06-15 11:56:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1326
Comment 7 Friedrich W. H. Kossebau 2023-06-23 14:23:32 UTC
Git commit 6e945ed1dc01ffbaf30455341cff0ba945877255 by Friedrich W. H. Kossebau.
Committed on 23/06/2023 at 14:04.
Pushed by kossebau into branch 'kf5'.

KUrlRequester::setFilter: note special filter syntax, allow unnamed filters

The API dox referred to QFileDialog::setNameFilters for the syntax to use
which is "Comment (file pattern)". The internal logic though expects
the old KDE style syntax "file pattern|Comment".

For more compatibility with Qt also allow name/comment-less filters by
handling of non-existing "|" hit in the filter parsing.
Related: bug 464350

M  +6    -4    src/widgets/kurlrequester.cpp
M  +8    -2    src/widgets/kurlrequester.h

https://invent.kde.org/frameworks/kio/-/commit/6e945ed1dc01ffbaf30455341cff0ba945877255
Comment 8 Friedrich W. H. Kossebau 2023-06-23 14:31:01 UTC
Git commit a7e865aa41acdb83dd625c68dd8f0d16e7f6dc0d by Friedrich W. H. Kossebau.
Committed on 23/06/2023 at 14:26.
Pushed by kossebau into branch 'master'.

KUrlRequester::setFilter: note special filter syntax, allow unnamed filters

The API dox referred to QFileDialog::setNameFilters for the syntax to use
which is "Comment (file pattern)". The internal logic though expects
the old KDE style syntax "file pattern|Comment".

For more compatibility with Qt also allow name/comment-less filters by
handling of non-existing "|" hit in the filter parsing.
Related: bug 464350
(cherry picked from commit 6e945ed1dc01ffbaf30455341cff0ba945877255)

M  +6    -4    src/widgets/kurlrequester.cpp
M  +8    -2    src/widgets/kurlrequester.h

https://invent.kde.org/frameworks/kio/-/commit/a7e865aa41acdb83dd625c68dd8f0d16e7f6dc0d
Comment 9 Friedrich W. H. Kossebau 2023-06-23 15:43:44 UTC
Git commit ee89c7a9e673f5734cd4f5fb50ebadc6915050eb by Friedrich W. H. Kossebau.
Committed on 23/06/2023 at 14:29.
Pushed by kossebau into branch 'kf5'.

Add KUrlRequester::nameFilters, deprecate KUrlRequester::filter

For consistency with QFileDialog API and better naming given
there are 2 kinds of filters supported, by name and by MIME type.

M  +109  -0    autotests/kurlrequestertest.cpp
M  +1    -1    src/widgets/CMakeLists.txt
M  +62   -7    src/widgets/kurlrequester.cpp
M  +35   -1    src/widgets/kurlrequester.h

https://invent.kde.org/frameworks/kio/-/commit/ee89c7a9e673f5734cd4f5fb50ebadc6915050eb
Comment 10 Friedrich W. H. Kossebau 2023-06-23 15:50:41 UTC
Git commit 8a1cc098cec9937bb11206f555a9bb978fbaf981 by Friedrich W. H. Kossebau.
Committed on 23/06/2023 at 14:32.
Pushed by kossebau into branch 'master'.

Add KUrlRequester::nameFilters, deprecate KUrlRequester::filter

For consistency with QFileDialog API and better naming given
there are 2 kinds of filters supported, by name and by MIME type.

M  +109  -0    autotests/kurlrequestertest.cpp
M  +1    -1    src/widgets/CMakeLists.txt
M  +62   -7    src/widgets/kurlrequester.cpp
M  +39   -1    src/widgets/kurlrequester.h

https://invent.kde.org/frameworks/kio/-/commit/8a1cc098cec9937bb11206f555a9bb978fbaf981