jsdialog: add TreeView to TestWidgetDialog

Change-Id: I5c4f70d98dd8ea03c137cd368a2c097cd866609d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144222
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Rashesh Padia <rashesh.padia@collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145067
Tested-by: Jenkins
diff --git a/cui/inc/widgettestdlg.hxx b/cui/inc/widgettestdlg.hxx
index dabc2ee..02ab7f3 100644
--- a/cui/inc/widgettestdlg.hxx
+++ b/cui/inc/widgettestdlg.hxx
@@ -18,10 +18,14 @@ class WidgetTestDialog final : public weld::GenericDialogController
private:
    std::unique_ptr<weld::Button> m_xOKButton;
    std::unique_ptr<weld::Button> m_xCancelButton;
    std::unique_ptr<weld::TreeView> m_xTreeView;
    std::unique_ptr<weld::TreeView> m_xTreeView2;

    DECL_LINK(OkHdl, weld::Button&, void);
    DECL_LINK(CancelHdl, weld::Button&, void);

    void FillTreeView();

public:
    WidgetTestDialog(weld::Window* pParent);
    ~WidgetTestDialog();
diff --git a/cui/source/dialogs/widgettestdlg.cxx b/cui/source/dialogs/widgettestdlg.cxx
index 5475151..51ecef3 100644
--- a/cui/source/dialogs/widgettestdlg.cxx
+++ b/cui/source/dialogs/widgettestdlg.cxx
@@ -8,15 +8,20 @@
*/

#include <widgettestdlg.hxx>
#include <bitmaps.hlst>

WidgetTestDialog::WidgetTestDialog(weld::Window* pParent)
    : GenericDialogController(pParent, "cui/ui/widgettestdialog.ui", "WidgetTestDialog")
{
    m_xOKButton = m_xBuilder->weld_button("ok_btn");
    m_xCancelButton = m_xBuilder->weld_button("cancel_btn");
    m_xTreeView = m_xBuilder->weld_tree_view("contenttree");
    m_xTreeView2 = m_xBuilder->weld_tree_view("contenttree2");

    m_xOKButton->connect_clicked(LINK(this, WidgetTestDialog, OkHdl));
    m_xCancelButton->connect_clicked(LINK(this, WidgetTestDialog, CancelHdl));

    FillTreeView();
}

WidgetTestDialog::~WidgetTestDialog() {}
@@ -28,4 +33,25 @@ IMPL_LINK_NOARG(WidgetTestDialog, CancelHdl, weld::Button&, void)
    m_xDialog->response(RET_CANCEL);
}

