vcl/inc/jsdialog/jsdialogbuilder.hxx |    4 ++++
 vcl/jsdialog/executor.cxx            |   10 ++++++++--
 vcl/jsdialog/jsdialogbuilder.cxx     |   35 +++++++++++++++++++++++++++++++++--
 3 files changed, 45 insertions(+), 4 deletions(-)

New commits:
commit 6be76f54a4e94b952975dfded25afff60257c6dd
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Wed May 3 04:30:55 2023 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri May 12 17:25:36 2023 +0200

    LOK: Navi-4 tree dblclick
    
    Removed sendUpdate that was called 1/sec, so selection dont revert 1/sec.
    Put sendUpdate into set_cursor(), that seems to be a better spot.
    
    Fixed set_cursor usage in executor, that caused slection to not work
    in dblclick at all.
    Because set_cursor(int) use not absolute position, but relative to parent
    And root was used as parent, so it picked SwContent from the 1. lvl,
    but the 1. lvl items are not real items, just SwContentTypes ..
    e.g.:Headings.. that cannot be activated.. so never happened anything.
    
    Change-Id: Iea373af3a0832a4f97202122bd36022eddf26efe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151308
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151703
    Tested-by: Jenkins

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 27ac31784228..4d38d66fe9f1 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -749,6 +749,10 @@ public:
     virtual void expand_row(const weld::TreeIter& rIter) override;
     virtual void collapse_row(const weld::TreeIter& rIter) override;
 
+    virtual void set_cursor(const weld::TreeIter& rIter) override;
+    void set_cursor_without_notify(const weld::TreeIter& rIter);
+    virtual void set_cursor(int pos) override;
+
     using SalInstanceTreeView::remove;
     virtual void remove(int pos) override;
     virtual void remove(const weld::TreeIter& rIter) override;
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 2784acf0cae8..af514bc70dde 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -441,7 +441,8 @@ bool ExecuteAction(const OUString& nWindowId, const 
OUString& rWidget, StringMap
                     std::unique_ptr<weld::TreeIter> 
itEntry(pTreeView->make_iterator());
                     pTreeView->get_iter_abs_pos(*itEntry, nAbsPos);
                     pTreeView->select(*itEntry);
-                    pTreeView->set_cursor(*itEntry);
+                    pTreeView->set_cursor_without_notify(*itEntry);
+                    pTreeView->grab_focus();
                     LOKTrigger::trigger_changed(*pTreeView);
                     return true;
                 }
@@ -450,8 +451,11 @@ bool ExecuteAction(const OUString& nWindowId, const 
OUString& rWidget, StringMap
                     sal_Int32 nRow = o3tl::toInt32(rData["data"]);
 
                     pTreeView->unselect_all();
+                    std::unique_ptr<weld::TreeIter> 
itEntry(pTreeView->make_iterator());
+                    pTreeView->get_iter_abs_pos(*itEntry, nRow);
                     pTreeView->select(nRow);
-                    pTreeView->set_cursor(nRow);
+                    pTreeView->set_cursor_without_notify(*itEntry);
+                    pTreeView->grab_focus();
                     LOKTrigger::trigger_changed(*pTreeView);
                     LOKTrigger::trigger_row_activated(*pTreeView);
                     return true;
@@ -461,6 +465,8 @@ bool ExecuteAction(const OUString& nWindowId, const 
OUString& rWidget, StringMap
                     sal_Int32 nAbsPos = o3tl::toInt32(rData["data"]);
                     std::unique_ptr<weld::TreeIter> 
itEntry(pTreeView->make_iterator());
                     pTreeView->get_iter_abs_pos(*itEntry, nAbsPos);
+                    pTreeView->set_cursor_without_notify(*itEntry);
+                    pTreeView->grab_focus();
                     pTreeView->expand_row(*itEntry);
                     return true;
                 }
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index ed3a0893dbcb..a3c55e28ddfb 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -2016,16 +2016,47 @@ void JSTreeView::clear()
     sendUpdate();
 }
 
+void JSTreeView::set_cursor_without_notify(const weld::TreeIter& rIter)
+{
+    SalInstanceTreeView::set_cursor(rIter);
+}
+
+void JSTreeView::set_cursor(const weld::TreeIter& rIter)
+{
+    SalInstanceTreeView::set_cursor(rIter);
+    sendUpdate();
+}
+
+void JSTreeView::set_cursor(int pos)
+{
+    SalInstanceTreeView::set_cursor(pos);
+    sendUpdate();
+}
+
 void JSTreeView::expand_row(const weld::TreeIter& rIter)
 {
+    bool bNotify = false;
+    const SalInstanceTreeIter& rVclIter = static_cast<const 
SalInstanceTreeIter&>(rIter);
+    if (!m_xTreeView->IsExpanded(rVclIter.iter))
+        bNotify = true;
+
     SalInstanceTreeView::expand_row(rIter);
-    sendUpdate();
+
+    if (bNotify)
+        sendUpdate();
 }
 
 void JSTreeView::collapse_row(const weld::TreeIter& rIter)
 {
+    bool bNotify = false;
+    const SalInstanceTreeIter& rVclIter = static_cast<const 
SalInstanceTreeIter&>(rIter);
+    if (m_xTreeView->IsExpanded(rVclIter.iter))
+        bNotify = true;
+
     SalInstanceTreeView::collapse_row(rIter);
-    sendUpdate();
+
+    if (bNotify)
+        sendUpdate();
 }
 
 JSExpander::JSExpander(JSDialogSender* pSender, ::VclExpander* pExpander,

Reply via email to