diff options
-rw-r--r-- | fpicker/source/office/RemoteFilesDialog.cxx | 9 | ||||
-rw-r--r-- | include/svtools/fileview.hxx | 2 | ||||
-rw-r--r-- | include/svtools/foldertree.hxx | 3 | ||||
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 15 | ||||
-rw-r--r-- | svtools/source/contnr/foldertree.cxx | 54 |
5 files changed, 69 insertions, 14 deletions
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index 5681efde578a..6078db45e4de 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -1078,8 +1078,6 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) OUString* sData = new OUString( rURL ); pRoot->SetUserData( static_cast< void* >( sData ) ); - m_pTreeView->Expand( pRoot ); - m_pName_ed->GrabFocus(); m_sLastServiceUrl = sURL; @@ -1088,8 +1086,13 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) } m_pPath->SetURL( rURL ); + m_pTreeView->SetSelectHdl( Link<>() ); - m_pTreeView->SetTreePath( rURL ); + + // read cached data for this url and fill the tree + const ::std::vector< std::pair< OUString, OUString > >& rFolders = m_pFileView->GetSubFolders(); + m_pTreeView->FillTreeEntry( rURL, rFolders ); + m_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) ); m_bIsConnected = true; diff --git a/include/svtools/fileview.hxx b/include/svtools/fileview.hxx index 6bb64157d74b..69469754994e 100644 --- a/include/svtools/fileview.hxx +++ b/include/svtools/fileview.hxx @@ -173,6 +173,8 @@ public: void EndInplaceEditing( bool _bCancel ); + ::std::vector< std::pair< OUString, OUString > > GetSubFolders(); + protected: virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; }; diff --git a/include/svtools/foldertree.hxx b/include/svtools/foldertree.hxx index 4be22b975404..ccf0382ad35d 100644 --- a/include/svtools/foldertree.hxx +++ b/include/svtools/foldertree.hxx @@ -42,12 +42,15 @@ private: Image m_aFolderImage; Image m_aFolderExpandedImage; + OUString m_sLastUpdatedDir; + public: FolderTree( vcl::Window* pParent, WinBits nBits ); virtual void RequestingChildren( SvTreeListEntry* pEntry ) SAL_OVERRIDE; void FillTreeEntry( SvTreeListEntry* pEntry ); + void FillTreeEntry( const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders ); void SetTreePath( OUString const & sUrl ); void SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList ); }; diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 0ee78b2df4f9..564235822c45 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -1387,6 +1387,21 @@ OUString SvtFileView::GetConfigString() const return sRet; } +::std::vector< std::pair< OUString, OUString > > SvtFileView::GetSubFolders() +{ + ::std::vector< std::pair< OUString, OUString > > aContent; + + for( ::std::vector< SortingData_Impl* >::size_type i = 0; i < mpImp->maContent.size(); i++ ) + { + if( mpImp->maContent[i]->mbIsFolder ) + { + std::pair< OUString, OUString > aEntry( mpImp->maContent[i]->GetTitle(), mpImp->maContent[i]->maTargetURL ); + aContent.push_back( aEntry ); + } + } + + return aContent; +} void SvtFileView::SetConfigString( const OUString& rCfgStr ) { diff --git a/svtools/source/contnr/foldertree.cxx b/svtools/source/contnr/foldertree.cxx index 71313409432e..f783a5bd0e28 100644 --- a/svtools/source/contnr/foldertree.cxx +++ b/svtools/source/contnr/foldertree.cxx @@ -34,21 +34,21 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) { if( pEntry ) { - while (SvTreeListEntry* pChild = FirstChild(pEntry)) - { - GetModel()->Remove(pChild); - } + OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); - ::std::vector< SortingData_Impl* > aContent; + if( pURL && m_sLastUpdatedDir != *pURL ) + { + while (SvTreeListEntry* pChild = FirstChild(pEntry)) + { + GetModel()->Remove(pChild); + } - ::rtl::Reference< ::svt::FileViewContentEnumerator > - xContentEnumerator(new FileViewContentEnumerator( - m_xEnv, aContent, m_aMutex, NULL)); + ::std::vector< SortingData_Impl* > aContent; - OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() ); + ::rtl::Reference< ::svt::FileViewContentEnumerator > + xContentEnumerator(new FileViewContentEnumerator( + m_xEnv, aContent, m_aMutex, NULL)); - if( pURL ) - { FolderDescriptor aFolder( *pURL ); EnumerationResult eResult = @@ -69,6 +69,38 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) } } } + else + { + // this dir was updated recently + // next time read this remote folder + m_sLastUpdatedDir = ""; + } +} + +void FolderTree::FillTreeEntry( const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders ) +{ + SetTreePath( rUrl ); + + SvTreeListEntry* pParent = GetCurEntry(); + + if( pParent && !IsExpanded( pParent ) ) + { + while( GetChildCount( pParent ) > 0 ) + { + SvTreeListEntry* pChild = FirstChild( pParent ); + GetModel()->Remove( pChild ); + } + + for(::std::vector< std::pair< OUString, OUString > >::const_iterator it = rFolders.begin(); it != rFolders.end() ; ++it) + { + SvTreeListEntry* pNewEntry = InsertEntry( it->first, pParent, true ); + OUString* sData = new OUString( it->second ); + pNewEntry->SetUserData( static_cast< void* >( sData ) ); + } + + m_sLastUpdatedDir = rUrl; + Expand( pParent ); + } } void FolderTree::SetTreePath( OUString const & sUrl ) |