D25315: KDirModel: implement showing "/" as a root node, optionally
Raphael Rosch
noreply at phabricator.kde.org
Fri Feb 28 12:22:26 GMT 2020
rrosch added a comment.
Tested on patched KF5 5.64, on Fedora 30 (32bit)... root node shows up! I had to change the call in my code that was originally:
model->dirLister()->openUrl(QUrl::fromLocalFile("/"), KDirLister::Keep);
to
model->openUrl(QUrl::fromLocalFile("/"), KDirModel::ShowRoot);
and don't really know the implications of the change at this point. (Will it "Keep"? Does it matter that I now call the model's openURL vs the dirLister's?)
I couldn't however get the following to work:
QModelIndex index = getIndexFromUrl("/home/myuser");
if (index.isValid()) {
treeView->setRootIndex(index.parent());
}
Which should show the node for "/home" as the root, but is instead giving me a flat listing of all the child nodes without "/home" as the root. Am I doing something wrong here? That part is called on a slot for the signal `&KDirModel::expand`. (Also, it would be great to have a setRootPath() that works in conjunction to expandToUrl or openUrl, to save processing cycles wasted on loading the parts of the model that won't be shown in the new rootIndex, like https://doc.qt.io/qt-5/qfilesystemmodel.html#setRootPath )
As it is relevant, I also tested the patch at http://www.davidfaure.fr/2019/kdirmodel_haschildren.diff for `hasChildren()`, which works as expected! Thank you!
---
For the curious, I just downloaded the source rpm for `kf5-kio`, installed it as unprivileged user, edited the .spec file to include the raw diff here as a the //second// patch, and the raw diff for D25249 <https://phabricator.kde.org/D25249> as the //first// patch (and copying them to `~/rpmbuild/SOURCES/` of course). I also had to change the `Release: ` line to something greater than the one already there so it installs without conflicts (I changed mine from "1" to "2patched"). Then just
rpmbuild -bb ~/rpmbuild/SPECS/kf5-kio.spec
and install the relevant rpms. No need to rebuild all of KF5 from git (which I started to attempt and bailed pretty quickly after thinking this might be the easier/faster/less space-using way. Knowing this process will be useful for newcomers to help test features on their system without the daunting (and probably impossible due to limited space) task of compiling all of KF5. This could be added to the dev documentation somewhere.
In any case, thanks again for implementing the feature! (Next step is to try to follow the same procedure to test the "crash on close of view" fix you submitted for Qt5, thanks also for that!)
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D25315
To: dfaure, stefanocrocco, elvisangelaccio, meven, apol
Cc: rrosch, kde-frameworks-devel, LeGast00n, cblack, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200228/2beaea6f/attachment.html>
More information about the Kde-frameworks-devel
mailing list