openPath() doesn't work for non-child directories

Bug #1195531 reported by Michael Spencer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu File Manager App
Fix Released
Low
Carlos Jose Mazieri

Bug Description

In FolderListModel, openPath() doesn't work correctly when trying to open a directory that isn't a child of the current directory.

For example, if the current directory is "/home/user",

openPath("/home/user/Documents") works, but
openPath("/home") does not.

Revision history for this message
Victor Thompson (vthompson) wrote :

Why can't you just let the user enter the full path and then try to set FolderListModel's path property? Maybe you can detect an error and alert the user somehow, otherwise the ListView should reload with the new destination.

One possible way you could test for an error would be to use the FolderListModel as a delegate (see lp:music-app which uses one) and parse the path (let's say it is /home/user/dir/) starting with "/" set as the path property. Then call openPath() with "home", if there is no error set the path property with "/home" and call openPath(), etc.

Revision history for this message
Victor Thompson (vthompson) wrote :

Sorry, I meant Repeater not "delegate". music-app's LibraryLoader.qml file has an example. Good luck!

Revision history for this message
Victor Thompson (vthompson) wrote :

Maybe you could even use this methodology to start with a typed "/" and autofill child directories... that'd be neat.

Revision history for this message
Victor Thompson (vthompson) wrote :
Changed in ubuntu-filemanager-app:
status: New → In Progress
importance: Undecided → Low
assignee: nobody → Carlos Jose Mazieri (carlos-mazieri)
Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

openPath() has been fixed and will be released soon.

For direcotories it allows entering:
               somelocaldir
               /home
               ..
               ../otherpath

For files:
              file
             /anypath/file
            ../file
            ../otherpath/file

Revision history for this message
Michael Spencer (ibelieve) wrote :

Victor, thanks for the suggestions and work. I'll take a look at incorporating your ideas into my merge request for an improved toolbar, which has a popover for accessing common places and going to a user-entered location.

Revision history for this message
Victor Thompson (vthompson) wrote :

While Carlos's changes to the behavior of openPath() should fix your issue, I'm not sure it'd be best to modify how openPath() works if we don't need to do so. The intent of this function is to open one of the child entries in the model. openIndex() is a similar function which can't be updated to allow any file path to be used. The change would make these two similar functions' use cases different. Also, it might not be ideal to allow a user of the plugin to open a binary or other file located in another directory. openPath("/sbin/reboot") for instance.

Also, using a separate model (as my branch does) would allow us to implement autofill for the user entered path. We wouldn't get that by simply modifying the FolderListModel plugin to allow free form navigation. We'd need a separate model.

Changed in ubuntu-filemanager-app:
status: In Progress → Fix Committed
Revision history for this message
Carlos Jose Mazieri (carlos-mazieri) wrote :

Victor, thanks for your suggestions, I have not looked at it yet, but I will.

You're right, using two models allows to implement autofill for the user inputs.

About openPath() open a binary:
         It uses QDesktopServices::openUrl(), I just tried and receive the message:
         The file file:///home/carlos/build-filemanager-Desktop-Debug/bazarrepo/test_folderlistmodel/simpleUI/simpleui is an executable program. For safety it will not be started.
         Yes, we should allow open a binary, maybe if it is a script we open it inside a terminal.

I have added test cases for these new functions, you guys can take a look on it.

Revision history for this message
Michael Spencer (ibelieve) wrote :

Victor, I've added path validation using your method - thanks! Just a question about the changes in your branch, what is the Repeater for?

Revision history for this message
Victor Thompson (vthompson) wrote :

The repeater probably isn't needed yet. I was going to try to get the autofill portion working. In order to get a list of child directories I'm pretty sure the best way of doing so is to load a Repeater with the new model and loop through the children.

Revision history for this message
Victor Thompson (vthompson) wrote :

I'd like to request that the fix for this be removed from the plugin and that this bug be changed to Opinion/Invalid.

Revision history for this message
Michael Spencer (ibelieve) wrote :

What good would removing the fix provide? In my opinion, openPath() - or some equivalent function that would only work for directories - should work just like directly setting the path, but would give an indication of whether it worked or not.

Revision history for this message
Victor Thompson (vthompson) wrote :

The intent is to open a path that is a child of the parent. There are other ways to determine if the path being set is valid. It might make more sense to provide a isPathValid() function that can be called before the path property is set. In either case, I would say this bug is invalid because it is out of the scope of what the intent of the function is to perform and there is no need for such a modification.

David Planella (dpm)
Changed in ubuntu-filemanager-app:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.