Bug 306219 - Expandable folders no longer works for network folders top level
Summary: Expandable folders no longer works for network folders top level
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: details mode (show other bugs)
Version: 2.1
Platform: Archlinux Linux
: NOR minor (vote)
Target Milestone: ---
Assignee: Dolphin Bug Assignee
Keywords: reproducible
Depends on:
Reported: 2012-09-03 23:57 UTC by gilbert.drew
Modified: 2013-06-26 20:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.0

POC expand folders with a different target url (2.84 KB, patch)
2013-06-24 16:42 UTC, Emmanuel Pescosta

Note You need to log in before you can comment on or make changes to this bug.
Description gilbert.drew 2012-09-03 23:57:24 UTC
Since dolphin 2.0, I can no longer expand network folders when select the "Network" place or use the remote:/ KIO.  This previously worked with 1.7.  I found this a great tool, e.g for comparing files across multiple hosts.

I should clarify that after selecting a specific network folder, expandable folders works fine.  This report is purely for the top level, "remote:/"

Reproducible: Always

Steps to Reproduce:
1. Add a network folder (any kind)
2. Enable expandable folders in details view preferences
3. Visit remote:/ 
Actual Results:  
The network folders don't expand

Expected Results:  
The network folders should be expandable
Comment 1 Frank Reininghaus 2012-11-29 08:21:12 UTC
Thanks for the bug report, I can confirm this. This is due to KFileItemModel not being clever enough to see that those things (which are not actually 'folders' even though they behave like folders from a user's point of view) should be expandable. Related to bug 304565.
Comment 2 Frank Reininghaus 2012-11-29 22:10:30 UTC
I just found out that this has been done on purpose: 

I can't comment on that at the moment though because I was not involved in the bug that this commit is supposed to fix.
Comment 3 gilbert.drew 2013-03-21 01:29:09 UTC
I noticed in dolphin 2.2 that comparing files now works in split view, so for this use case it's a good workaround and it's actually a better workflow for me too.

Keep up the great work!
Comment 4 Emmanuel Pescosta 2013-06-23 17:47:40 UTC
Shall we re-enable this feature (KFileItemModel problem is fixed) or shall we close this bug report?
Comment 5 Frank Reininghaus 2013-06-24 08:20:29 UTC
@Emmanuel: I must admit that I currently don't see at all where in the code we disable expanding folders when viewing 'remote:'. Do you have an idea? Is it maybe the kioslave that does not tell us that the items are like directories?
Comment 6 Emmanuel Pescosta 2013-06-24 11:05:04 UTC
In KFileItemModel::retrieveData:

    if (m_requestRole[IsExpandableRole]) {
        data.insert(sharedValue("isExpandable"), item.isDir() && item.url() == item.targetUrl());

Remove "&& item.url() == item.targetUrl()" and it works ;)

But we have a small problem here. The remote:/ kioslave openes other kioslaves and this fails because we use the KFileItem.url() in Dolphin, but here we need the KFileItem.targetUrl() in the whole KFileItemModel (This change fixes the problem but introduces another problem with the tags:/ kioslave when you have applied multiple tags to a file) - The dirlister reports the target url!
Comment 7 Emmanuel Pescosta 2013-06-24 16:42:53 UTC
Created attachment 80750 [details]
POC expand folders with a different target url
Comment 8 Frank Reininghaus 2013-06-25 08:36:25 UTC
Thanks for the patch. Does this patch work OK now (can't test it at the moment), or are there any problems left? If there are problems, then I'm not sure if it's worth investing lots of time into this feature (which is not extremely important IMHO). Or maybe one could check how it's done in KDirModel.
Comment 9 Emmanuel Pescosta 2013-06-25 09:20:33 UTC
Yes it works with this patch ;)

KDirModel stores all the data in a tree structure.

When you have a tree structure you can easily use the target url as "key", but in Dolphin we use a list of all items with the "normal" url as key. The target url approach (replace the "normal" url with the target url) in Dolphin can produce a key collision with e.g. nepomuk-tags, ...

Example (Target url problem):
A image file with the path "/home/dolphinuser/image.png" tagged with "Awesome Image" and "Another Tag".

   * Tree (With "key": target url):
tag:/ -|- Awesome Image --- /home/dolphinuser/image.png
          |- Another Tag --- /home/dolphinuser/image.png

Always obvious!

    * Dolphin (With key: target url):
tag:/Awesome Image 
/home/dolphinuser/image.png -> Parent item "tag:/Awesome Image"
tag:/Another Tag
/home/dolphinuser/image.png -> Parent item "tag:/Another Tag"   [FAIL]

And here you can see the problem, there are two "/home/dolphinuser/image.png" entries. Dolphin only adds the first "/home/dolphinuser/image.png" to the list -> the "Another Tag" has no item.

So the solution is: 
Use Dolphin's current approach ("normal" url as key) + create a list for target url to "normal" url mapping for items with url != target url. So when the dir lister sends us the directory url (is always the target url of a item), we use the url mapping table to get the right "Dolphin internal" directory url.
Comment 10 Frank Reininghaus 2013-06-25 17:58:21 UTC
All right, thanks for the explanation. Well, if it works, then I don't see why we should not re-enable that feature. However, I'm wondering if we really need two different members m_expandedDirs and m_expandedDirsTargetUrl. Couldn't it be done with just one hash? In the case that the "target URL" is the URL, key and value would just be equal.
Comment 11 Emmanuel Pescosta 2013-06-26 20:10:12 UTC
Git commit ad1c3a293d791e4c647a54ceb9a86b7492b2ef01 by Emmanuel Pescosta.
Committed on 26/06/2013 at 20:04.
Pushed by emmanuelp into branch 'master'.

Re-enable expandable folders for network top level folders (remote:/)

Added a hash table for target url to url mapping. So when the dir lister
sends us the target url as directory url, we can use the url mapping table
to get the right "Dolphin internal" directory url, which is the non-target url.
FIXED-IN: 4.11.0
REVIEW: 111252

M  +16   -8    dolphin/src/kitemviews/kfileitemmodel.cpp
M  +2    -2    dolphin/src/kitemviews/kfileitemmodel.h