diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-03-31 13:02:37 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-03-31 18:13:34 +0200 |
commit | 6b568ab1cf9a47440a00b4e05ca82bd98e159555 (patch) | |
tree | 3b742b45de912ec5e3fe7edb28405a8d54e35756 /vcl | |
parent | 00748b30660abe34ae980cdc7b1a24ac305a90b2 (diff) |
add iter_next_visible to skip unexpanded entries
Change-Id: I64acfc28579135f52ad0021418e863988c05ca94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91431
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 76 |
2 files changed, 53 insertions, 32 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 9d6e20c9a1f5..0c5d94fbf09e 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -4179,6 +4179,15 @@ public: return rVclIter.iter != nullptr; } + virtual bool iter_next_visible(weld::TreeIter& rIter) const override + { + SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); + rVclIter.iter = m_xTreeView->NextVisible(rVclIter.iter); + if (rVclIter.iter && IsDummyEntry(rVclIter.iter)) + return iter_next_visible(rVclIter); + return rVclIter.iter != nullptr; + } + virtual bool iter_children(weld::TreeIter& rIter) const override { SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 0656f08a8a65..c804670dda7c 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -9248,6 +9248,44 @@ private: return false; } + bool iter_next(weld::TreeIter& rIter, bool bOnlyExpanded) const + { + GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreeIter tmp; + GtkTreeIter iter = rGtkIter.iter; + + bool ret = gtk_tree_model_iter_children(pModel, &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(pModel, &tmp)) + { + rGtkIter.iter = tmp; + return true; + } + // Move up level(s) until we find the level where the next node exists. + while (gtk_tree_model_iter_parent(pModel, &tmp, &iter)) + { + iter = tmp; + if (gtk_tree_model_iter_next(pModel, &tmp)) + { + rGtkIter.iter = tmp; + return true; + } + } + return false; + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -10213,38 +10251,7 @@ public: virtual bool iter_next(weld::TreeIter& rIter) const override { - GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); - GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); - GtkTreeIter tmp; - GtkTreeIter iter = rGtkIter.iter; - - bool ret = gtk_tree_model_iter_children(pModel, &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(pModel, &tmp)) - { - rGtkIter.iter = tmp; - return true; - } - // Move up level(s) until we find the level where the next node exists. - while (gtk_tree_model_iter_parent(pModel, &tmp, &iter)) - { - iter = tmp; - if (gtk_tree_model_iter_next(pModel, &tmp)) - { - rGtkIter.iter = tmp; - return true; - } - } - return false; + return iter_next(rIter, false); } virtual bool iter_previous(weld::TreeIter& rIter) const override @@ -10285,6 +10292,11 @@ public: return false; } + virtual bool iter_next_visible(weld::TreeIter& rIter) const override + { + return iter_next(rIter, true); + } + virtual bool iter_children(weld::TreeIter& rIter) const override { GtkInstanceTreeIter& rGtkIter = static_cast<GtkInstanceTreeIter&>(rIter); |