[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 31 16:14:12 UTC 2020


 include/vcl/weld.hxx          |    2 +
 vcl/source/app/salvtables.cxx |    9 ++++
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   76 ++++++++++++++++++++++++------------------
 3 files changed, 55 insertions(+), 32 deletions(-)

New commits:
commit 6b568ab1cf9a47440a00b4e05ca82bd98e159555
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Mar 31 13:02:37 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 31 18:13:34 2020 +0200

    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 at redhat.com>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 35e474ca4a3b..15dd5ad91de8 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -900,6 +900,8 @@ public:
     virtual bool iter_next(TreeIter& rIter) const = 0;
     // set iter to point to previous node, sibling first then depth
     virtual bool iter_previous(TreeIter& rIter) const = 0;
+    // set iter to point to next node, depth first but only if expanded, then sibling
+    virtual bool iter_next_visible(TreeIter& rIter) const = 0;
     virtual bool iter_children(TreeIter& rIter) const = 0;
     bool iter_nth_sibling(TreeIter& rIter, int nChild) const
     {
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);


More information about the Libreoffice-commits mailing list