Bug 185463 - KFileDialog::getSaveUrl() and similar will not accept a non-local start directory
Summary: KFileDialog::getSaveUrl() and similar will not accept a non-local start direc...
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-24 18:58 UTC by Jonathan Marten
Modified: 2009-07-20 11:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed patch (595 bytes, patch)
2009-02-24 18:59 UTC, Jonathan Marten
Details
Updated patch (682 bytes, patch)
2009-02-25 18:11 UTC, Jonathan Marten
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Marten 2009-02-24 18:58:28 UTC
Version:            (using Devel)
OS:                Linux
Installed from:    Compiled sources

If a non-local 'dir' parameter is specified to KFileDialog::getSaveUrl() - and possibly getSaveFileName() and getSaveFilenameWid() also - the remote protocol is lost and the local directory of the remote URL's path is selected.

For example, if a starting directory of "ftp://user@hostname/home/user/filename" is specified, the dialogue opens with "/home/user" listed and "filename" selected.  Clicking "Save" tries to save to the local file, not via the ftp protocol.

KFileDialog::getSaveurl() does:

    bool defaultDir = dir.isEmpty();
    bool specialDir = !defaultDir && dir.protocol()=="kfiledialog";
    KFileDialog dlg(specialDir ? dir : KUrl(), filter, parent);
    if ( !specialDir )
        dlg.setSelection( dir.url() );

KFileWidget::setSelection(url) calls KFileWidgetPrivate::setLocationText(url), which in turn calls KFileWidget::setURL(url.path()).  This discards the original protocol information from the URL and lists the local directory with that path.

Applying the attached patch to kdelibs/kfile/kfilewidget.cpp appears to solve the problem.  Could a kfile expert check it?
Comment 1 Jonathan Marten 2009-02-24 18:59:52 UTC
Created attachment 31612 [details]
Proposed patch
Comment 2 Jonathan Marten 2009-02-25 18:11:57 UTC
Created attachment 31635 [details]
Updated patch

The previous patch doesn't work in the case where no starting location but only a file name is specified - it selects the root directory in that case.
Comment 3 Ben Boeckel 2009-05-28 06:36:17 UTC
Hmm, I see something like this when trying to open a remote file. I traverse to /home/boeckb/ on the remote server (via sftp) and when I choose the file, the places widget jump me to my local /home/boeckb/ causing the file to not be found. Bug #194385
Comment 4 Jonathan Marten 2009-07-20 11:16:29 UTC
Fixed by commit 951469.