[Libreoffice-commits] core.git: cui/source include/svtools svtools/source

Mihály Palenik palenik.mihaly at gmail.com
Fri Jul 24 06:48:21 PDT 2015


 cui/source/options/optaboutconfig.cxx |    3 --
 include/svtools/treelistbox.hxx       |    1 
 svtools/source/contnr/treelistbox.cxx |   51 ++++++++++++++++++----------------
 3 files changed, 29 insertions(+), 26 deletions(-)

New commits:
commit af162f1c37e8c909386e72e5d8b4ff6bccfd529b
Author: Mihály Palenik <palenik.mihaly at gmail.com>
Date:   Thu Jul 23 09:50:09 2015 +0200

    Fix alternating rows in SvTreeListBox
    
    Alternating rows in SvTreeListBox is not work correctly when insert, expand
    or collapse. Now is work properly and set in Expert Configuration dialog.
    
    Change-Id: I58b53ae59fa7f8d9de769342a0e1bad55de18f20
    Reviewed-on: https://gerrit.libreoffice.org/17310
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 811976c..165e9e9 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -179,6 +179,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI
                                         util::SearchFlags::REG_NOT_ENDOFLINE);
 
     m_pPrefBox->SetTabs(aTabs, MAP_PIXEL);
+    m_pPrefBox->SetAlternatingRowColors( true );
 }
 
 CuiAboutConfigTabPage::~CuiAboutConfigTabPage()
@@ -479,7 +480,6 @@ void CuiAboutConfigTabPage::FillItems(const Reference< XNameAccess >& xNameAcces
             InsertEntry(sPath, sPath.copy(index+1), seqItems[i], sType, sValue, pParentEntry, !bLoadAll);
         }
     }
-    m_pPrefBox->SetAlternatingRowColors( true );
 }
 
 Reference< XNameAccess > CuiAboutConfigTabPage::getConfigAccess( const OUString& sNodePath, bool bUpdate )
@@ -863,7 +863,6 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, SearchHdl_Impl)
         m_pPrefBox->SortByCol(sortedCol, sortMode == SortAscending);
 
     m_pPrefBox->SetUpdateMode( true );
-    m_pPrefBox->SetAlternatingRowColors( true );
 
     return 0;
 }
diff --git a/include/svtools/treelistbox.hxx b/include/svtools/treelistbox.hxx
index 1c89cec..9ec23e4 100644
--- a/include/svtools/treelistbox.hxx
+++ b/include/svtools/treelistbox.hxx
@@ -267,6 +267,7 @@ class SVT_DLLPUBLIC SvTreeListBox
     long mnCheckboxItemWidth;
     bool mbContextBmpExpanded;
     bool mbAlternatingRowColors;
+    bool mbUpdateAlternatingRows;
 
     SvTreeListEntry*    pHdlEntry;
     SvLBoxItem*     pHdlItem;
diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index c7207d4..b33c31c 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -381,6 +381,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) :
     mpImpl(new SvTreeListBoxImpl(*this)),
     mbContextBmpExpanded(false),
     mbAlternatingRowColors(false),
+    mbUpdateAlternatingRows(false),
     eSelMode(NO_SELECTION),
     nMinWidthInChars(0)
 {
@@ -411,6 +412,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, const ResId& rResId) :
     mpImpl(new SvTreeListBoxImpl(*this)),
     mbContextBmpExpanded(false),
     mbAlternatingRowColors(false),
+    mbUpdateAlternatingRows(false),
     eSelMode(NO_SELECTION),
     nMinWidthInChars(0)
 {
@@ -471,16 +473,7 @@ sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry, SvTreeListEntry* pPare
 {
     sal_uLong nInsPos = pModel->Insert( pEntry, pParent, nPos );
     pEntry->SetBackColor( GetBackground().GetColor() );
-    if(mbAlternatingRowColors)
-    {
-        if(nPos == TREELIST_APPEND)
-        {
-            if(Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetBackground().GetColor())
-                pEntry->SetBackColor( GetSettings().GetStyleSettings().GetAlternatingRowColor() );
-        }
-        else
-            SetAlternatingRowColors( true );
-    }
+    SetAlternatingRowColors( mbAlternatingRowColors );
     return nInsPos;
 }
 
@@ -488,16 +481,7 @@ sal_uLong SvTreeListBox::Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos )
 {
     sal_uLong nInsPos = pModel->Insert( pEntry, nRootPos );
     pEntry->SetBackColor( GetBackground().GetColor() );
-    if(mbAlternatingRowColors)
-    {
-        if(nRootPos == TREELIST_APPEND)
-        {
-            if(Prev(pEntry) && Prev(pEntry)->GetBackColor() == GetBackground().GetColor())
-                pEntry->SetBackColor( GetSettings().GetStyleSettings().GetAlternatingRowColor() );
-        }
-        else
-            SetAlternatingRowColors( true );
-    }
+    SetAlternatingRowColors( mbAlternatingRowColors );
     return nInsPos;
 }
 
@@ -2372,6 +2356,7 @@ bool SvTreeListBox::Expand( SvTreeListEntry* pParent )
             pImp->EntryExpanded( pParent );
             pHdlEntry = pParent;
             ExpandedHdl();
+            SetAlternatingRowColors( mbAlternatingRowColors );
         }
         nFlags = pParent->GetFlags();
         nFlags &= ~SvTLEntryFlags::NO_NODEBMP;
@@ -2409,6 +2394,7 @@ bool SvTreeListBox::Collapse( SvTreeListEntry* pParent )
         pImp->EntryCollapsed( pParent );
         pHdlEntry = pParent;
         ExpandedHdl();
+        SetAlternatingRowColors( mbAlternatingRowColors );
     }
 
     // #i92103#
@@ -2590,6 +2576,8 @@ void SvTreeListBox::MouseMove( const MouseEvent& rMEvt )
 void SvTreeListBox::SetUpdateMode( bool bUpdate )
 {
     pImp->SetUpdateMode( bUpdate );
+    mbUpdateAlternatingRows = bUpdate;
+    SetAlternatingRowColors( mbAlternatingRowColors );
 }
 
 void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
@@ -3393,20 +3381,35 @@ Size SvTreeListBox::GetOptimalSize() const
 
 void SvTreeListBox::SetAlternatingRowColors( bool bEnable )
 {
-    mbAlternatingRowColors = bEnable;
-    if( mbAlternatingRowColors )
+    if( !mbUpdateAlternatingRows )
+    {
+        mbAlternatingRowColors = bEnable;
+        return;
+    }
+
+    if( bEnable )
     {
         SvTreeListEntry* pEntry = pModel->First();
         for(size_t i = 0; pEntry; ++i)
         {
             pEntry->SetBackColor( i % 2 == 0 ? GetBackground().GetColor() : GetSettings().GetStyleSettings().GetAlternatingRowColor());
-            pEntry = pModel->Next(pEntry);
+            SvTreeListEntry *pNextEntry = nullptr;
+            if( IsExpanded( pEntry ) )
+                pNextEntry = pModel->FirstChild( pEntry );
+            else
+                pNextEntry = pModel->NextSibling( pEntry );
+
+            if( !pNextEntry )
+                pEntry = pModel->Next( pEntry );
+            else
+                pEntry = pNextEntry;
         }
     }
-    else
+    else if( mbAlternatingRowColors )
         for(SvTreeListEntry* pEntry = pModel->First(); pEntry; pEntry = pModel->Next(pEntry))
             pEntry->SetBackColor( GetBackground().GetColor() );
 
+    mbAlternatingRowColors = bEnable;
     pImp->UpdateAll();
 }
 


More information about the Libreoffice-commits mailing list