diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2015-07-15 11:58:33 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-09-11 20:57:57 +0000 |
commit | fb1e645e4a5334e75cc594cf89c0540c6d23b0c6 (patch) | |
tree | d325840570c7506136ecc300c9cd3f568a58efc0 /vcl/unx/kde | |
parent | 013f84d06f7ad76d72b863170891589c3504508c (diff) |
getFiles refactoring: kde part
1) kdecommandthread part
before:
getFiles retrieves all files with:
First element = path only of the files
other elements = file names (without path)
after:
Add getSelectedFiles which retrieves all files with their url
getFiles uses getSelectedFiles and truncates to 1 entry if more than 1 entry
2) kdefilepicker part
before:
getFiles case retrieves all files with names including path
after:
add getSelectedFiles case which retrieves all files with names including path
change getFiles to retrieve only the first file (with path)
See http://nabble.documentfoundation.org/Dev-f1639786.html for discussion
Change-Id: I73cf00e7c03a1f2379f4628b5d7f12418029cca1
Reviewed-on: https://gerrit.libreoffice.org/17064
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl/unx/kde')
-rw-r--r-- | vcl/unx/kde/UnxCommandThread.cxx | 35 | ||||
-rw-r--r-- | vcl/unx/kde/UnxCommandThread.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde/fpicker/kdecommandthread.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde/fpicker/kdecommandthread.hxx | 1 | ||||
-rw-r--r-- | vcl/unx/kde/fpicker/kdefilepicker.cxx | 31 |
5 files changed, 49 insertions, 20 deletions
diff --git a/vcl/unx/kde/UnxCommandThread.cxx b/vcl/unx/kde/UnxCommandThread.cxx index b7c4a868289d..df3a01499b42 100644 --- a/vcl/unx/kde/UnxCommandThread.cxx +++ b/vcl/unx/kde/UnxCommandThread.cxx @@ -100,34 +100,29 @@ OUString SAL_CALL UnxFilePickerCommandThread::getDirectory() return m_aGetDirectory; } -uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getFiles() +uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getSelectedFiles() { ::osl::MutexGuard aGuard( m_aMutex ); sal_Int32 nSize = m_aGetFiles.size(); - uno::Sequence< OUString > aFiles( ( nSize > 1 )? nSize + 1: nSize ); + uno::Sequence< OUString > aFiles( nSize ); - if ( nSize == 1 ) - aFiles[0] = m_aGetFiles.front(); - else if ( nSize > 1 ) + size_t nIdx = 0; + for ( ::std::list< OUString >::const_iterator it = m_aGetFiles.begin(); + it != m_aGetFiles.end(); ++it, ++nIdx ) { - // First entry in the sequence must be the dirname, the others are the - // filenames, so we have to rearrange the list... - - OUString aFront = m_aGetFiles.front(); - sal_Int32 nLastSlash = aFront.lastIndexOf( '/' ); + aFiles[nIdx] = *it; + } - aFiles[0] = ( nLastSlash >= 0 )? aFront.copy( 0, nLastSlash ): OUString(); - ++nLastSlash; + return aFiles; +} +uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getFiles() +{ + ::osl::MutexGuard aGuard( m_aMutex ); - sal_Int32 nIdx = 1; - for ( ::std::list< OUString >::const_iterator it = m_aGetFiles.begin(); - it != m_aGetFiles.end(); ++it, ++nIdx ) - { - sal_Int32 nLength = (*it).getLength() - nLastSlash; - aFiles[nIdx] = ( nLength >= 0 )? (*it).copy( nLastSlash, nLength ): OUString(); - } - } + uno::Sequence< OUString > aFiles = getSelectedFiles(); + if (aFiles.getLength() > 1) + aFiles.realloc(1); // we just want the first entry here return aFiles; } diff --git a/vcl/unx/kde/UnxCommandThread.hxx b/vcl/unx/kde/UnxCommandThread.hxx index c2571c588a21..da17b60001c3 100644 --- a/vcl/unx/kde/UnxCommandThread.hxx +++ b/vcl/unx/kde/UnxCommandThread.hxx @@ -109,6 +109,7 @@ public: OUString SAL_CALL getDirectory(); ::osl::Condition& SAL_CALL getFilesCondition() { return m_aGetFilesCondition; } + ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSelectedFiles(); ::com::sun::star::uno::Sequence< OUString > SAL_CALL getFiles(); ::osl::Condition& SAL_CALL getValueCondition() { return m_aGetValueCondition; } diff --git a/vcl/unx/kde/fpicker/kdecommandthread.cxx b/vcl/unx/kde/fpicker/kdecommandthread.cxx index 6f4411791a96..b30f3e72e314 100644 --- a/vcl/unx/kde/fpicker/kdecommandthread.cxx +++ b/vcl/unx/kde/fpicker/kdecommandthread.cxx @@ -57,6 +57,7 @@ KDECommandEvent::KDECommandEvent( const QString &qCommand, QStringList *pStringL { "getDirectory", GetDirectory }, { "setDirectory", SetDirectory }, { "getFiles", GetFiles }, + { "getSelectedFiles", GetSelectedFiles }, { "setTitle", SetTitle }, { "setType", SetType }, { "setDefaultName", SetDefaultName }, diff --git a/vcl/unx/kde/fpicker/kdecommandthread.hxx b/vcl/unx/kde/fpicker/kdecommandthread.hxx index b795b1828186..a0f10236b344 100644 --- a/vcl/unx/kde/fpicker/kdecommandthread.hxx +++ b/vcl/unx/kde/fpicker/kdecommandthread.hxx @@ -60,6 +60,7 @@ public: SetDirectory, GetFiles, + GetSelectedFiles, SetTitle, SetType, diff --git a/vcl/unx/kde/fpicker/kdefilepicker.cxx b/vcl/unx/kde/fpicker/kdefilepicker.cxx index e2baaae6a5cd..766bd38e9893 100644 --- a/vcl/unx/kde/fpicker/kdefilepicker.cxx +++ b/vcl/unx/kde/fpicker/kdefilepicker.cxx @@ -330,6 +330,37 @@ void KDEFileDialog::customEvent( QCustomEvent *pEvent ) { KURL::List qList( selectedURLs() ); for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it ) + { + appendURL( qString, (*it) ); + break; // we just want the first element + } + } + else + { + // we have to return the selected files anyway + const KFileItemList *pItems = ops->selectedItems(); + for ( KFileItemListIterator it( *pItems ); it.current(); ++it ) + { + appendURL( qString, (*it)->url() ); + break; // we just want the first element + } + } + + sendCommand( qString ); + setCanNotifySelection( true ); + } + break; + case KDECommandEvent::GetSelectedFiles: + { + QString qString; + qString.reserve( 1024 ); + + qString.append( "files" ); + + if ( result() == QDialog::Accepted ) + { + KURL::List qList( selectedURLs() ); + for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it ) appendURL( qString, (*it) ); } else |