summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihály Palenik <palenik.mihaly@gmail.com>2015-07-23 09:50:09 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-07-24 13:47:48 +0000
commitaf162f1c37e8c909386e72e5d8b4ff6bccfd529b (patch)
tree231653817f1d77a57e59e710c0f1bc3b2522a548
parent738cf411e9315d17c7eb8be47ded643a00dfe5c5 (diff)
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@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--cui/source/options/optaboutconfig.cxx3
-rw-r--r--include/svtools/treelistbox.hxx1
-rw-r--r--svtools/source/contnr/treelistbox.cxx51
3 files changed, 29 insertions, 26 deletions
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index 811976c83ef9..165e9e932fa6 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 1c89cec84750..9ec23e4653ac 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 c7207d4eebbe..b33c31cabefe 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();
}