include/vcl/toolkit/treelistentry.hxx | 2 ++ vcl/inc/iconview.hxx | 2 -- vcl/source/app/salvtables.cxx | 4 ++-- vcl/source/treelist/iconview.cxx | 11 +++-------- vcl/source/treelist/iconviewimpl.cxx | 14 +++++++------- vcl/source/treelist/svlbitm.cxx | 4 ++-- vcl/source/treelist/treelistbox.cxx | 2 +- vcl/source/treelist/treelistentry.cxx | 10 ++++++++++ 8 files changed, 27 insertions(+), 22 deletions(-)
New commits: commit 2180e365b9e4c4920e1526554bb99a1e37094523 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Aug 8 12:23:12 2025 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Aug 8 10:50:47 2025 +0200 Move IsSeparator to SvTreeListEntry, where it belongs. It is strange to have it in IconView. Change-Id: I4df2df78246878872927952537843cf4dde7cd52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189146 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/vcl/toolkit/treelistentry.hxx b/include/vcl/toolkit/treelistentry.hxx index d9fa804e3713..599a4e6a21e1 100644 --- a/include/vcl/toolkit/treelistentry.hxx +++ b/include/vcl/toolkit/treelistentry.hxx @@ -111,6 +111,8 @@ public: void SetUserData( void* pPtr ); void EnableChildrenOnDemand( bool bEnable=true ); bool HasChildrenOnDemand() const; + void SetSeparator(); + bool IsSeparator() const; SvTLEntryFlags GetFlags() const { return nEntryFlags;} void SetFlags( SvTLEntryFlags nFlags ); diff --git a/vcl/inc/iconview.hxx b/vcl/inc/iconview.hxx index c421467fa705..67908deafe9d 100644 --- a/vcl/inc/iconview.hxx +++ b/vcl/inc/iconview.hxx @@ -59,8 +59,6 @@ public: /// Update entry size based on image size void UpdateEntrySize(const Image& pImage); - static bool IsSeparator(const SvTreeListEntry& rEntry); - protected: virtual void CalcEntryHeight(SvTreeListEntry const* pEntry) override; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index dd115a2f3273..ad5458e002e3 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -3641,7 +3641,7 @@ void SalInstanceTreeView::do_insert(const weld::TreeIter* pParent, int pos, cons SvTreeListEntry* pEntry = new SvTreeListEntry; if (bIsSeparator) - pEntry->SetFlags(pEntry->GetFlags() | SvTLEntryFlags::IS_SEPARATOR); + pEntry->SetSeparator(); if (m_xTreeView->nTreeFlags & SvTreeFlags::CHKBTN) AddStringItem(pEntry, u""_ustr, -1); @@ -5444,7 +5444,7 @@ void SalInstanceIconView::insert_separator(int pos, const OUString* /* pId */) const auto nInsertPos = pos == -1 ? TREELIST_APPEND : pos; const OUString sSep(VclResId(STR_SEPARATOR)); SvTreeListEntry* pEntry = new SvTreeListEntry; - pEntry->SetFlags(pEntry->GetFlags() | SvTLEntryFlags::IS_SEPARATOR); + pEntry->SetSeparator(); const Image aDummy; pEntry->AddItem(std::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); pEntry->AddItem(std::make_unique<SvLBoxString>(sSep)); diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx index 2ddea6824d1f..b946ca1ea834 100644 --- a/vcl/source/treelist/iconview.cxx +++ b/vcl/source/treelist/iconview.cxx @@ -48,7 +48,7 @@ IconView::IconView(vcl::Window* pParent, WinBits nBits) Size IconView::GetEntrySize(const SvTreeListEntry& entry) const { - if (IsSeparator(entry)) + if (entry.IsSeparator()) return { GetEntryWidth() * GetColumnCount(), separatorHeight }; return { GetEntryWidth(), GetEntryHeight() }; } @@ -71,18 +71,13 @@ bool IconView::HasSeparatorEntry() const for (sal_uInt32 i = 0; i < GetEntryCount(); i++) { SvTreeListEntry* pEntry = GetEntry(i); - if (pEntry && IsSeparator(*pEntry)) + if (pEntry && pEntry->IsSeparator()) return true; } return false; } -bool IconView::IsSeparator(const SvTreeListEntry& rEntry) -{ - return bool(rEntry.GetFlags() & SvTLEntryFlags::IS_SEPARATOR); -} - void IconView::CalcEntryHeight(SvTreeListEntry const* pEntry) { int nHeight = nSpacing * 2; @@ -344,7 +339,7 @@ void IconView::DumpEntryAndSiblings(tools::JsonWriter& rJsonWriter, SvTreeListEn if (IsSelected(pEntry)) rJsonWriter.put("selected", true); - if (IsSeparator(*pEntry)) + if (pEntry->IsSeparator()) rJsonWriter.put("separator", true); rJsonWriter.put("row", GetModel()->GetAbsPos(pEntry)); diff --git a/vcl/source/treelist/iconviewimpl.cxx b/vcl/source/treelist/iconviewimpl.cxx index 6c20903b3b90..8103e3adb8be 100644 --- a/vcl/source/treelist/iconviewimpl.cxx +++ b/vcl/source/treelist/iconviewimpl.cxx @@ -48,7 +48,7 @@ void IconViewImpl::IterateVisibleEntryAreas(const IterateEntriesFunc& f, bool fr entry = m_pView->NextVisible(entry)) { const Size s = GetEntrySize(*entry); - if (x >= rowWidth || IconView::IsSeparator(*entry)) + if (x >= rowWidth || entry->IsSeparator()) { column = 0; x = 0; @@ -69,7 +69,7 @@ tools::Long IconViewImpl::GetEntryRow(const SvTreeListEntry* entry) const tools::Long nEntryRow = -1; auto GetRow = [entry, &nEntryRow, row = -1](const EntryAreaInfo& info) mutable { - if (info.column == 0 && !IconView::IsSeparator(info.entry)) + if (info.column == 0 && !info.entry.IsSeparator()) ++row; if (&info.entry != entry) return CallbackResult::Continue; @@ -86,7 +86,7 @@ void IconViewImpl::SetStartEntry(SvTreeListEntry* entry) tools::Long row = -1; auto GetEntryAndRow = [&entry, &row, max, found = entry](const EntryAreaInfo& info) mutable { - if (info.column == 0 && !IconView::IsSeparator(info.entry)) + if (info.column == 0 && !info.entry.IsSeparator()) { found = &info.entry; ++row; @@ -125,7 +125,7 @@ SvTreeListEntry* IconViewImpl::GoToPrevRow(SvTreeListEntry* pEntry, int nRows) c auto FindPrev = [this, pEntry, nRows, &pPrev, prevs = std::vector<SvTreeListEntry*>()](const EntryAreaInfo& info) mutable { - if (info.column == 0 && !IconView::IsSeparator(info.entry)) + if (info.column == 0 && !info.entry.IsSeparator()) prevs.push_back(&info.entry); if (pEntry == &info.entry) { @@ -136,7 +136,7 @@ SvTreeListEntry* IconViewImpl::GoToPrevRow(SvTreeListEntry* pEntry, int nRows) c for (short column = info.column; column; --column) { SvTreeListEntry* pNext = m_pView->NextVisible(pPrev); - if (!pNext || IconView::IsSeparator(*pNext)) + if (!pNext || pNext->IsSeparator()) break; pPrev = pNext; } @@ -155,7 +155,7 @@ SvTreeListEntry* IconViewImpl::GoToNextRow(SvTreeListEntry* pEntry, int nRows) c SvTreeListEntry* pNext = pEntry; auto FindNext = [pEntry, nRows, &pNext, column = -1](const EntryAreaInfo& info) mutable { - if (info.column <= column && !IconView::IsSeparator(info.entry)) + if (info.column <= column && !info.entry.IsSeparator()) { if (info.column == 0 && --nRows < 0) return CallbackResult::Stop; @@ -375,7 +375,7 @@ void IconViewImpl::AdjustScrollBars( Size& rSize ) auto CountRowsAndHeight = [&nTotalRows, &totalHeight](const EntryAreaInfo& info) { totalHeight = std::max(totalHeight, info.area.Bottom()); - if (info.column == 0 && !IconView::IsSeparator(info.entry)) + if (info.column == 0 && !info.entry.IsSeparator()) ++nTotalRows; return CallbackResult::Continue; }; diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx index 80410f967544..38f8d74cb9f0 100644 --- a/vcl/source/treelist/svlbitm.cxx +++ b/vcl/source/treelist/svlbitm.cxx @@ -193,7 +193,7 @@ void SvLBoxString::Paint( const SvViewDataEntry* /*pView*/, const SvTreeListEntry& rEntry) { DrawTextFlags nStyle = (rDev.IsEnabled() && !mbDisabled) ? DrawTextFlags::NONE : DrawTextFlags::Disable; - if (bool(rEntry.GetFlags() & SvTLEntryFlags::IS_SEPARATOR)) + if (rEntry.IsSeparator()) { Point aStartPos(0, rPos.Y() - 2); tools::Rectangle aRegion(aStartPos, Size(rDev.GetSizePixel().Width(), 4)); @@ -265,7 +265,7 @@ void SvLBoxString::InitViewData( if( !pViewData ) pViewData = pView->GetViewDataItem( pEntry, this ); - if (bool(pEntry->GetFlags() & SvTLEntryFlags::IS_SEPARATOR)) + if (pEntry->IsSeparator()) { pViewData->mnWidth = -1; pViewData->mnHeight = 0; diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index a9768badfe12..4f5c85947760 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2613,7 +2613,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, tools::Long nLine, vcl: Size aRectSize(0, nTempEntryHeight); SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry ); - const bool bSeparator(rEntry.GetFlags() & SvTLEntryFlags::IS_SEPARATOR); + const bool bSeparator(rEntry.IsSeparator()); const auto nMaxContextBmpWidthBeforeIndentIsNeeded = nIndent + GetExpandedNodeBmp().GetSizePixel().Width() / 2; diff --git a/vcl/source/treelist/treelistentry.cxx b/vcl/source/treelist/treelistentry.cxx index 59f9680d002e..863c2ef65efa 100644 --- a/vcl/source/treelist/treelistentry.cxx +++ b/vcl/source/treelist/treelistentry.cxx @@ -201,6 +201,16 @@ bool SvTreeListEntry::HasChildrenOnDemand() const return static_cast<bool>(nEntryFlags & SvTLEntryFlags::CHILDREN_ON_DEMAND); } +void SvTreeListEntry::SetSeparator() +{ + SetFlags(GetFlags() | SvTLEntryFlags::IS_SEPARATOR); +} + +bool SvTreeListEntry::IsSeparator() const +{ + return bool(GetFlags() & SvTLEntryFlags::IS_SEPARATOR); +} + void SvTreeListEntry::SetFlags( SvTLEntryFlags nFlags ) { nEntryFlags = nFlags;