diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-08-25 17:50:50 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-08-26 12:54:53 +0200 |
commit | 35c0fb32cca60376bc55871eb04948b86870d04d (patch) | |
tree | d5c989b974af0589089d103c86703e3cddc59897 | |
parent | 613b5e45f5c2418fc7ea3b1faeda783929ad0a4e (diff) |
fpicker-kde-local-media2.diff: Handle media:/ files locally.
-rw-r--r-- | fpicker/source/unx/kde/kdefilepicker.cxx | 33 | ||||
-rw-r--r-- | fpicker/source/unx/kde/kdefilepicker.hxx | 1 |
2 files changed, 26 insertions, 8 deletions
diff --git a/fpicker/source/unx/kde/kdefilepicker.cxx b/fpicker/source/unx/kde/kdefilepicker.cxx index 7ebd79c1981f..2f55a29d8101 100644 --- a/fpicker/source/unx/kde/kdefilepicker.cxx +++ b/fpicker/source/unx/kde/kdefilepicker.cxx @@ -311,11 +311,8 @@ void FileDialog::customEvent( QCustomEvent *pEvent ) setCanNotifySelection( true ); exec(); -#if KDE_IS_VERSION(3,5,0) - KURL qLocalSelectedURL = KIO::NetAccess::mostLocalURL( selectedURL(), this ); -#else - KURL qLocalSelectedURL( selectedURL() ); -#endif + KURL qLocalSelectedURL = mostLocalURL( selectedURL() ); + qSelectedURL = addExtension( qLocalSelectedURL.url() ); QString qProtocol( qLocalSelectedURL.protocol() ); @@ -603,13 +600,33 @@ bool FileDialog::isSupportedProtocol( const QString &rProtocol ) const return false; } -QString FileDialog::localCopy( const QString &rFileName ) const +KURL FileDialog::mostLocalURL( const KURL &rURL ) const { #if KDE_IS_VERSION(3,5,0) - KURL qLocalURL = KIO::NetAccess::mostLocalURL( KURL( rFileName ), const_cast<FileDialog*>( this ) ); + KURL qMostLocalURL( KIO::NetAccess::mostLocalURL( rURL, const_cast<FileDialog*>( this ) ) ); + if ( qMostLocalURL.isLocalFile() ) + return qMostLocalURL; + else + { + // Terrible hack to get even non-existing media:// files right + qMostLocalURL.cd( ".." ); + KURL qMostLocalPath( KIO::NetAccess::mostLocalURL( qMostLocalURL, const_cast<FileDialog*>( this ) ) ); + if ( qMostLocalPath.isLocalFile() ) + { + qMostLocalPath.addPath( rURL.fileName() ); + return qMostLocalPath; + } + } +#endif + + return rURL; +} + +QString FileDialog::localCopy( const QString &rFileName ) const +{ + KURL qLocalURL = mostLocalURL( KURL( rFileName ) ); if ( qLocalURL.isLocalFile() ) return qLocalURL.url(); -#endif int nExtensionPos = rFileName.findRev( '/' ); if ( nExtensionPos >= 0 ) diff --git a/fpicker/source/unx/kde/kdefilepicker.hxx b/fpicker/source/unx/kde/kdefilepicker.hxx index b7d602a5eb69..2afa8e6a9acc 100644 --- a/fpicker/source/unx/kde/kdefilepicker.hxx +++ b/fpicker/source/unx/kde/kdefilepicker.hxx @@ -96,6 +96,7 @@ protected: bool isExecuting( void ) const { return m_bIsExecuting; } bool isSupportedProtocol( const QString &rProtocol ) const; + KURL mostLocalURL( const KURL &rURL ) const; QString localCopy( const QString &rFileName ) const; void setCanNotifySelection( bool bCanNotifySelection ) { m_bCanNotifySelection = bCanNotifySelection; } |