vcl/qt5/QtInstanceTreeView.cxx | 40 +++++++++++++++++--- vcl/unx/gtk3/gtkinst.cxx | 81 ++++++++++++++++++----------------------- 2 files changed, 72 insertions(+), 49 deletions(-)
New commits: commit 16f588da18cc6d34d628ebb3154f6dc8a7ee7c21 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Aug 5 12:54:05 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 6 07:15:46 2025 +0200 gtk: Drop always false GtkInstanceTreeView::iter_next param `bOnlyExpanded` is always false since commit 87e33c3c1c481ee38d03f66412374cd9bd2d76cb Date: Tue Sep 1 17:11:08 2020 +0100 drop some unused methods , so drop the param and merge the helper function into the other GtkInstanceTreeView::iter_next. Change-Id: If0fea58eb0299f552a78d5241f647294664dbb49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188946 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 559e010a2b87..c2cdaa59b272 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -14614,49 +14614,6 @@ private: return false; } - bool iter_next(weld::TreeIter& rIter, bool bOnlyExpanded) const - { - GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); - GtkTreeIter tmp; - GtkTreeIter iter = rGtkIter.iter; - - bool ret = gtk_tree_model_iter_children(m_pTreeModel, &tmp, &iter); - if (ret && bOnlyExpanded && !get_row_expanded(rGtkIter)) - ret = false; - rGtkIter.iter = tmp; - if (ret) - { - //on-demand dummy entry doesn't count - if (get_text(rGtkIter, -1) == "<dummy>") - return iter_next(rGtkIter, bOnlyExpanded); - return true; - } - - tmp = iter; - if (gtk_tree_model_iter_next(m_pTreeModel, &tmp)) - { - rGtkIter.iter = tmp; - //on-demand dummy entry doesn't count - if (get_text(rGtkIter, -1) == "<dummy>") - return iter_next(rGtkIter, bOnlyExpanded); - return true; - } - // Move up level(s) until we find the level where the next node exists. - while (gtk_tree_model_iter_parent(m_pTreeModel, &tmp, &iter)) - { - iter = tmp; - if (gtk_tree_model_iter_next(m_pTreeModel, &tmp)) - { - rGtkIter.iter = tmp; - //on-demand dummy entry doesn't count - if (get_text(rGtkIter, -1) == "<dummy>") - return iter_next(rGtkIter, bOnlyExpanded); - return true; - } - } - return false; - } - #if !GTK_CHECK_VERSION(4, 0, 0) // tdf#154565 ignore the crossing event if it was triggered ultimately by a // key stroke which is likely from exiting the search box. This way we can @@ -15925,7 +15882,43 @@ public: virtual bool iter_next(weld::TreeIter& rIter) const override { - return iter_next(rIter, false); + GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); + GtkTreeIter tmp; + GtkTreeIter iter = rGtkIter.iter; + + bool ret = gtk_tree_model_iter_children(m_pTreeModel, &tmp, &iter); + rGtkIter.iter = tmp; + if (ret) + { + //on-demand dummy entry doesn't count + if (get_text(rGtkIter, -1) == "<dummy>") + return iter_next(rGtkIter); + return true; + } + + tmp = iter; + if (gtk_tree_model_iter_next(m_pTreeModel, &tmp)) + { + rGtkIter.iter = tmp; + //on-demand dummy entry doesn't count + if (get_text(rGtkIter, -1) == "<dummy>") + return iter_next(rGtkIter); + return true; + } + // Move up level(s) until we find the level where the next node exists. + while (gtk_tree_model_iter_parent(m_pTreeModel, &tmp, &iter)) + { + iter = tmp; + if (gtk_tree_model_iter_next(m_pTreeModel, &tmp)) + { + rGtkIter.iter = tmp; + //on-demand dummy entry doesn't count + if (get_text(rGtkIter, -1) == "<dummy>") + return iter_next(rGtkIter); + return true; + } + } + return false; } virtual bool iter_previous(weld::TreeIter& rIter) const override commit 670e20c59204d894f5e9e9e51245dedb874e4d30 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Aug 5 12:27:13 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 6 07:15:40 2025 +0200 tdf#130857 qt weld: Implement QtInstanceTreeView::all_foreach Do it similar as the GtkInstanceTreeView implementation does by reusing existing methods to get the first iterator and iterate from there. This depends on QtInstanceTreeView::iter_next to also get implemented to actually be useful, would currently assert there. Change-Id: If7e20d5b1104ab66c1f3eba0574406d49a926b5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188945 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 4dcb12682169..db0eb0adb64d 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -699,9 +699,17 @@ void QtInstanceTreeView::move_subtree(weld::TreeIter&, const weld::TreeIter*, in assert(false && "Not implemented yet"); } -void QtInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>&) +void QtInstanceTreeView::all_foreach(const std::function<bool(weld::TreeIter&)>& func) { - assert(false && "Not implemented yet"); + QtInstanceTreeIter aIter({}); + if (get_iter_first(aIter)) + { + do + { + if (func(aIter)) + return; + } while (iter_next(aIter)); + } } void QtInstanceTreeView::selected_foreach(const std::function<bool(weld::TreeIter&)>& func) commit 605da0cc7484906a7ddf8ab73231472bb5522796 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Aug 5 12:17:53 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Aug 6 07:15:33 2025 +0200 tdf#130857 qt weld: Implement QtInstanceTreeView::bulk_insert_for_each This will e.g. be used by the "Tools" -> "AutoCorrect" -> "AutoCorrect Options" dialog. Change-Id: I8bcd8c584558900a99579af16572da714bcbdd61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188940 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index a2ab9fe624c3..4dcb12682169 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -725,10 +725,32 @@ void QtInstanceTreeView::visible_foreach(const std::function<bool(weld::TreeIter } void QtInstanceTreeView::bulk_insert_for_each( - int, const std::function<void(weld::TreeIter&, int nSourceIndex)>&, const weld::TreeIter*, - const std::vector<int>*, bool) + int nSourceCount, const std::function<void(weld::TreeIter&, int nSourceIndex)>& func, + const weld::TreeIter* pParent, const std::vector<int>* pFixedWidths, bool) { - assert(false && "Not implemented yet"); + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + // clear existing children + const QModelIndex aParentIndex = pParent ? modelIndex(*pParent) : QModelIndex(); + const int nRows = m_pModel->rowCount(aParentIndex); + if (nRows > 0) + m_pModel->removeRows(0, nRows, aParentIndex); + + // insert new rows + m_pModel->insertRows(0, nSourceCount, aParentIndex); + + // call function for each row + for (int nRow = 0; nRow < nSourceCount; nRow++) + { + QtInstanceTreeIter aIter = treeIter(nRow, aParentIndex); + func(aIter, nRow); + } + + // set column widths + if (pFixedWidths) + set_column_fixed_widths(*pFixedWidths); + }); } bool QtInstanceTreeView::get_row_expanded(const weld::TreeIter& rIter) const