diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-08-30 10:20:38 +0200 |
---|---|---|
committer | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-09-02 12:38:31 +0200 |
commit | 6eb7dd4a2683fb4c28506a464317d7ee54cfe1de (patch) | |
tree | efb2905d640dfcb080355afd228c0c76864026d9 /cui | |
parent | 1485bcc796dd8bd53762368ec4a1345ddb7cda72 (diff) |
SmartArt edit UI: add new node
First approach to adding new node. Currently it's possible only to add
top-level node to the end of diagram.
Change-Id: Icd9530ab2fb8987a1690ffc96c244cc845b72eba
Reviewed-on: https://gerrit.libreoffice.org/78286
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/DiagramDialog.cxx | 20 | ||||
-rw-r--r-- | cui/source/inc/DiagramDialog.hxx | 4 | ||||
-rw-r--r-- | cui/uiconfig/ui/diagramdialog.ui | 39 |
3 files changed, 61 insertions, 2 deletions
diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx index c48e8f58089d..f3b84c0fcc4e 100644 --- a/cui/source/dialogs/DiagramDialog.cxx +++ b/cui/source/dialogs/DiagramDialog.cxx @@ -9,7 +9,9 @@ #include <DiagramDialog.hxx> +#include <comphelper/dispatchcommand.hxx> #include <svx/DiagramDataInterface.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> DiagramDialog::DiagramDialog(weld::Window* pWindow, std::shared_ptr<DiagramDataInterface> pDiagramData) @@ -17,8 +19,12 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, , mpDiagramData(pDiagramData) , mpBtnOk(m_xBuilder->weld_button("btnOk")) , mpBtnCancel(m_xBuilder->weld_button("btnCancel")) + , mpBtnAdd(m_xBuilder->weld_button("btnAdd")) , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram")) + , mpTextAdd(m_xBuilder->weld_text_view("textAdd")) { + mpBtnAdd->connect_clicked(LINK(this, DiagramDialog, OnAddClick)); + populateTree(nullptr, OUString()); // expand all items @@ -29,6 +35,20 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow, }); } +IMPL_LINK_NOARG(DiagramDialog, OnAddClick, weld::Button&, void) +{ + OUString sText = mpTextAdd->get_text(); + if (!sText.isEmpty()) + { + std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator()); + mpTreeDiagram->insert(nullptr, -1, &sText, nullptr, nullptr, nullptr, nullptr, false, + pEntry.get()); + mpTreeDiagram->select(*pEntry); + mpDiagramData->addNode(sText); + comphelper::dispatchCommand(".uno:RegenerateDiagram", {}); + } +} + void DiagramDialog::populateTree(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 ec47de6414bd..c1ce3316427e 100644 --- a/cui/source/inc/DiagramDialog.hxx +++ b/cui/source/inc/DiagramDialog.hxx @@ -26,7 +26,11 @@ private: std::shared_ptr<DiagramDataInterface> mpDiagramData; std::unique_ptr<weld::Button> mpBtnOk; std::unique_ptr<weld::Button> mpBtnCancel; + std::unique_ptr<weld::Button> mpBtnAdd; std::unique_ptr<weld::TreeView> mpTreeDiagram; + std::unique_ptr<weld::TextView> mpTextAdd; + + DECL_LINK(OnAddClick, weld::Button&, void); void populateTree(weld::TreeIter* pParent, const OUString& rParentId); }; diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui index 000f340f028a..c52376f0b3a3 100644 --- a/cui/uiconfig/ui/diagramdialog.ui +++ b/cui/uiconfig/ui/diagramdialog.ui @@ -49,7 +49,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -57,7 +57,6 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="headers_visible">False</property> - <property name="show_expanders">True</property> <child internal-child="selection"> <object class="GtkTreeSelection"/> </child> @@ -68,6 +67,42 @@ <property name="position">0</property> </packing> </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkTextView" id="textAdd"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="btnAdd"> + <property name="label">gtk-add</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">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> </child> <action-widgets> |