From 611903191fc0f613d5335e04d8d97aa71bedd96a Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 12 Jun 2026 09:40:07 +0200 Subject: [PATCH] vcl: Move logic to notify about SvTreeListBox model changes to base Stop having various virtual methods in SvTreeListBox and overriding them in LclTabListBox to notify about model changes. Instead, move the corresponding logic to notify about such changes directly into the SvTreeListBox base class, which already supports notifying about various other changes. Change-Id: I918c5768afea70e8c0992d5c8c6be1f584909a12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206424 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- include/vcl/toolkit/treelistbox.hxx | 17 ++++++++------- vcl/inc/treeglue.hxx | 32 ----------------------------- vcl/source/treelist/treelistbox.cxx | 12 +++++++++++ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/include/vcl/toolkit/treelistbox.hxx b/include/vcl/toolkit/treelistbox.hxx index 00e6071ac206..7b492d12c821 100644 --- a/include/vcl/toolkit/treelistbox.hxx +++ b/include/vcl/toolkit/treelistbox.hxx @@ -220,6 +220,7 @@ class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox : public Control, Link m_aExpandingHdl; Link m_aSelectHdl; Link m_aDeselectHdl; + Link m_aModelChangedHdl; Link m_aTooltipHdl; Link m_aCustomRenderHdl; Link m_aCustomMeasureHdl; @@ -502,6 +503,7 @@ public: } void SetExpandingHdl(const Link& rNewHdl) { m_aExpandingHdl = rNewHdl; } void SetExpandedHdl(const Link& rNewHdl) { m_aExpandedHdl = rNewHdl; } + void SetModelChangedHdl(const Link& rLink) { m_aModelChangedHdl = rLink; } void SetTooltipHdl(const Link& rLink) { m_aTooltipHdl = rLink; } void SetCustomRenderHdl(const Link& rLink) { @@ -517,6 +519,7 @@ public: void SelectHdl(); void DeselectHdl(); bool DoubleClickHdl(); + void ModelChangedHdl(); SvTreeListEntry* GetHdlEntry() const { return m_pHdlEntry; } // Is called for an Entry that gets expanded with the Flag @@ -677,13 +680,13 @@ public: virtual void LoseFocus() override; void SetUpdateMode( bool ); - virtual void ModelHasCleared(); - virtual void ModelHasInserted(SvTreeListEntry* pEntry); - virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry); - virtual void ModelIsMoving(SvTreeListEntry* pSource); - virtual void ModelHasMoved(SvTreeListEntry* pSource); - virtual void ModelIsRemoving(SvTreeListEntry* pEntry); - virtual void ModelHasRemoved(SvTreeListEntry* pEntry); + void ModelHasCleared(); + void ModelHasInserted(SvTreeListEntry* pEntry); + void ModelHasInsertedTree(SvTreeListEntry* pEntry); + void ModelIsMoving(SvTreeListEntry* pSource); + void ModelHasMoved(SvTreeListEntry* pSource); + void ModelIsRemoving(SvTreeListEntry* pEntry); + void ModelHasRemoved(SvTreeListEntry* pEntry); void ModelHasEntryInvalidated(SvTreeListEntry* pEntry); void ScrollOutputArea( short nDeltaEntries ); diff --git a/vcl/inc/treeglue.hxx b/vcl/inc/treeglue.hxx index 8c584ef42791..cbfcabd4838d 100644 --- a/vcl/inc/treeglue.hxx +++ b/vcl/inc/treeglue.hxx @@ -12,7 +12,6 @@ class LclTabListBox final : public SvTabListBox { - Link m_aModelChangedHdl; Link m_aStartDragHdl; Link m_aEndDragHdl; @@ -22,7 +21,6 @@ public: { } - void SetModelChangedHdl(const Link& rLink) { m_aModelChangedHdl = rLink; } void SetStartDragHdl(const Link& rLink) { m_aStartDragHdl = rLink; } void SetEndDragHdl(const Link& rLink) { m_aEndDragHdl = rLink; } @@ -39,36 +37,6 @@ public: m_aEndDragHdl.Call(this); } - virtual void ModelHasCleared() override - { - SvTabListBox::ModelHasCleared(); - m_aModelChangedHdl.Call(this); - } - - virtual void ModelHasInserted(SvTreeListEntry* pEntry) override - { - SvTabListBox::ModelHasInserted(pEntry); - m_aModelChangedHdl.Call(this); - } - - virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry) override - { - SvTabListBox::ModelHasInsertedTree(pEntry); - m_aModelChangedHdl.Call(this); - } - - virtual void ModelHasMoved(SvTreeListEntry* pSource) override - { - SvTabListBox::ModelHasMoved(pSource); - m_aModelChangedHdl.Call(this); - } - - virtual void ModelHasRemoved(SvTreeListEntry* pEntry) override - { - SvTabListBox::ModelHasRemoved(pEntry); - m_aModelChangedHdl.Call(this); - } - SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget, bool bScroll = true) { SvTreeListEntry* pOldTargetEntry = m_pTargetEntry; diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index 6d45f0a8ea8f..71713870fde1 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -502,6 +502,8 @@ bool SvTreeListBox::DoubleClickHdl() return !m_aDoubleClickHdl.IsSet() || m_aDoubleClickHdl.Call(this); } +void SvTreeListBox::ModelChangedHdl() { m_aModelChangedHdl.Call(this); } + bool SvTreeListBox::CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 nAction ) { if ( pSource != this ) @@ -2166,6 +2168,8 @@ void SvTreeListBox::ModelHasCleared() AdjustEntryHeight(); AdjustEntryHeight( GetDefaultExpandedEntryBmp() ); AdjustEntryHeight( GetDefaultCollapsedEntryBmp() ); + + ModelChangedHdl(); } bool SvTreeListBox::PosOverBody(const Point& rPos) const @@ -2416,12 +2420,16 @@ void SvTreeListBox::ModelHasInsertedTree( SvTreeListEntry* pEntry ) pTmp = Next( pTmp ); } while (pTmp && nRefDepth < m_pModel->GetDepth(pTmp)); m_pImpl->TreeInserted(pEntry); + + ModelChangedHdl(); } void SvTreeListBox::ModelHasInserted( SvTreeListEntry* pEntry ) { ImpEntryInserted( pEntry ); m_pImpl->EntryInserted(pEntry); + + ModelChangedHdl(); } void SvTreeListBox::ModelIsMoving(SvTreeListEntry* pSource ) @@ -2432,6 +2440,8 @@ void SvTreeListBox::ModelIsMoving(SvTreeListEntry* pSource ) void SvTreeListBox::ModelHasMoved( SvTreeListEntry* pSource ) { m_pImpl->EntryMoved(pSource); + + ModelChangedHdl(); } void SvTreeListBox::ModelIsRemoving( SvTreeListEntry* pEntry ) @@ -2454,6 +2464,8 @@ void SvTreeListBox::ModelHasRemoved( SvTreeListEntry* pEntry ) m_pTargetEntry = nullptr; m_pImpl->EntryRemoved(); + + ModelChangedHdl(); } void SvTreeListBox::SetCollapsedNodeBmp( const Image& rBmp)