D24741: Add a utility accessor to get a QUrl from a ResultSet::Result

Méven Car noreply at phabricator.kde.org
Thu Oct 17 19:47:17 BST 2019


meven added inline comments.

INLINE COMMENTS

> ivan wrote in resultset.h:78
> `url` or `resourceUrl`?
> 
> I hoped we are not going to have these problems after the death of Nepomuk. Thought file paths for files and urls for everything else would be a sane default. :)
> 
> Also, can you add a `TODO: KF6 rething the function names` for these two.

`url` makes more sense to me, no need to decorate it, this is idiomatic KDE/Qt. `toUrl` might make sense alternatively since it is not a free operation as it is a copy.

I am not too aware of the history around Nepomuk.

File paths for files and urls for everything else is fine internally but the API was not very clear about how to use it.
Given you would need to basically parse the resource to know which one it is, if you did not forget to do it in the first place.
That's why D22005 <https://phabricator.kde.org/D22005> happens.

IMO we would need a type dedicated for file path, that would be a wrapper around QString, something like C++17 https://en.cppreference.com/w/cpp/filesystem/path or Rust https://doc.rust-lang.org/std/path/struct.Path.html

While we are at it I could add a isPath() or similar to tell if resource contains a url or a path QDir::isAbsolutePath(resource()) basically.

About KF6 I would suggest resource would return something like std::variant<std::filesystem::path, QString> https://en.cppreference.com/w/cpp/utility/variant
Add a std::optionnal<QString> path() and make url std::optionnal<QUrl> could also be interesting.
Can't wait for KF6 C++17 !
I learned a lot of those modern C++ features first in Rust.

REPOSITORY
  R159 KActivities Statistics

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

To: meven, ivan
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/20191017/a7d8c1c4/attachment.html>


More information about the Kde-frameworks-devel mailing list