summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/DiagramDialog.cxx19
-rw-r--r--cui/source/inc/DiagramDialog.hxx2
-rw-r--r--cui/uiconfig/ui/diagramdialog.ui14
3 files changed, 33 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);
};
diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui
index 98a67717209a..c05031f19bc4 100644
--- a/cui/uiconfig/ui/diagramdialog.ui
+++ b/cui/uiconfig/ui/diagramdialog.ui
@@ -129,6 +129,20 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="btnRemove">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>