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

the base of breadcrumb widget

Change-Id: I6775b43c270faa7158ffb2a3a9ae0f19700ddef3
üst e0080650
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <vcl/vclptr.hxx> #include <vcl/vclptr.hxx>
#include <vcl/split.hxx> #include <vcl/split.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/fixedhyper.hxx>
#include <svtools/fileview.hxx> #include <svtools/fileview.hxx>
#include <svtools/treelistentry.hxx> #include <svtools/treelistentry.hxx>
...@@ -63,6 +64,7 @@ typedef std::shared_ptr<Place> ServicePtr; ...@@ -63,6 +64,7 @@ typedef std::shared_ptr<Place> ServicePtr;
typedef ::com::sun::star::uno::Sequence<OUString> OUStringList; typedef ::com::sun::star::uno::Sequence<OUString> OUStringList;
class FileViewContainer; class FileViewContainer;
class Breadcrumb;
class SVT_DLLPUBLIC RemoteFilesDialog : public ModalDialog class SVT_DLLPUBLIC RemoteFilesDialog : public ModalDialog
{ {
...@@ -92,7 +94,7 @@ private: ...@@ -92,7 +94,7 @@ private:
VclPtr<CancelButton> m_pCancel_btn; VclPtr<CancelButton> m_pCancel_btn;
VclPtr<MenuButton> m_pAddService_btn; VclPtr<MenuButton> m_pAddService_btn;
VclPtr<ListBox> m_pServices_lb; VclPtr<ListBox> m_pServices_lb;
VclPtr<Edit> m_pPath_ed; VclPtr<Breadcrumb> m_pPath;
VclPtr<Splitter> m_pSplitter; VclPtr<Splitter> m_pSplitter;
VclPtr<SvTreeListBox> m_pTreeView; VclPtr<SvTreeListBox> m_pTreeView;
VclPtr<SvtFileView> m_pFileView; VclPtr<SvtFileView> m_pFileView;
...@@ -127,6 +129,8 @@ private: ...@@ -127,6 +129,8 @@ private:
DECL_LINK( TreeSelectHdl, SvTreeListBox * ); DECL_LINK( TreeSelectHdl, SvTreeListBox * );
DECL_LINK( TreeExpandHdl, SvTreeListBox * ); DECL_LINK( TreeExpandHdl, SvTreeListBox * );
DECL_LINK( SelectBreadcrumbHdl, Breadcrumb * );
}; };
#endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX #endif // INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX
......
...@@ -75,6 +75,110 @@ class FileViewContainer : public vcl::Window ...@@ -75,6 +75,110 @@ class FileViewContainer : public vcl::Window
} }
}; };
class Breadcrumb : public VclHBox
{
private:
const unsigned int m_cCount = 4; // how many labels we have - temporary
std::vector< VclPtr< FixedHyperlink > > m_aLinks;
std::vector< VclPtr< FixedText > > m_aSeparators;
OUString m_sPath;
OUString m_sClickedURL;
Link<> m_aClickHdl;
DECL_LINK ( ClickLinkHdl, FixedHyperlink* );
public:
Breadcrumb( vcl::Window* pParent ) : VclHBox( pParent )
{
set_spacing( 6 );
for(unsigned int i = 0; i < m_cCount; i++)
{
m_aLinks.push_back( VclPtr< FixedHyperlink >::Create( this ) );
m_aLinks[i]->Hide();
m_aLinks[i]->SetClickHdl( LINK( this, Breadcrumb, ClickLinkHdl ) );
m_aSeparators.push_back( VclPtr< FixedText >::Create( this ) );
m_aSeparators[i]->SetText( ">" );
m_aSeparators[i]->Hide();
}
}
~Breadcrumb()
{
disposeOnce();
}
void dispose()
{
for(unsigned int i = 0; i < m_cCount; i++)
{
m_aSeparators[i].disposeAndClear();
m_aLinks[i].disposeAndClear();
}
VclHBox::dispose();
}
void SetClickHdl( const Link<>& rLink )
{
m_aClickHdl = rLink;
}
OUString GetHdlURL()
{
return m_sClickedURL;
}
void SetURL( const OUString& rURL )
{
m_sPath = rURL;
INetURLObject aURL( rURL );
aURL.setFinalSlash();
OUString sPath = aURL.GetURLPath(INetURLObject::DECODE_WITH_CHARSET);
unsigned int nSegments = aURL.getSegmentCount();
unsigned int nPos = 0;
unsigned int i;
m_aLinks[0]->SetText( "Root" );
m_aLinks[0]->Show();
m_aLinks[0]->SetURL( INetURLObject::GetScheme( aURL.GetProtocol() )
+ aURL.GetHost() );
m_aSeparators[0]->Show();
for(i = 1; i < m_cCount && i < nSegments + 1; i++)
{
unsigned int nEnd = sPath.indexOf( '/', nPos + 1 );
OUString sLabel = OUString( sPath.getStr() + nPos + 1, nEnd - nPos - 1 );
m_aLinks[i]->SetText( sLabel );
m_aLinks[i]->SetURL( INetURLObject::GetScheme( aURL.GetProtocol() )
+ aURL.GetHost()
+ OUString( sPath.getStr(), nEnd ) );
m_aLinks[i]->Show();
m_aSeparators[i]->Show();
nPos = nEnd;
}
for(; i < m_cCount; i++)
{
m_aLinks[i]->Hide();
m_aSeparators[i]->Hide();
}
}
};
IMPL_LINK ( Breadcrumb, ClickLinkHdl, FixedHyperlink*, pLink )
{
m_sClickedURL = pLink->GetURL();
m_aClickHdl.Call( this );
return 1;
}
RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
: ModalDialog(pParent, "RemoteFilesDialog", "svt/ui/remotefilesdialog.ui") : ModalDialog(pParent, "RemoteFilesDialog", "svt/ui/remotefilesdialog.ui")
, m_context(comphelper::getProcessComponentContext()) , m_context(comphelper::getProcessComponentContext())
...@@ -88,7 +192,6 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) ...@@ -88,7 +192,6 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
get(m_pCancel_btn, "cancel"); get(m_pCancel_btn, "cancel");
get(m_pAddService_btn, "add_service_btn"); get(m_pAddService_btn, "add_service_btn");
get(m_pServices_lb, "services_lb"); get(m_pServices_lb, "services_lb");
get(m_pPath_ed, "path");
get(m_pFilter_lb, "filter_lb"); get(m_pFilter_lb, "filter_lb");
get(m_pName_ed, "name_ed"); get(m_pName_ed, "name_ed");
...@@ -118,6 +221,11 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits) ...@@ -118,6 +221,11 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
m_pOpen_btn->Hide(); m_pOpen_btn->Hide();
} }
m_pPath = VclPtr<Breadcrumb>::Create( get<vcl::Window>("breadcrumb_container") );
m_pPath->set_hexpand(true);
m_pPath->SetClickHdl( LINK( this, RemoteFilesDialog, SelectBreadcrumbHdl ) );
m_pPath->Show();
m_pContainer = VclPtr<FileViewContainer>::Create( get<vcl::Window>("container") ); m_pContainer = VclPtr<FileViewContainer>::Create( get<vcl::Window>("container") );
m_pContainer->set_hexpand(true); m_pContainer->set_hexpand(true);
...@@ -201,13 +309,13 @@ void RemoteFilesDialog::dispose() ...@@ -201,13 +309,13 @@ void RemoteFilesDialog::dispose()
m_pFileView.disposeAndClear(); m_pFileView.disposeAndClear();
m_pSplitter.disposeAndClear(); m_pSplitter.disposeAndClear();
m_pContainer.disposeAndClear(); m_pContainer.disposeAndClear();
m_pPath.disposeAndClear();
m_pOpen_btn.clear(); m_pOpen_btn.clear();
m_pSave_btn.clear(); m_pSave_btn.clear();
m_pCancel_btn.clear(); m_pCancel_btn.clear();
m_pAddService_btn.clear(); m_pAddService_btn.clear();
m_pServices_lb.clear(); m_pServices_lb.clear();
m_pPath_ed.clear();
m_pFilter_lb.clear(); m_pFilter_lb.clear();
m_pName_ed.clear(); m_pName_ed.clear();
...@@ -307,11 +415,11 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL ) ...@@ -307,11 +415,11 @@ FileViewResult RemoteFilesDialog::OpenURL( OUString sURL )
OUString sFilter = getCurrentFilter(); OUString sFilter = getCurrentFilter();
m_pFileView->EndInplaceEditing( false ); m_pFileView->EndInplaceEditing( false );
m_pPath_ed->SetText( sURL );
eResult = m_pFileView->Initialize( sURL, sFilter, NULL, BlackList ); eResult = m_pFileView->Initialize( sURL, sFilter, NULL, BlackList );
if( eResult == eSuccess ) if( eResult == eSuccess )
{ {
m_pPath->SetURL( sURL );
m_pFilter_lb->Enable( true ); m_pFilter_lb->Enable( true );
m_pName_ed->Enable( true ); m_pName_ed->Enable( true );
m_pContainer->Enable( true ); m_pContainer->Enable( true );
...@@ -563,4 +671,14 @@ IMPL_LINK ( RemoteFilesDialog, TreeExpandHdl, SvTreeListBox *, pBox ) ...@@ -563,4 +671,14 @@ IMPL_LINK ( RemoteFilesDialog, TreeExpandHdl, SvTreeListBox *, pBox )
return 1; return 1;
} }
IMPL_LINK ( RemoteFilesDialog, SelectBreadcrumbHdl, Breadcrumb*, pPtr )
{
if( pPtr )
{
OpenURL( pPtr->GetHdlURL() );
}
return 1;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -123,9 +123,13 @@ ...@@ -123,9 +123,13 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="path"> <object class="GtkBox" id="breadcrumb_container">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<child>
<placeholder/>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
......
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