[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - 2 commits - include/svtools svtools/Library_svt.mk svtools/source

Szymon Kłos eszkadev at gmail.com
Wed Jun 10 08:25:47 PDT 2015


 include/svtools/RemoteFilesDialog.hxx        |    7 -
 include/svtools/breadcrumb.hxx               |   62 +++++++++++
 svtools/Library_svt.mk                       |    1 
 svtools/source/control/breadcrumb.cxx        |  142 +++++++++++++++++++++++++++
 svtools/source/dialogs/RemoteFilesDialog.cxx |  118 ----------------------
 5 files changed, 209 insertions(+), 121 deletions(-)

New commits:
commit c5813bf98886e7de2d92cb9d43bcd3cff58d01c9
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Wed Jun 10 17:24:12 2015 +0200

    added a new mode of showing path in the breadcrumb
    
    Change-Id: I0819f2346ee3412d044c2d6c7d3bbc2dd9231ed5

diff --git a/include/svtools/breadcrumb.hxx b/include/svtools/breadcrumb.hxx
index 86be5d2..29858d6 100644
--- a/include/svtools/breadcrumb.hxx
+++ b/include/svtools/breadcrumb.hxx
@@ -19,6 +19,12 @@
 
 #include <vector>
 
+enum SvtBreadcrumbMode
+{
+    ONLY_CURRENT_PATH = 0,
+    ALL_VISITED = 1
+};
+
 class SVT_DLLPUBLIC Breadcrumb : public VclHBox
 {
     private:
@@ -28,9 +34,12 @@ class SVT_DLLPUBLIC Breadcrumb : public VclHBox
         OUString m_sRootName;
         OUString m_sClickedURL;
 
+        SvtBreadcrumbMode m_eMode;
+
         Link<> m_aClickHdl;
 
         void appendField();
+        void clearFields( unsigned int nStartIndex );
 
         DECL_LINK ( ClickLinkHdl, FixedHyperlink* );
 
@@ -45,6 +54,7 @@ class SVT_DLLPUBLIC Breadcrumb : public VclHBox
 
         void SetRootName( const OUString& rURL );
         void SetURL( const OUString& rURL );
+        void SetMode( SvtBreadcrumbMode eMode );
 };
 
 #endif
diff --git a/svtools/source/control/breadcrumb.cxx b/svtools/source/control/breadcrumb.cxx
index ba2ed5d..c7cbc00 100644
--- a/svtools/source/control/breadcrumb.cxx
+++ b/svtools/source/control/breadcrumb.cxx
@@ -11,6 +11,7 @@
 
 Breadcrumb::Breadcrumb( vcl::Window* pParent, WinBits nWinStyle ) : VclHBox( pParent, nWinStyle )
 {
+    m_eMode = SvtBreadcrumbMode::ONLY_CURRENT_PATH;
     set_spacing( 6 );
     appendField(); // root
 }
@@ -56,6 +57,8 @@ void Breadcrumb::SetURL( const OUString& rURL )
     unsigned int nPos = 0;
     unsigned int i;
 
+    bool bClear = ( m_eMode == SvtBreadcrumbMode::ONLY_CURRENT_PATH );
+
     m_aLinks[0]->SetText( m_sRootName );
     m_aLinks[0]->Show();
     m_aLinks[0]->Enable( true );
@@ -71,6 +74,13 @@ void Breadcrumb::SetURL( const OUString& rURL )
         unsigned int nEnd = sPath.indexOf( '/', nPos + 1 );
         OUString sLabel = OUString( sPath.getStr() + nPos + 1, nEnd - nPos - 1 );
 
+        if( m_eMode == SvtBreadcrumbMode::ALL_VISITED )
+        {
+            if( m_aLinks[i]->GetText() != sLabel )
+                bClear = true;
+        }
+
+
         m_aLinks[i]->SetText( sLabel );
         m_aLinks[i]->SetURL( INetURLObject::GetScheme( aURL.GetProtocol() )
                                 + aURL.GetHost()
@@ -85,13 +95,21 @@ void Breadcrumb::SetURL( const OUString& rURL )
     m_aLinks[i - 1]->Enable( false );
     m_aSeparators[i - 1]->Hide();
 
-    for( ; i < m_aLinks.size(); i++ )
+    if( bClear )
     {
-        m_aLinks[i]->Hide();
-        m_aSeparators[i]->Hide();
+        clearFields( i );
+    }
+    else
+    {
+        for( ; i < m_aLinks.size(); i++ )
+            m_aLinks[i]->Enable( true );
     }
 }
 
+void Breadcrumb::SetMode( SvtBreadcrumbMode eMode )
+{
+    m_eMode = eMode;
+}
 
 void Breadcrumb::appendField()
 {
@@ -104,6 +122,15 @@ void Breadcrumb::appendField()
     m_aSeparators[m_aLinks.size() - 1]->Hide();
 }
 
+void Breadcrumb::clearFields( unsigned int nStartIndex )
+{
+    for( unsigned int i = nStartIndex; i < m_aLinks.size(); i++ )
+    {
+        m_aLinks[i]->Hide();
+        m_aSeparators[i]->Hide();
+    }
+}
+
 IMPL_LINK ( Breadcrumb, ClickLinkHdl, FixedHyperlink*, pLink )
 {
     m_sClickedURL = pLink->GetURL();
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index b85f1e8..663d719 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -120,6 +120,7 @@ RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
     m_pPath = VclPtr<Breadcrumb>::Create( get<vcl::Window>("breadcrumb_container") );
     m_pPath->set_hexpand(true);
     m_pPath->SetClickHdl( LINK( this, RemoteFilesDialog, SelectBreadcrumbHdl ) );
+    m_pPath->SetMode( SvtBreadcrumbMode::ALL_VISITED );
     m_pPath->Show();
 
     m_pContainer = VclPtr<FileViewContainer>::Create( get<vcl::Window>("container") );
commit e097ae0f42a6e2f57a51ba22844941c2cf7b0efc
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Wed Jun 10 15:55:01 2015 +0200

    the breadcrumb class moved to the new file
    
    Change-Id: I283080522090766682b1d6c7911466898b11758a

diff --git a/include/svtools/RemoteFilesDialog.hxx b/include/svtools/RemoteFilesDialog.hxx
index 2e30efc..c6bf8d8 100644
--- a/include/svtools/RemoteFilesDialog.hxx
+++ b/include/svtools/RemoteFilesDialog.hxx
@@ -15,6 +15,9 @@
 #include <svtools/PlaceEditDialog.hxx>
 #include <svtools/svtools.hrc>
 #include <svtools/svtresid.hxx>
+#include <svtools/breadcrumb.hxx>
+#include <svtools/fileview.hxx>
+#include <svtools/treelistentry.hxx>
 
 #include <vcl/button.hxx>
 #include <vcl/menubtn.hxx>
@@ -23,10 +26,6 @@
 #include <vcl/vclptr.hxx>
 #include <vcl/split.hxx>
 #include <vcl/svapp.hxx>
-#include <vcl/fixedhyper.hxx>
-
-#include <svtools/fileview.hxx>
-#include <svtools/treelistentry.hxx>
 
 #include <officecfg/Office/Common.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
diff --git a/include/svtools/breadcrumb.hxx b/include/svtools/breadcrumb.hxx
new file mode 100644
index 0000000..86be5d2
--- /dev/null
+++ b/include/svtools/breadcrumb.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SVTOOLS_BREADCRUMB_HXX
+#define INCLUDED_SVTOOLS_BREADCRUMB_HXX
+
+#include <svtools/svtdllapi.h>
+
+#include <tools/urlobj.hxx>
+
+#include <vcl/fixedhyper.hxx>
+#include <vcl/layout.hxx>
+
+#include <vector>
+
+class SVT_DLLPUBLIC Breadcrumb : public VclHBox
+{
+    private:
+        std::vector< VclPtr< FixedHyperlink > > m_aLinks;
+        std::vector< VclPtr< FixedText > > m_aSeparators;
+
+        OUString m_sRootName;
+        OUString m_sClickedURL;
+
+        Link<> m_aClickHdl;
+
+        void appendField();
+
+        DECL_LINK ( ClickLinkHdl, FixedHyperlink* );
+
+    public:
+        Breadcrumb( vcl::Window* pParent, WinBits nWinStyle = 0 );
+        ~Breadcrumb();
+
+        void dispose();
+
+        void SetClickHdl( const Link<>& rLink );
+        OUString GetHdlURL();
+
+        void SetRootName( const OUString& rURL );
+        void SetURL( const OUString& rURL );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index 30c0dfd..e3ce0a0 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -106,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
     svtools/source/contnr/viewdataentry \
     svtools/source/control/accessibleruler \
     svtools/source/control/asynclink \
+    svtools/source/control/breadcrumb \
     svtools/source/control/calendar \
     svtools/source/control/collatorres \
     svtools/source/control/ctrlbox \
diff --git a/svtools/source/control/breadcrumb.cxx b/svtools/source/control/breadcrumb.cxx
new file mode 100644
index 0000000..ba2ed5d
--- /dev/null
+++ b/svtools/source/control/breadcrumb.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <svtools/breadcrumb.hxx>
+
+Breadcrumb::Breadcrumb( vcl::Window* pParent, WinBits nWinStyle ) : VclHBox( pParent, nWinStyle )
+{
+    set_spacing( 6 );
+    appendField(); // root
+}
+
+Breadcrumb::~Breadcrumb()
+{
+    disposeOnce();
+}
+
+void Breadcrumb::dispose()
+{
+    for( unsigned int i = 0; i < m_aLinks.size(); i++ )
+    {
+        m_aSeparators[i].disposeAndClear();
+        m_aLinks[i].disposeAndClear();
+    }
+
+    VclHBox::dispose();
+}
+
+void Breadcrumb::SetClickHdl( const Link<>& rLink )
+{
+    m_aClickHdl = rLink;
+}
+
+OUString Breadcrumb::GetHdlURL()
+{
+    return m_sClickedURL;
+}
+
+void Breadcrumb::SetRootName( const OUString& rURL )
+{
+    m_sRootName = rURL;
+}
+
+void Breadcrumb::SetURL( const OUString& 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( m_sRootName );
+    m_aLinks[0]->Show();
+    m_aLinks[0]->Enable( true );
+    m_aLinks[0]->SetURL( INetURLObject::GetScheme( aURL.GetProtocol() )
+                                + aURL.GetHost() );
+    m_aSeparators[0]->Show();
+
+    for( i = 1; i < nSegments + 1; i++ )
+    {
+        if( i >= m_aLinks.size() )
+            appendField();
+
+        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_aLinks[i]->Enable( true );
+        m_aSeparators[i]->Show();
+
+        nPos = nEnd;
+    }
+
+    m_aLinks[i - 1]->Enable( false );
+    m_aSeparators[i - 1]->Hide();
+
+    for( ; i < m_aLinks.size(); i++ )
+    {
+        m_aLinks[i]->Hide();
+        m_aSeparators[i]->Hide();
+    }
+}
+
+
+void Breadcrumb::appendField()
+{
+    m_aLinks.push_back( VclPtr< FixedHyperlink >::Create( this ) );
+    m_aLinks[m_aLinks.size() - 1]->Hide();
+    m_aLinks[m_aLinks.size() - 1]->SetClickHdl( LINK( this, Breadcrumb, ClickLinkHdl ) );
+
+    m_aSeparators.push_back( VclPtr< FixedText >::Create( this ) );
+    m_aSeparators[m_aLinks.size() - 1]->SetText( ">" );
+    m_aSeparators[m_aLinks.size() - 1]->Hide();
+}
+
+IMPL_LINK ( Breadcrumb, ClickLinkHdl, FixedHyperlink*, pLink )
+{
+    m_sClickedURL = pLink->GetURL();
+    m_aClickHdl.Call( this );
+
+    return 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/dialogs/RemoteFilesDialog.cxx b/svtools/source/dialogs/RemoteFilesDialog.cxx
index 6aad7ea..b85f1e8 100644
--- a/svtools/source/dialogs/RemoteFilesDialog.cxx
+++ b/svtools/source/dialogs/RemoteFilesDialog.cxx
@@ -75,123 +75,6 @@ class FileViewContainer : public vcl::Window
     }
 };
 
-class Breadcrumb : public VclHBox
-{
-    private:
-    std::vector< VclPtr< FixedHyperlink > > m_aLinks;
-    std::vector< VclPtr< FixedText > > m_aSeparators;
-
-    OUString m_sRootName;
-    OUString m_sClickedURL;
-
-    Link<> m_aClickHdl;
-
-    DECL_LINK ( ClickLinkHdl, FixedHyperlink* );
-
-    public:
-    Breadcrumb( vcl::Window* pParent ) : VclHBox( pParent )
-    {
-        set_spacing( 6 );
-        appendField(); // root
-    }
-
-    ~Breadcrumb()
-    {
-        disposeOnce();
-    }
-
-    void dispose()
-    {
-        for( unsigned int i = 0; i < m_aLinks.size(); 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 SetRootName( const OUString& rURL )
-    {
-        m_sRootName = rURL;
-    }
-
-    void SetURL( const OUString& 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( m_sRootName );
-        m_aLinks[0]->Show();
-        m_aLinks[0]->Enable( true );
-        m_aLinks[0]->SetURL( INetURLObject::GetScheme( aURL.GetProtocol() )
-                                + aURL.GetHost() );
-        m_aSeparators[0]->Show();
-
-        for( i = 1; i < nSegments + 1; i++ )
-        {
-            if( i >= m_aLinks.size() )
-                appendField();
-
-            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_aLinks[i]->Enable( true );
-            m_aSeparators[i]->Show();
-
-            nPos = nEnd;
-        }
-
-        m_aLinks[i - 1]->Enable( false );
-        m_aSeparators[i - 1]->Hide();
-
-        for( ; i < m_aLinks.size(); i++ )
-        {
-            m_aLinks[i]->Hide();
-            m_aSeparators[i]->Hide();
-        }
-    }
-
-    private:
-    void appendField()
-    {
-        m_aLinks.push_back( VclPtr< FixedHyperlink >::Create( this ) );
-        m_aLinks[m_aLinks.size() - 1]->Hide();
-        m_aLinks[m_aLinks.size() - 1]->SetClickHdl( LINK( this, Breadcrumb, ClickLinkHdl ) );
-        m_aSeparators.push_back( VclPtr< FixedText >::Create( this ) );
-        m_aSeparators[m_aLinks.size() - 1]->SetText( ">" );
-        m_aSeparators[m_aLinks.size() - 1]->Hide();
-    }
-};
-
-IMPL_LINK ( Breadcrumb, ClickLinkHdl, FixedHyperlink*, pLink )
-{
-    m_sClickedURL = pLink->GetURL();
-    m_aClickHdl.Call( this );
-
-    return 1;
-}
-
 RemoteFilesDialog::RemoteFilesDialog(vcl::Window* pParent, WinBits nBits)
     : ModalDialog(pParent, "RemoteFilesDialog", "svt/ui/remotefilesdialog.ui")
     , m_context(comphelper::getProcessComponentContext())


More information about the Libreoffice-commits mailing list