diff options
author | Henry Castro <hcastro@collabora.com> | 2020-12-17 11:02:40 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2020-12-22 13:04:47 +0100 |
commit | 07ba7227104f5c30a6dbaa88314cf62aac28b7c5 (patch) | |
tree | 62ba6bb8b58f8142791b92e4f2938e9d6e5b5e93 | |
parent | 71ec214d7583f637fefcb5eca13c637cc6b38029 (diff) |
jsdialog: add the "expand" action
to the tree list view control
Change-Id: I69f1b06748053fdfe9164c52e889629e51f91409
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107914
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
-rw-r--r-- | vcl/inc/salvtables.hxx | 2 | ||||
-rw-r--r-- | vcl/jsdialog/executor.cxx | 20 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 7 |
3 files changed, 22 insertions, 7 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 47afc48903f2..c435230653c5 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -1566,6 +1566,8 @@ public: virtual bool get_iter_first(weld::TreeIter& rIter) const override; + virtual bool get_iter_abs_pos(weld::TreeIter& rIter, int nPos) const; + virtual bool iter_next_sibling(weld::TreeIter& rIter) const override; virtual bool iter_previous_sibling(weld::TreeIter& rIter) const override; diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx index b2103fbe865f..0ff259e7bfd4 100644 --- a/vcl/jsdialog/executor.cxx +++ b/vcl/jsdialog/executor.cxx @@ -179,7 +179,7 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat } else if (sControlType == "treeview") { - auto pTreeView = dynamic_cast<weld::TreeView*>(pWidget); + auto pTreeView = dynamic_cast<JSTreeView*>(pWidget); if (pTreeView) { if (sAction == "change") @@ -209,6 +209,16 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat LOKTrigger::trigger_row_activated(*pTreeView); return true; } + else if (sAction == "expand") + { + OString nRowString + = OUStringToOString(rData["data"], RTL_TEXTENCODING_ASCII_US); + int nAbsPos = std::atoi(nRowString.getStr()); + std::unique_ptr<weld::TreeIter> itEntry(pTreeView->make_iterator()); + pTreeView->get_iter_abs_pos(*itEntry, nAbsPos); + pTreeView->expand_row(*itEntry); + return true; + } else if (sAction == "dragstart") { OString nRowString @@ -216,17 +226,13 @@ bool ExecuteAction(sal_uInt64 nWindowId, const OString& rWidget, StringMap& rDat int nRow = std::atoi(nRowString.getStr()); pTreeView->select(nRow); + pTreeView->drag_start(); - JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView); - if (pJSTreeView) - pJSTreeView->drag_start(); return true; } else if (sAction == "dragend") { - JSTreeView* pJSTreeView = dynamic_cast<JSTreeView*>(pTreeView); - if (pJSTreeView) - pJSTreeView->drag_end(); + pTreeView->drag_end(); return true; } } diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index e2e322e725fa..47563271e05b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -4329,6 +4329,13 @@ bool SalInstanceTreeView::get_iter_first(weld::TreeIter& rIter) const return rVclIter.iter != nullptr; } +bool SalInstanceTreeView::get_iter_abs_pos(weld::TreeIter& rIter, int nAbsPos) const +{ + SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); + rVclIter.iter = m_xTreeView->GetEntryAtAbsPos(nAbsPos); + return rVclIter.iter != nullptr; +} + bool SalInstanceTreeView::iter_next_sibling(weld::TreeIter& rIter) const { SalInstanceTreeIter& rVclIter = static_cast<SalInstanceTreeIter&>(rIter); |