vcl: Also pass the item in treeview callback when entry edited

So far, the callback called when a SvTreeListBox
entry was edited contained the SvTreeListEntry
and the new text of the entry.

Pass also the entry's item (SvLBoxItem) in addition,
so the handler can take that into account.

This will be used in an upcoming commit to extend
weld::TreeView::signal_editing_done to also pass
the index of the edited column.

Change-Id: Iad2866d8fcc710d82f4f0dc0661a3b1f0bebaeab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204303
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2026-04-26 18:09:18 +02:00
parent 504d1aa22e
commit b6dc3ce75d
7 changed files with 39 additions and 18 deletions
+5 -4
View File
@@ -111,7 +111,7 @@ private:
std::vector<rtl::Reference<AccessibleBrowseBoxHeaderCell>> m_aAccessibleChildren;
Link<SvTreeListEntry*, bool> m_aEditingEntryHdl;
Link<const IterString&, bool> m_aEditedEntryHdl;
Link<const EntryItemText&, bool> m_aEditedEntryHdl;
DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void );
DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void );
@@ -223,7 +223,7 @@ public:
m_aEditingEntryHdl = rLink;
}
void SetEditedEntryHdl(const Link<const IterString&, bool>& rLink)
void SetEditedEntryHdl(const Link<const EntryItemText&, bool>& rLink)
{
m_aEditedEntryHdl = rLink;
}
@@ -239,9 +239,10 @@ public:
return m_aEditingEntryHdl.Call(pEntry);
}
virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override
virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem,
const OUString& rNewText) override
{
return m_aEditedEntryHdl.Call(IterString(rEntry, rNewText));
return m_aEditedEntryHdl.Call(EntryItemText(rEntry, pItem, rNewText));
}
};
+16 -2
View File
@@ -176,7 +176,20 @@ struct SvTreeListBoxImpl;
typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args;
typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args;
typedef std::pair<SvTreeListEntry&, OUString> IterString;
struct EntryItemText
{
SvTreeListEntry& m_rEntry;
const SvLBoxItem* m_pItem;
OUString m_sText;
EntryItemText(SvTreeListEntry& rEntry, const SvLBoxItem* pItem, const OUString& rText)
: m_rEntry(rEntry)
, m_pItem(pItem)
, m_sText(rText)
{
}
};
class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox : public Control,
public DropTargetHelper,
@@ -669,7 +682,8 @@ public:
// Edits the Entry's first StringItem, 0 == Cursor
void EditEntry( SvTreeListEntry* pEntry );
virtual bool EditingEntry( SvTreeListEntry* pEntry );
virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText);
virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem,
const OUString& rNewText);
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
@@ -99,7 +99,8 @@ public:
virtual void RequestingChildren( SvTreeListEntry* pParent ) override;
virtual bool EditingEntry( SvTreeListEntry* pEntry ) override;
virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override;
virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem,
const OUString& rNewText) override;
DECL_LINK(OnSelectionChangeHdl, SvTreeListBox*, void);
DECL_LINK(OnExpandingHdl, SvTreeListBox*, bool);
@@ -1485,7 +1486,8 @@ bool UnoTreeListBoxImpl::EditingEntry( SvTreeListEntry* pEntry )
return mxPeer.is() && mxPeer->onEditingEntry( dynamic_cast< UnoTreeListEntry* >( pEntry ) );
}
bool UnoTreeListBoxImpl::EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText)
bool UnoTreeListBoxImpl::EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem*,
const OUString& rNewText)
{
return mxPeer.is() && mxPeer->onEditedEntry(dynamic_cast<UnoTreeListEntry*>(&rEntry), rNewText);
}
+1 -1
View File
@@ -1567,7 +1567,7 @@ protected:
DECL_LINK(StartDragHdl, SvTreeListBox*, bool);
DECL_STATIC_LINK(SalInstanceTreeView, FinishDragHdl, SvTreeListBox*, void);
DECL_LINK(EditingEntryHdl, SvTreeListEntry*, bool);
DECL_LINK(EditedEntryHdl, const IterString&, bool);
DECL_LINK(EditedEntryHdl, const EntryItemText&, bool);
DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void);
DECL_LINK(CompareHdl, const SvSortData&, sal_Int32);
DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString);
+5 -4
View File
@@ -21,7 +21,7 @@ class LclTabListBox final : public SvTabListBox
Link<SvTreeListBox*, bool> m_aStartDragHdl;
Link<SvTreeListBox*, void> m_aEndDragHdl;
Link<SvTreeListEntry*, bool> m_aEditingEntryHdl;
Link<const IterString&, bool> m_aEditedEntryHdl;
Link<const EntryItemText&, bool> m_aEditedEntryHdl;
public:
LclTabListBox(vcl::Window* pParent, WinBits nWinStyle)
@@ -36,7 +36,7 @@ public:
{
m_aEditingEntryHdl = rLink;
}
void SetEditedEntryHdl(const Link<const IterString&, bool>& rLink)
void SetEditedEntryHdl(const Link<const EntryItemText&, bool>& rLink)
{
m_aEditedEntryHdl = rLink;
}
@@ -127,9 +127,10 @@ public:
return m_aEditingEntryHdl.Call(pEntry);
}
virtual bool EditedEntry(SvTreeListEntry& rEntry, const OUString& rNewText) override
virtual bool EditedEntry(SvTreeListEntry& rEntry, const SvLBoxItem* pItem,
const OUString& rNewText) override
{
return m_aEditedEntryHdl.Call(IterString(rEntry, rNewText));
return m_aEditedEntryHdl.Call(EntryItemText(rEntry, pItem, rNewText));
}
};
+3 -3
View File
@@ -5083,10 +5083,10 @@ IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool)
return signal_editing_started(SalInstanceTreeIter(*this, pEntry));
}
IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const IterString&, rIterString, bool)
IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const EntryItemText&, rEntryItemString, bool)
{
return signal_editing_done(
iter_string(SalInstanceTreeIter(*this, &rIterString.first), rIterString.second));
return signal_editing_done(iter_string(SalInstanceTreeIter(*this, &rEntryItemString.m_rEntry),
rEntryItemString.m_sText));
}
SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder,
+5 -2
View File
@@ -2131,7 +2131,10 @@ bool SvTreeListBox::EditingEntry( SvTreeListEntry* )
return true;
}
bool SvTreeListBox::EditedEntry(SvTreeListEntry&, const OUString&) { return true; }
bool SvTreeListBox::EditedEntry(SvTreeListEntry&, const SvLBoxItem*, const OUString&)
{
return true;
}
void SvTreeListBox::EnableInplaceEditing( bool bOn )
{
@@ -2774,7 +2777,7 @@ void SvTreeListBox::EditedText( const OUString& rStr )
{
if (m_pEdEntry) // we have to check if this entry is null that means that it is removed while editing
{
if (EditedEntry(*m_pEdEntry, rStr))
if (EditedEntry(*m_pEdEntry, m_pEdItem, rStr))
{
m_pEdItem->SetText(rStr);
m_pModel->InvalidateEntry(m_pEdEntry);