summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorGrzegorz Araminowicz <grzegorz.araminowicz@collabora.com>2019-08-27 08:47:26 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-08-27 15:05:24 +0200
commitfae4eb717427f542305d2978f5fa78cbf27eaafa (patch)
tree1dfb2a8f8a4f14aca442745deb62632ab81933cb /cui
parent423d16487b6d8bc048f546017da3b8274bc289cf (diff)
SmartArt edit UI: change plain text widget to tree view
Added getChildren() data interface method, so that it's possible to recursively fill tree view with (id, text) pairs Change-Id: Ic100ded3a3e125bf79f5caa421cd8f91e5210954 Reviewed-on: https://gerrit.libreoffice.org/78169 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/DiagramDialog.cxx23
-rw-r--r--cui/source/inc/DiagramDialog.hxx4
-rw-r--r--cui/uiconfig/ui/diagramdialog.ui7
3 files changed, 30 insertions, 4 deletions
diff --git a/cui/source/dialogs/DiagramDialog.cxx b/cui/source/dialogs/DiagramDialog.cxx
index f93b3bbdf28b..c48e8f58089d 100644
--- a/cui/source/dialogs/DiagramDialog.cxx
+++ b/cui/source/dialogs/DiagramDialog.cxx
@@ -17,9 +17,28 @@ DiagramDialog::DiagramDialog(weld::Window* pWindow,
, mpDiagramData(pDiagramData)
, mpBtnOk(m_xBuilder->weld_button("btnOk"))
, mpBtnCancel(m_xBuilder->weld_button("btnCancel"))
- , mpTextDiagram(m_xBuilder->weld_text_view("textDiagram"))
+ , mpTreeDiagram(m_xBuilder->weld_tree_view("treeDiagram"))
{
- mpTextDiagram->set_text(mpDiagramData->getString());
+ populateTree(nullptr, OUString());
+
+ // expand all items
+ weld::TreeView* pTreeDiagram = mpTreeDiagram.get();
+ pTreeDiagram->all_foreach([pTreeDiagram](weld::TreeIter& rEntry) {
+ pTreeDiagram->expand_row(rEntry);
+ return false;
+ });
+}
+
+void DiagramDialog::populateTree(weld::TreeIter* pParent, const OUString& rParentId)
+{
+ auto aItems = mpDiagramData->getChildren(rParentId);
+ for (auto& aItem : aItems)
+ {
+ std::unique_ptr<weld::TreeIter> pEntry(mpTreeDiagram->make_iterator());
+ mpTreeDiagram->insert(pParent, -1, &aItem.second, &aItem.first, nullptr, nullptr, nullptr,
+ false, pEntry.get());
+ populateTree(pEntry.get(), aItem.first);
+ }
}
DiagramDialog::~DiagramDialog() {}
diff --git a/cui/source/inc/DiagramDialog.hxx b/cui/source/inc/DiagramDialog.hxx
index 55a948c15cc4..ec47de6414bd 100644
--- a/cui/source/inc/DiagramDialog.hxx
+++ b/cui/source/inc/DiagramDialog.hxx
@@ -26,7 +26,9 @@ private:
std::shared_ptr<DiagramDataInterface> mpDiagramData;
std::unique_ptr<weld::Button> mpBtnOk;
std::unique_ptr<weld::Button> mpBtnCancel;
- std::unique_ptr<weld::TextView> mpTextDiagram;
+ std::unique_ptr<weld::TreeView> mpTreeDiagram;
+
+ void populateTree(weld::TreeIter* pParent, const OUString& rParentId);
};
#endif // INCLUDED_CUI_SOURCE_INC_DIAGRAMDIALOG_HXX
diff --git a/cui/uiconfig/ui/diagramdialog.ui b/cui/uiconfig/ui/diagramdialog.ui
index 6b6c888808df..000f340f028a 100644
--- a/cui/uiconfig/ui/diagramdialog.ui
+++ b/cui/uiconfig/ui/diagramdialog.ui
@@ -53,9 +53,14 @@
</packing>
</child>
<child>
- <object class="GtkTextView" id="textDiagram">
+ <object class="GtkTreeView" id="treeDiagram">
<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>
</object>
<packing>
<property name="expand">True</property>