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 a863bd126ee9a19f305542c836644f7daaa784a7 Author: Attila Szűcs <[email protected]> AuthorDate: Wed May 3 04:30:55 2023 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Fri May 5 10:53:26 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 <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 75ea450ec4c8..25281fb33236 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 737ae2f961b9..1accb3bc1de0 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -445,7 +445,8 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM 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; } @@ -454,8 +455,11 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM 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; @@ -465,6 +469,8 @@ bool ExecuteAction(const std::string& nWindowId, const OString& rWidget, StringM 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 ef59d1eb1e8f..3f094891c6eb 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -2021,16 +2021,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,
