diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-07-28 10:30:58 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-08-14 08:45:15 +0200 |
commit | 851d73c4d99151dfbc5684a8800f5d92b94e8b36 (patch) | |
tree | 58410e72dce5e778e79e35c6db41af319ce9619b /svtools | |
parent | 6eede78d4e75fdbec7e565ebb15f1ce9956734f0 (diff) |
reuse data from SvtFileView in the FolderTree
Change-Id: I5a830459e7d5d9c71b7997b9014dde048b317d81
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 15 | ||||
-rw-r--r-- | svtools/source/contnr/foldertree.cxx | 54 |
2 files changed, 58 insertions, 11 deletions
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 ) |