diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-09-20 12:53:45 +0200 |
---|---|---|
committer | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-09-25 09:31:08 +0200 |
commit | 711c0b6331958da4fd53eb6c4f9ecd5a422bb186 (patch) | |
tree | e17b463e3f813cc4a4d849d91397adc610f121db /cui/source | |
parent | b13421011d9377676e1adc282634991d5064a866 (diff) |
SmartArt Edit UI: remove node
Removes data node from data model including associated presentation nodes,
transition nodes and all connections between them (child-parent and
presentation-of).
It still doesn't update order of remaining connections after removal, so
empty entries can happen. Additional step is needed or using better data
structures.
Change-Id: I96e0752b6ec5a19ae8e972dbd421314e6c442b53
Reviewed-on: https://gerrit.libreoffice.org/79279
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com>
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/DiagramDialog.cxx | 19 | ||||
-rw-r--r-- | cui/source/inc/DiagramDialog.hxx | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx index 4891ef93daee..f3a4a069a19c 100644 --- a/cui/source/dialogs/DiagramDialog.cxx +++ b/cui/source/dialogs/DiagramDialog.cxx @@ -20,10 +20,12 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, , mpBtnOk(m_xBuilder->weld_button("btnOk")) , mpBtnCancel(m_xBuilder->weld_button("btnCancel")) , mpBtnAdd(m_xBuilder->weld_button("btnAdd")) + , mpBtnRemove(m_xBuilder->weld_button("btnRemove")) , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram")) , mpTextAdd(m_xBuilder->weld_text_view("textAdd")) { mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick)); + mpBtnRemove->connect_clicked(LINK(this, DiagramDialog, OnRemoveClick)); populateTree(nullptr, OUString()); @@ -40,15 +42,28 @@ IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) OUString sText = mpTextAdd->get_text(); if (!sText.isEmpty()) { + OUString sNodeId = mpDiagramData->addNode(sText); std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); - mpTreeDiagram->insert(nullptr, -1, &sText, nullptr, nullptr, nullptr, nullptr, false, + mpTreeDiagram->insert(nullptr, -1, &sText, &sNodeId, nullptr, nullptr, nullptr, false, pEntry.get()); mpTreeDiagram->select(*pEntry); - mpDiagramData->addNode(sText); comphelper::dispatchCommand(".uno:RegenerateDiagram", {}); } } +IMPL_LINK_NOARG(DiagramDialog, OnRemoveClick, weld::Button&, void) +{ + std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); + if (mpTreeDiagram->get_selected(pEntry.get())) + { + if (mpDiagramData->removeNode(mpTreeDiagram->get_id(*pEntry))) + { + mpTreeDiagram->remove(*pEntry); + comphelper::dispatchCommand(".uno:RegenerateDiagram", {}); + } + } +} + void DiagramDialog::populateTree(const weld::TreeIter* pParent, const OUString& rParentId) { auto aItems = mpDiagramData->getChildren(rParentId); diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx index 461ffee9a7e6..e97144050a0e 100644 --- a/cui/source/inc/DiagramDialog.hxx +++ b/cui/source/inc/DiagramDialog.hxx @@ -27,10 +27,12 @@ private: std::unique_ptr<weld::Button> mpBtnOk; std::unique_ptr<weld::Button> mpBtnCancel; std::unique_ptr<weld::Button> mpBtnAdd; + std::unique_ptr<weld::Button> mpBtnRemove; std::unique_ptr<weld::TreeView> mpTreeDiagram; std::unique_ptr<weld::TextView> mpTextAdd; DECL_LINK(OnAddClick, weld::Button&, void); + DECL_LINK(OnRemoveClick, weld::Button&, void); void populateTree(const weld::TreeIter* pParent, const OUString& rParentId); }; |