From 897bd0517d835ba00458279311e5d8ff11079dd7 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 18 Sep 2020 10:09:54 +0100 Subject: Related: tdf#136559 set multiple columns in model at the same time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reduces time from 40s to 13s Change-Id: I01d6a4fcaa5a868f9b9f9292f4a7e99e216ea23b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102988 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/unx/gtk3/gtk3gtkinst.cxx | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'vcl/unx') diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 660e07374fb4..471b353bd64b 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -9444,6 +9444,30 @@ private: return bRet; } + void set_toggle(const GtkTreeIter& iter, TriState eState, int col) + { + if (col == -1) + col = m_nExpanderToggleCol; + else + col = to_internal_model(col); + + if (eState == TRISTATE_INDET) + { + gtk_tree_store_set(m_pTreeStore, const_cast(&iter), + m_aToggleVisMap[col], true, // checkbuttons are invisible until toggled on or off + m_aToggleTriStateMap[col], true, // tristate on + -1); + } + else + { + gtk_tree_store_set(m_pTreeStore, const_cast(&iter), + m_aToggleVisMap[col], true, // checkbuttons are invisible until toggled on or off + m_aToggleTriStateMap[col], false, // tristate off + col, eState == TRISTATE_TRUE, // set toggle state + -1); + } + } + void set(const GtkTreeIter& iter, int col, const OUString& rText) { OString aStr(OUStringToOString(rText, RTL_TEXTENCODING_UTF8)); @@ -10651,42 +10675,18 @@ public: return get_bool(rGtkIter.iter, col) ? TRISTATE_TRUE : TRISTATE_FALSE; } - virtual void set_toggle(int pos, TriState eState, int col) override - { - if (col == -1) - col = m_nExpanderToggleCol; - else - col = to_internal_model(col); - - // checkbuttons are invisible until toggled on or off - set(pos, m_aToggleVisMap[col], true); - if (eState == TRISTATE_INDET) - set(pos, m_aToggleTriStateMap[col], true); - else - { - set(pos, m_aToggleTriStateMap[col], false); - set(pos, col, eState == TRISTATE_TRUE); - } - } - virtual void set_toggle(const weld::TreeIter& rIter, TriState eState, int col) override { const GtkInstanceTreeIter& rGtkIter = static_cast(rIter); + set_toggle(rGtkIter.iter, eState, col); + } - if (col == -1) - col = m_nExpanderToggleCol; - else - col = to_internal_model(col); - - // checkbuttons are invisible until toggled on or off - set(rGtkIter.iter, m_aToggleVisMap[col], true); - if (eState == TRISTATE_INDET) - set(rGtkIter.iter, m_aToggleTriStateMap[col], true); - else - { - set(rGtkIter.iter, m_aToggleTriStateMap[col], false); - set(rGtkIter.iter, col, eState == TRISTATE_TRUE); - } + virtual void set_toggle(int pos, TriState eState, int col) override + { + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreeIter iter; + if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos)) + set_toggle(iter, eState, col); } virtual void enable_toggle_buttons(weld::ColumnToggleType eType) override -- cgit