[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 3 09:00:39 UTC 2020
include/vcl/weld.hxx | 7 +++++++
vcl/source/app/salvtables.cxx | 9 ++++++---
vcl/unx/gtk3/gtk3gtkinst.cxx | 20 ++++++++++++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
New commits:
commit b15918747192943ab174dff806797ab662a52895
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Mar 2 13:50:28 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 3 09:59:55 2020 +0100
add a collapsing row hook
Change-Id: I83d690715a9e427d23b3f2316fd114c037487d54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89841
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 7f3463611a4d..75c38262c426 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -718,6 +718,8 @@ protected:
Link<const std::pair<const TreeIter&, OUString>&, bool> m_aEditingDoneHdl;
// if handler returns false, the expansion of the row is refused
Link<const TreeIter&, bool> m_aExpandingHdl;
+ // if handler returns false, the collapse of the row is refused
+ Link<const TreeIter&, bool> m_aCollapsingHdl;
Link<TreeView&, void> m_aVisibleRangeChangedHdl;
Link<TreeView&, void> m_aModelChangedHdl;
// if handler returns true, then menu has been show and event is consumed
@@ -736,6 +738,10 @@ protected:
{
return !m_aExpandingHdl.IsSet() || m_aExpandingHdl.Call(rIter);
}
+ bool signal_collapsing(const TreeIter& rIter)
+ {
+ return !m_aCollapsingHdl.IsSet() || m_aCollapsingHdl.Call(rIter);
+ }
void signal_visible_range_changed() { m_aVisibleRangeChangedHdl.Call(*this); }
void signal_model_changed() { m_aModelChangedHdl.Call(*this); }
@@ -962,6 +968,7 @@ public:
= 0;
void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; }
+ void connect_collapsing(const Link<const TreeIter&, bool>& rLink) { m_aCollapsingHdl = rLink; }
// rStartLink returns true to allow editing, false to disallow
// rEndLink returns true to accept the edit, false to reject
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 14da859c1a0c..e4aafd793bba 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4227,7 +4227,7 @@ public:
virtual void collapse_row(const weld::TreeIter& rIter) override
{
const SalInstanceTreeIter& rVclIter = static_cast<const SalInstanceTreeIter&>(rIter);
- if (m_xTreeView->IsExpanded(rVclIter.iter))
+ if (m_xTreeView->IsExpanded(rVclIter.iter) && signal_collapsing(rIter))
m_xTreeView->Collapse(rVclIter.iter);
}
@@ -4676,19 +4676,22 @@ IMPL_LINK(SalInstanceTreeView, HeaderBarClickedHdl, HeaderBar*, pHeaderBar, void
IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, SvTreeListBox*, bool)
{
SvTreeListEntry* pEntry = m_xTreeView->GetHdlEntry();
+ SalInstanceTreeIter aIter(pEntry);
+
if (m_xTreeView->IsExpanded(pEntry))
{
//collapsing;
- return true;
+ return signal_collapsing(aIter);
}
+ // expanding
+
// if there's a preexisting placeholder child, required to make this
// potentially expandable in the first place, now we remove it
SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry);
if (pPlaceHolder)
m_xTreeView->RemoveEntry(pPlaceHolder);
- SalInstanceTreeIter aIter(pEntry);
bool bRet = signal_expanding(aIter);
//expand disallowed, restore placeholder
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 6901202c9796..0720a6833b57 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -8604,6 +8604,7 @@ private:
gulong m_nChangedSignalId;
gulong m_nRowActivatedSignalId;
gulong m_nTestExpandRowSignalId;
+ gulong m_nTestCollapseRowSignalId;
gulong m_nVAdjustmentChangedSignalId;
gulong m_nRowDeletedSignalId;
gulong m_nRowInsertedSignalId;
@@ -8801,6 +8802,12 @@ private:
return !pThis->signal_test_expand_row(*iter);
}
+ static gboolean signalTestCollapseRow(GtkTreeView*, GtkTreeIter* iter, GtkTreePath*, gpointer widget)
+ {
+ GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
+ return !pThis->signal_test_collapse_row(*iter);
+ }
+
bool child_is_placeholder(GtkInstanceTreeIter& rGtkIter) const
{
bool bPlaceHolder = false;
@@ -8843,6 +8850,17 @@ private:
return bRet;
}
+ bool signal_test_collapse_row(GtkTreeIter& iter)
+ {
+ disable_notify_events();
+
+ GtkInstanceTreeIter aIter(iter);
+ bool bRet = signal_collapsing(aIter);
+
+ enable_notify_events();
+ return bRet;
+ }
+
static void signalCellToggled(GtkCellRendererToggle* pCell, const gchar *path, gpointer widget)
{
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
@@ -9134,6 +9152,7 @@ public:
G_CALLBACK(signalChanged), this))
, m_nRowActivatedSignalId(g_signal_connect(pTreeView, "row-activated", G_CALLBACK(signalRowActivated), this))
, m_nTestExpandRowSignalId(g_signal_connect(pTreeView, "test-expand-row", G_CALLBACK(signalTestExpandRow), this))
+ , m_nTestCollapseRowSignalId(g_signal_connect(pTreeView, "test-collapse-row", G_CALLBACK(signalTestCollapseRow), this))
, m_nVAdjustmentChangedSignalId(0)
, m_nPopupMenuSignalId(g_signal_connect(pTreeView, "popup-menu", G_CALLBACK(signalPopupMenu), this))
, m_nKeyPressSignalId(g_signal_connect(pTreeView, "key-press-event", G_CALLBACK(signalKeyPress), this))
@@ -10643,6 +10662,7 @@ public:
g_signal_handler_disconnect(pVAdjustment, m_nVAdjustmentChangedSignalId);
}
+ g_signal_handler_disconnect(m_pTreeView, m_nTestCollapseRowSignalId);
g_signal_handler_disconnect(m_pTreeView, m_nTestExpandRowSignalId);
g_signal_handler_disconnect(m_pTreeView, m_nRowActivatedSignalId);
g_signal_handler_disconnect(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId);
More information about the Libreoffice-commits
mailing list