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

Szymon Kłos eszkadev at gmail.com
Fri Jun 12 11:42:14 PDT 2015


 include/svtools/PlaceEditDialog.hxx        |    2 
 include/svtools/breadcrumb.hxx             |    4 
 svtools/source/control/breadcrumb.cxx      |  133 +++++++++++++++++++++++------
 svtools/source/dialogs/PlaceEditDialog.cxx |   17 +++
 4 files changed, 130 insertions(+), 26 deletions(-)

New commits:
commit 405623e6d87dfc4e465c5abb039f192ff0dd9395
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Fri Jun 12 19:04:24 2015 +0200

    select the default repository (GDrive, OneDrive, Alfresco Cloud)
    
    Change-Id: I436512807ba4d83aeb767585cd27d4df2c1bfb61

diff --git a/include/svtools/PlaceEditDialog.hxx b/include/svtools/PlaceEditDialog.hxx
index dc8840a..de321a2 100644
--- a/include/svtools/PlaceEditDialog.hxx
+++ b/include/svtools/PlaceEditDialog.hxx
@@ -39,6 +39,8 @@ private :
 
     VclPtr<PushButton>   m_pBTDelete;
 
+    VclPtr<Button>       m_pBTRepoRefresh;
+
     VclPtr<VclGrid>      m_pTypeGrid;
 
     /** Vector holding the details UI control for each server type.
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx
index 1028a56..12a5a49 100644
--- a/svtools/source/dialogs/PlaceEditDialog.cxx
+++ b/svtools/source/dialogs/PlaceEditDialog.cxx
@@ -27,6 +27,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent)
     get( m_pBTOk, "ok" );
     get( m_pBTCancel, "cancel" );
     get( m_pBTDelete, "delete" );
+    get( m_pBTRepoRefresh, "repositoriesRefresh" );
 
     m_pBTOk->SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) );
     m_pBTOk->Enable( false );
@@ -184,7 +185,23 @@ void PlaceEditDialog::InitDetails( )
 
 IMPL_LINK ( PlaceEditDialog,  OKHdl, Button *, )
 {
+    if (m_xCurrentDetails.get())
+    {
+        OUString sUrl = m_xCurrentDetails->getUrl().GetHost(INetURLObject::DECODE_WITH_CHARSET);
+        OUString sGDriveHost( GDRIVE_BASE_URL );
+        OUString sAlfrescoHost( ALFRESCO_CLOUD_BASE_URL );
+        OUString sOneDriveHost( ONEDRIVE_BASE_URL );
+
+        if( sUrl.compareTo(sGDriveHost, sGDriveHost.getLength()) == 0
+           || sUrl.compareTo(sAlfrescoHost, sAlfrescoHost.getLength()) == 0
+           || sUrl.compareTo(sOneDriveHost, sOneDriveHost.getLength()) == 0 )
+        {
+            m_pBTRepoRefresh->Click();
+        }
+    }
+
     EndDialog( RET_OK );
+
     return 1;
 }
 
commit 4df95faf36177e8945e06d4ab1a3934c69c9be6a
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Fri Jun 12 17:33:28 2015 +0200

    hiding the fragments of the long paths
    
    Change-Id: Iebdf4fbbb0371fbaedaacb500623586fa70865e3

diff --git a/include/svtools/breadcrumb.hxx b/include/svtools/breadcrumb.hxx
index 29858d6..ff08994 100644
--- a/include/svtools/breadcrumb.hxx
+++ b/include/svtools/breadcrumb.hxx
@@ -19,6 +19,8 @@
 
 #include <vector>
 
+#define SPACING 6
+
 enum SvtBreadcrumbMode
 {
     ONLY_CURRENT_PATH = 0,
@@ -39,7 +41,7 @@ class SVT_DLLPUBLIC Breadcrumb : public VclHBox
         Link<> m_aClickHdl;
 
         void appendField();
-        void clearFields( unsigned int nStartIndex );
+        bool showField( unsigned int nIndex, unsigned int nWidthMax );
 
         DECL_LINK ( ClickLinkHdl, FixedHyperlink* );
 
diff --git a/svtools/source/control/breadcrumb.cxx b/svtools/source/control/breadcrumb.cxx
index c7cbc00..735756a 100644
--- a/svtools/source/control/breadcrumb.cxx
+++ b/svtools/source/control/breadcrumb.cxx
@@ -12,7 +12,7 @@
 Breadcrumb::Breadcrumb( vcl::Window* pParent, WinBits nWinStyle ) : VclHBox( pParent, nWinStyle )
 {
     m_eMode = SvtBreadcrumbMode::ONLY_CURRENT_PATH;
-    set_spacing( 6 );
+    set_spacing( SPACING );
     appendField(); // root
 }
 
@@ -51,22 +51,24 @@ void Breadcrumb::SetURL( const OUString& rURL )
 {
     INetURLObject aURL( rURL );
     aURL.setFinalSlash();
+
     OUString sPath = aURL.GetURLPath(INetURLObject::DECODE_WITH_CHARSET);
+    OUString sRootPath = INetURLObject::GetScheme( aURL.GetProtocol() ) + aURL.GetHost();
 
-    unsigned int nSegments = aURL.getSegmentCount();
+    int nSegments = aURL.getSegmentCount();
     unsigned int nPos = 0;
-    unsigned int i;
 
     bool bClear = ( m_eMode == SvtBreadcrumbMode::ONLY_CURRENT_PATH );
 
+    // root field
+
     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();
+    m_aLinks[0]->SetURL( sRootPath );
+
+    // fill the other fields
 
-    for( i = 1; i < nSegments + 1; i++ )
+    for( unsigned int i = 1; i < (unsigned int)nSegments + 1; i++ )
     {
         if( i >= m_aLinks.size() )
             appendField();
@@ -80,30 +82,97 @@ void Breadcrumb::SetURL( const OUString& rURL )
                 bClear = true;
         }
 
-
         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]->SetURL( sRootPath + OUString( sPath.getStr(), nEnd ) );
+        m_aLinks[i]->Hide();
         m_aLinks[i]->Enable( true );
-        m_aSeparators[i]->Show();
+        m_aSeparators[i]->Hide();
 
         nPos = nEnd;
     }
 
-    m_aLinks[i - 1]->Enable( false );
-    m_aSeparators[i - 1]->Hide();
+    // clear unused fields
 
-    if( bClear )
+    for( unsigned int i = nSegments + 1; i < m_aLinks.size(); i++ )
     {
-        clearFields( i );
+        if( bClear )
+            m_aLinks[i]->SetText( "" );
+
+        m_aLinks[i]->Hide();
+        m_aSeparators[i]->Hide();
+        m_aLinks[i]->Enable( true );
     }
-    else
+
+    // show fields
+
+    Resize();
+    unsigned int nMaxWidth = GetSizePixel().Width();
+    unsigned int nSeparatorWidth = m_aSeparators[0]->GetSizePixel().Width();
+    unsigned int nCurrentWidth = 0;
+    unsigned int nLastVisible = nSegments;
+
+    bool bRight = ( m_eMode == SvtBreadcrumbMode::ALL_VISITED );
+    bool bLeft = true;
+
+    int i = 0;
+
+    while( bLeft || bRight )
     {
-        for( ; i < m_aLinks.size(); i++ )
-            m_aLinks[i]->Enable( true );
+        if( nSegments - i == -1 )
+            bLeft = false;
+
+        if( bLeft )
+        {
+            unsigned int nIndex = nSegments - i;
+
+            if( showField( nIndex, nMaxWidth - nCurrentWidth ) )
+            {
+                nCurrentWidth += m_aLinks[nIndex]->GetSizePixel().Width()
+                                + nSeparatorWidth + 2*SPACING;
+            }
+            else
+            {
+                // label is too long
+                if( nSegments != 0 )
+                {
+                    m_aLinks[0]->SetText( "..." );
+                    m_aLinks[0]->Enable( false );
+                }
+                bLeft = false;
+            }
+        }
+
+        if( nSegments + i == (int)m_aLinks.size() )
+            bRight = false;
+
+        if( i != 0 && bRight )
+        {
+            unsigned int nIndex = nSegments + i;
+
+            if( m_aLinks[nIndex]->GetText() == "" )
+            {
+                bRight = false;
+            }
+            else if( showField( nIndex, nMaxWidth - nCurrentWidth ) )
+            {
+                nCurrentWidth += m_aLinks[nIndex]->GetSizePixel().Width()
+                                + nSeparatorWidth + 3*SPACING;
+                nLastVisible = nIndex;
+            }
+            else
+            {
+                bRight = false;
+            }
+        }
+
+        i++;
     }
+
+    // current dir should be inactive
+    m_aLinks[nSegments]->Enable( false );
+
+    // hide last separator
+    m_aSeparators[nLastVisible]->Hide();
 }
 
 void Breadcrumb::SetMode( SvtBreadcrumbMode eMode )
@@ -122,13 +191,27 @@ void Breadcrumb::appendField()
     m_aSeparators[m_aLinks.size() - 1]->Hide();
 }
 
-void Breadcrumb::clearFields( unsigned int nStartIndex )
+bool Breadcrumb::showField( unsigned int nIndex, unsigned int nWidthMax )
 {
-    for( unsigned int i = nStartIndex; i < m_aLinks.size(); i++ )
+    m_aLinks[nIndex]->Show();
+    m_aSeparators[nIndex]->Show();
+
+    unsigned int nSeparatorWidth = m_aSeparators[0]->GetSizePixel().Width();
+    unsigned int nWidth = m_aLinks[nIndex]->GetSizePixel().Width()
+            + nSeparatorWidth + 3*SPACING;
+
+    if( nWidth > nWidthMax )
     {
-        m_aLinks[i]->Hide();
-        m_aSeparators[i]->Hide();
+        if( nIndex != 0 )
+        {
+            m_aLinks[nIndex]->Hide();
+            m_aSeparators[nIndex]->Hide();
+        }
+
+        return false;
     }
+
+    return true;
 }
 
 IMPL_LINK ( Breadcrumb, ClickLinkHdl, FixedHyperlink*, pLink )


More information about the Libreoffice-commits mailing list