void WidgetTestDialog::FillTreeView()
{
    OUString aImage1(RID_SVXBMP_CELL_LR);
    OUString aImage2(RID_SVXBMP_SHADOW_BOT_LEFT);

    for (size_t nCount = 0; nCount < 4; nCount++)
    {
        OUString sText = OUString::Concat("Test ") + OUString::Concat(OUString::number(nCount));
        std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
        m_xTreeView->insert(nullptr, -1, &sText, &sText, nullptr, nullptr, false, xEntry.get());
        m_xTreeView->set_image(*xEntry, (nCount % 2 == 0) ? aImage1 : aImage2);

        m_xTreeView2->append();
        m_xTreeView2->set_image(nCount, (nCount % 2 == 0) ? aImage1 : aImage2);
        m_xTreeView2->set_text(nCount, "First Column", 0);
        m_xTreeView2->set_text(
            nCount, OUString::Concat("Row ") + OUString::Concat(OUString::number(nCount)), 1);
        m_xTreeView2->set_id(nCount, OUString::number(nCount));
    }
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/uiconfig/ui/widgettestdialog.ui b/cui/uiconfig/ui/widgettestdialog.ui
index 787deda..4f4b3cf 100644
--- a/cui/uiconfig/ui/widgettestdialog.ui
+++ b/cui/uiconfig/ui/widgettestdialog.ui
@@ -8,11 +8,8 @@
    <property name="type-hint">dialog</property>
    <child internal-child="vbox">
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can-focus">False</property>
        <property name="orientation">vertical</property>
        <property name="spacing">5</property>
        <child internal-child="action_area">
      <property name="orientation">vertical</property>
      <child internal-child="action_area">
          <object class="GtkButtonBox">
            <property name="can-focus">False</property>
            <property name="layout-style">end</property>
@@ -46,9 +43,16 @@
          <packing>
            <property name="expand">False</property>
            <property name="fill">False</property>
            <property name="position">0</property>
            <property name="position">1</property>
          </packing>
        </child>
      <child>
      <!-- n-columns=2 n-rows=2 -->
      <object class="GtkGrid">
        <property name="visible">True</property>
        <property name="can-focus">False</property>
        <property name="row-spacing">5</property>
        <property name="column-spacing">5</property>
        <child>
          <!-- n-columns=2 n-rows=7 -->
          <object class="GtkGrid">
@@ -286,18 +290,8 @@
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkSeparator">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
            <property name="left-attach">0</property>
            <property name="top-attach">0</property>
          </packing>
        </child>
        <child>
@@ -455,11 +449,151 @@
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
            <property name="left-attach">0</property>
            <property name="top-attach">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="contentbox">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkScrolledWindow">
                <property name="visible">True</property>
                <property name="can-focus">True</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="shadow-type">in</property>
                <child>
                  <object class="GtkTreeView" id="contenttree">
                    <property name="width-request">-1</property>
                    <property name="visible">True</property>
                    <property name="can-focus">True</property>
                    <property name="receives-default">True</property>
                    <property name="has-tooltip">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="model">liststore2</property>
                    <property name="headers-visible">False</property>
                    <property name="reorderable">True</property>
                    <property name="search-column">1</property>
                    <property name="enable-tree-lines">True</property>
                    <child>
                      <object class="GtkTreeViewColumn" id="treeviewcolumn0">
                        <property name="spacing">6</property>
                        <child>
                          <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf0"/>
                          <attributes>
                            <attribute name="sensitive">4</attribute>
                            <attribute name="pixbuf">0</attribute>
                          </attributes>
                        </child>
                        <child>
                          <object class="GtkCellRendererText" id="cellrenderertext0">
                            <property name="xalign">0</property>
                          </object>
                          <attributes>
                            <attribute name="xpad">5</attribute>
                            <attribute name="sensitive">4</attribute>
                            <attribute name="text">1</attribute>
                          </attributes>
                        </child>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left-attach">1</property>
            <property name="top-attach">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkBox" id="contentbox2">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="hexpand">True</property>
            <property name="vexpand">True</property>
            <property name="orientation">vertical</property>
            <child>
              <object class="GtkScrolledWindow">
                <property name="visible">True</property>
                <property name="can-focus">True</property>
                <property name="hexpand">True</property>
                <property name="vexpand">True</property>
                <property name="shadow-type">in</property>
                <child>
                  <object class="GtkTreeView" id="contenttree2">
                    <property name="width-request">-1</property>
                    <property name="visible">True</property>
                    <property name="can-focus">True</property>
                    <property name="receives-default">True</property>
                    <property name="has-tooltip">True</property>
                    <property name="hexpand">True</property>
                    <property name="vexpand">True</property>
                    <property name="model">liststore3</property>
                    <property name="headers-visible">True</property>
                    <property name="reorderable">True</property>
                    <property name="search-column">1</property>
                    <property name="enable-tree-lines">True</property>
                    <child>
                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                        <property name="resizable">True</property>
                        <property name="spacing">6</property>
                        <property name="title" translatable="no">Column 1</property>
                        <child>
                          <object class="GtkCellRendererText" id="cellrenderer1"/>
                          <attributes>
                            <attribute name="text">0</attribute>
                          </attributes>
                        </child>
                      </object>
                    </child>
                    <child>
                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
                        <property name="resizable">True</property>
                        <property name="spacing">6</property>
                        <property name="title" translatable="no">Column 2</property>
                        <child>
                          <object class="GtkCellRendererText" id="cellrenderer2"/>
                          <attributes>
                            <attribute name="text">1</attribute>
                          </attributes>
                        </child>
                      </object>
                    </child>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="left-attach">1</property>
            <property name="top-attach">1</property>
          </packing>
        </child>
      </object>
    </child>
    </object>
    <packing>
      <property name="position">0</property>
    </packing>
    </child>
  </object>
  <object class="GtkTextBuffer" id="textbuffer1">
    <property name="text" translatable="no">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy tex
@@ -471,7 +605,7 @@ t ever since the 1500s, when an unknown printer took a galley of type and scramb
 Ipsum passages, and more recently with desktop publishing
 software like Aldus PageMaker including versions of Lorem Ipsum.</property>
  </object>
    <object class="GtkListStore" id="liststore1">
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name gchararray1 -->
      <column type="gchararray"/>
@@ -494,4 +628,30 @@ t ever since the 1500s, when an unknown printer took a galley of type and scramb
      </row>
    </data>
  </object>
  <object class="GtkTreeStore" id="liststore2">
    <columns>
      <!-- column-name expander -->
      <column type="GdkPixbuf"/>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
      <!-- column-name weight -->
      <column type="gint"/>
      <!-- column-name sensitive -->
      <column type="gboolean"/>
      <!-- column-name extraindent -->
      <column type="gint"/>
    </columns>
  </object>
    <object class="GtkTreeStore" id="liststore3">
    <columns>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name text1 -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
</interface>