[Libreoffice-commits] core.git: vcl/unx

Julien Nabet serval2412 at yahoo.fr
Fri Sep 11 13:58:20 PDT 2015


 vcl/unx/kde/UnxCommandThread.cxx         |   35 +++++++++++++------------------
 vcl/unx/kde/UnxCommandThread.hxx         |    1 
 vcl/unx/kde/fpicker/kdecommandthread.cxx |    1 
 vcl/unx/kde/fpicker/kdecommandthread.hxx |    1 
 vcl/unx/kde/fpicker/kdefilepicker.cxx    |   31 +++++++++++++++++++++++++++
 5 files changed, 49 insertions(+), 20 deletions(-)

New commits:
commit fb1e645e4a5334e75cc594cf89c0540c6d23b0c6
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Wed Jul 15 11:58:33 2015 +0200

    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 at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/unx/kde/UnxCommandThread.cxx b/vcl/unx/kde/UnxCommandThread.cxx
index b7c4a86..df3a01499 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 c2571c5..da17b60 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 6f44117..b30f3e7 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 b795b18..a0f1023 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 e2baaae..766bd38 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


More information about the Libreoffice-commits mailing list