Kaydet (Commit) 851d73c4 authored tarafından Szymon Kłos's avatar Szymon Kłos

reuse data from SvtFileView in the FolderTree

Change-Id: I5a830459e7d5d9c71b7997b9014dde048b317d81
üst 6eede78d
...@@ -1078,8 +1078,6 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) ...@@ -1078,8 +1078,6 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL )
OUString* sData = new OUString( rURL ); OUString* sData = new OUString( rURL );
pRoot->SetUserData( static_cast< void* >( sData ) ); pRoot->SetUserData( static_cast< void* >( sData ) );
m_pTreeView->Expand( pRoot );
m_pName_ed->GrabFocus(); m_pName_ed->GrabFocus();
m_sLastServiceUrl = sURL; m_sLastServiceUrl = sURL;
...@@ -1088,8 +1086,13 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL ) ...@@ -1088,8 +1086,13 @@ void RemoteFilesDialog::UpdateControls( const OUString& rURL )
} }
m_pPath->SetURL( rURL ); m_pPath->SetURL( rURL );
m_pTreeView->SetSelectHdl( Link<>() ); 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_pTreeView->SetSelectHdl( LINK( this, RemoteFilesDialog, TreeSelectHdl ) );
m_bIsConnected = true; m_bIsConnected = true;
......
...@@ -173,6 +173,8 @@ public: ...@@ -173,6 +173,8 @@ public:
void EndInplaceEditing( bool _bCancel ); void EndInplaceEditing( bool _bCancel );
::std::vector< std::pair< OUString, OUString > > GetSubFolders();
protected: protected:
virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE; virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
}; };
......
...@@ -42,12 +42,15 @@ private: ...@@ -42,12 +42,15 @@ private:
Image m_aFolderImage; Image m_aFolderImage;
Image m_aFolderExpandedImage; Image m_aFolderExpandedImage;
OUString m_sLastUpdatedDir;
public: public:
FolderTree( vcl::Window* pParent, WinBits nBits ); FolderTree( vcl::Window* pParent, WinBits nBits );
virtual void RequestingChildren( SvTreeListEntry* pEntry ) SAL_OVERRIDE; virtual void RequestingChildren( SvTreeListEntry* pEntry ) SAL_OVERRIDE;
void FillTreeEntry( SvTreeListEntry* pEntry ); void FillTreeEntry( SvTreeListEntry* pEntry );
void FillTreeEntry( const OUString & rUrl, const ::std::vector< std::pair< OUString, OUString > >& rFolders );
void SetTreePath( OUString const & sUrl ); void SetTreePath( OUString const & sUrl );
void SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList ); void SetBlackList( const ::com::sun::star::uno::Sequence< OUString >& rBlackList );
}; };
......
...@@ -1387,6 +1387,21 @@ OUString SvtFileView::GetConfigString() const ...@@ -1387,6 +1387,21 @@ OUString SvtFileView::GetConfigString() const
return sRet; 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 ) void SvtFileView::SetConfigString( const OUString& rCfgStr )
{ {
......
...@@ -34,21 +34,21 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) ...@@ -34,21 +34,21 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry )
{ {
if( pEntry ) if( pEntry )
{ {
while (SvTreeListEntry* pChild = FirstChild(pEntry)) OUString* pURL = static_cast< OUString* >( pEntry->GetUserData() );
{
GetModel()->Remove(pChild);
}
::std::vector< SortingData_Impl* > aContent; if( pURL && m_sLastUpdatedDir != *pURL )
{
while (SvTreeListEntry* pChild = FirstChild(pEntry))
{
GetModel()->Remove(pChild);
}
::rtl::Reference< ::svt::FileViewContentEnumerator > ::std::vector< SortingData_Impl* > aContent;
xContentEnumerator(new FileViewContentEnumerator(
m_xEnv, aContent, m_aMutex, NULL));
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 ); FolderDescriptor aFolder( *pURL );
EnumerationResult eResult = EnumerationResult eResult =
...@@ -69,6 +69,38 @@ void FolderTree::FillTreeEntry( SvTreeListEntry* pEntry ) ...@@ -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 ) void FolderTree::SetTreePath( OUString const & sUrl )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment