This moves the logic from KFileItem to KIO global private to make it available to KIO::iconNameForUrl
Details
Unittests still pass, adjusted the iconNameForUrl test
Diff Detail
- Repository
- R241 KIO
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
This reminds me that someone still needs to extend QStandardPaths to cover the other XDG paths such as templates, a thing I shoved to the side and then forgot about ^^
src/core/global.cpp | ||
---|---|---|
311 | should be a QStringLiteral. I don't see a QL1S version of inherits() |
Can't reproduce locally. Could it be that XDG dirs aren't properly setup on CI or something like that?
No XDG is well set up since everything else passes ;)
Actually I have the same error locally. Where does the string "folder-videos" come from?
That's in kioglobal_p.cpp mapped from MoviesLocation, so KIO::fileNameForUrl should return that.
It's also tested for in testIconNameForStandardPath (though here it's just $HOME + /Videos)
Ah I see.
The problem is that /home/dfaure/Videos (i.e. what is returned by QSP) does NOT exist (I guess I deleted it, can't remember).
I don't see anyone (neither iconNameForUrl nor iconForStandardPath) checking for existance, though, it would/should always return videos icon for a folder that potentially be in StandardPaths?
OK, not sure what happened, but something changed ~/.config/user-dirs.dirs and here's what happens now:
~/.config/user-dirs.dirs says
XDG_VIDEOS_DIR="$HOME/"
which leads to MoviesLocation returning /home/dfaure, so the code in iconForStandardPath() matches the home folder first and returns "user-home".
QDEBUG : KFileItemTest::testIconNameForUrl(videos) KFileItemTest::testIconNameForUrl: QUrl("file:///home/dfaure")
FAIL! : KFileItemTest::testIconNameForUrl(videos) Compared values are not the same
Actual (KIO::iconNameForUrl(url)): "user-home" Expected (expectedIcon) : "folder-videos"
... and when it's actually set to /home/dfaure/Videos, then KIO::iconNameForUrl skips the call to KIOPrivate::iconForStandardPath because of the mt.inherits(QLatin1String("inode/directory") check.
The mimetype is application/octet-stream (default mimetype) if the dir doesn't exist.
I'll commit a fix for both cases (equal to home and non-existent).