cui/uiconfig/ui/pastespecial.ui    |   75 +++++++++++++++++--------------------
 include/vcl/builderbase.hxx        |    1 
 vcl/inc/qt5/QtInstanceTreeView.hxx |    2 
 vcl/qt5/QtBuilder.cxx              |    1 
 vcl/qt5/QtInstanceTreeView.cxx     |   27 +++++++++----
 vcl/source/window/builder.cxx      |   12 +++++
 6 files changed, 70 insertions(+), 48 deletions(-)

New commits:
commit f956faffdeab44fa59765c5c933198799164ef2b
Author:     Michael Weghorn <[email protected]>
AuthorDate: Sat Nov 30 00:34:32 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Nov 30 09:39:56 2024 +0100

    tdf#130857 qt weld: Implement setting tree view entry ID
    
    Use QStandardItem::setData with a custom role
    (ROLE_ID, with a value sufficiently larger than
    Qt::UserRole to avoid any accidental overlap, as
    e.g. QStandardItem::setData would use a default
    role of Qt::UserRole + 1) to set the ID.
    
    Implement QtInstanceTreeView::get_id
    to get the ID for the entry with a given index.
    
    Change-Id: If1c8cecac44fb3eb9ca2152abb05c3864240383a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177567
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx 
b/vcl/inc/qt5/QtInstanceTreeView.hxx
index 89959b08af7f..5c3fe21418a3 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -65,7 +65,7 @@ public:
     virtual void set_cursor(int pos) override;
 
     virtual int find_text(const OUString& rText) const override;
-    virtual OUString get_id(int pos) const override;
+    virtual OUString get_id(int nPos) const override;
     virtual int find_id(const OUString& rId) const override;
 
     virtual std::unique_ptr<weld::TreeIter> make_iterator(const 
weld::TreeIter* pOrig
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index e570e38a4537..7b008a1f8713 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -12,6 +12,9 @@
 
 #include <vcl/qt/QtUtils.hxx>
 
+// role used for the ID in the QStandardItem
+constexpr int ROLE_ID = Qt::UserRole + 1000;
+
 QtInstanceTreeView::QtInstanceTreeView(QTreeView* pTreeView)
     : QtInstanceWidget(pTreeView)
     , m_pTreeView(pTreeView)
@@ -32,7 +35,6 @@ void QtInstanceTreeView::insert(const weld::TreeIter* 
pParent, int pos, const OU
     // when needed to support more dialogs, then adjust/remove asserts below
     assert(!pParent && "Not implemented yet");
     assert(pos == -1 && "Not implemented yet");
-    assert(!pId && "Not implemented yet");
     assert(!pIconName && "Not implemented yet");
     assert(!pImageSurface && "Not implemented yet");
     assert(!bChildrenOnDemand && "Not implemented yet");
@@ -40,17 +42,18 @@ void QtInstanceTreeView::insert(const weld::TreeIter* 
pParent, int pos, const OU
     // avoid -Werror=unused-parameter for release build
     (void)pParent;
     (void)pos;
-    (void)pId;
     (void)pIconName;
     (void)pImageSurface;
     (void)bChildrenOnDemand;
     (void)pRet;
 
-    assert(pStr && "No string passed, which is currently the only 
supported/implemented case");
-
     SolarMutexGuard g;
     GetQtInstance().RunInMainThread([&] {
-        QStandardItem* pItem = new QStandardItem(toQString(*pStr));
+        QStandardItem* pItem = new QStandardItem;
+        if (pStr)
+            pItem->setText(toQString(*pStr));
+        if (pId)
+            pItem->setData(toQString(*pId), ROLE_ID);
         m_pModel->appendRow(pItem);
     });
 }
@@ -217,10 +220,18 @@ int QtInstanceTreeView::find_text(const OUString&) const
     return -1;
 }
 
-OUString QtInstanceTreeView::get_id(int) const
+OUString QtInstanceTreeView::get_id(int nPos) const
 {
-    assert(false && "Not implemented yet");
-    return OUString();
+    SolarMutexGuard g;
+
+    OUString sId;
+    GetQtInstance().RunInMainThread([&] {
+        QVariant aRoleData = m_pModel->data(m_pModel->index(0, nPos), ROLE_ID);
+        if (aRoleData.canConvert<QString>())
+            sId = toOUString(aRoleData.toString());
+    });
+
+    return sId;
 }
 
 int QtInstanceTreeView::find_id(const OUString&) const
commit 25c0fe3f495e7169cd1e74b35b6d5a4d8afdffd6
Author:     Michael Weghorn <[email protected]>
AuthorDate: Sat Nov 30 00:15:25 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Nov 30 09:39:49 2024 +0100

    cui: Resave pastespecial.ui with glade 3.40
    
    This is the "Paste Special" dialog that shows
    when pasting using Ctrl+Shift+V.
    
    Change-Id: I7a3166251111a4fd568ad8c395e4d4053ae1f868
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177566
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/cui/uiconfig/ui/pastespecial.ui b/cui/uiconfig/ui/pastespecial.ui
index 436e77f8db28..e0490663f636 100644
--- a/cui/uiconfig/ui/pastespecial.ui
+++ b/cui/uiconfig/ui/pastespecial.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="cui">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkTreeStore" id="liststore1">
@@ -11,30 +11,30 @@
     </columns>
   </object>
   <object class="GtkDialog" id="PasteSpecialDialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">6</property>
+    <property name="can-focus">False</property>
+    <property name="border-width">6</property>
     <property name="title" translatable="yes" 
context="pastespecial|PasteSpecialDialog">Paste Special</property>
     <property name="modal">True</property>
-    <property name="default_width">0</property>
-    <property name="default_height">0</property>
-    <property name="type_hint">dialog</property>
+    <property name="default-width">0</property>
+    <property name="default-height">0</property>
+    <property name="type-hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox3">
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area3">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
+            <property name="can-focus">False</property>
+            <property name="layout-style">end</property>
             <child>
               <object class="GtkButton" id="ok">
                 <property name="label" translatable="yes" 
context="stock">_OK</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="can-default">True</property>
+                <property name="has-default">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -47,8 +47,8 @@
               <object class="GtkButton" id="cancel">
                 <property name="label" translatable="yes" 
context="stock">_Cancel</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -61,8 +61,8 @@
               <object class="GtkButton" id="help">
                 <property name="label" translatable="yes" 
context="stock">_Help</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>
@@ -76,14 +76,14 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="pack_type">end</property>
+            <property name="pack-type">end</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
           <object class="GtkBox" id="box1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can-focus">False</property>
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
             <property name="orientation">vertical</property>
@@ -91,12 +91,12 @@
             <child>
               <object class="GtkBox" id="box2">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkLabel" id="label2">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes" 
context="pastespecial|label2">Source:</property>
                   </object>
                   <packing>
@@ -108,9 +108,9 @@
                 <child>
                   <object class="GtkLabel" id="source">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="wrap">True</property>
-                    <property name="max_width_chars">72</property>
+                    <property name="max-width-chars">72</property>
                     <child internal-child="accessible">
                       <object class="AtkObject" id="source-atkobject">
                         <property name="AtkObject::accessible-description" 
translatable="yes" context="pastespecial|extended_tip|source">Displays the 
source of the clipboard contents.</property>
@@ -133,30 +133,30 @@
             <child>
               <object class="GtkFrame" id="frame1">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can-focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
+                <property name="label-xalign">0</property>
+                <property name="shadow-type">none</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>
+                    <property name="can-focus">True</property>
                     <property name="margin-start">12</property>
                     <property name="margin-top">6</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="shadow-type">in</property>
                     <child>
                       <object class="GtkTreeView" id="list">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
+                        <property name="can-focus">True</property>
                         <property name="vexpand">True</property>
                         <property name="model">liststore1</property>
-                        <property name="headers_visible">False</property>
-                        <property name="headers_clickable">False</property>
-                        <property name="search_column">0</property>
-                        <property name="show_expanders">False</property>
+                        <property name="headers-visible">False</property>
+                        <property name="headers-clickable">False</property>
+                        <property name="search-column">0</property>
+                        <property name="show-expanders">False</property>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" 
id="treeview-selection1"/>
                         </child>
@@ -182,7 +182,7 @@
                 <child type="label">
                   <object class="GtkLabel" id="label1">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can-focus">False</property>
                     <property name="label" translatable="yes" 
context="pastespecial|label1">Selection</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
@@ -210,9 +210,6 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
-    <child type="titlebar">
-      <placeholder/>
-    </child>
     <child internal-child="accessible">
       <object class="AtkObject" id="PasteSpecialDialog-atkobject">
         <property name="AtkObject::accessible-description" translatable="yes" 
context="pastespecial|extended_tip|PasteSpecialDialog">Inserts the contents of 
the clipboard into the current file in a format that you can specify.</property>
commit 5073fc170e3b45a6b80a4dbf85aa5e24338177b4
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Nov 29 16:38:33 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Sat Nov 30 09:39:42 2024 +0100

    tdf#130857 qt weld: Evaluate GtkTreeView:show-expanders property
    
    Evaluate the GtkTreeView:show-expanders property [1]
    and set the QTreeView::rootIsDecorated propert accordingly [2]:
    
    > This property holds whether to show controls for expanding and
    > collapsing top-level items
    >
    > Items with children are typically shown with controls to expand and
    > collapse them, allowing their children to be shown or hidden. If this
    > property is false, these controls are not shown for top-level items.
    > This can be used to make a single level tree structure appear like a
    > simple list of items.
    
    With this in place, there are no more expanders shown for
    Calc's "Sheets" -> "Show Sheet" dialog for the native Qt
    version, just like with the gtk3 or gen versions.
    
    [1] https://docs.gtk.org/gtk3/property.TreeView.show-expanders.html
    [2] https://doc.qt.io/qt-6/qtreeview.html#rootIsDecorated-prop
    
    Change-Id: I11bcdd39695d230866abddf6d4b305dd6af52f59
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177548
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/vcl/builderbase.hxx b/include/vcl/builderbase.hxx
index 1845d2d90cc3..04b534b92a4e 100644
--- a/include/vcl/builderbase.hxx
+++ b/include/vcl/builderbase.hxx
@@ -87,6 +87,7 @@ protected:
     static bool extractHeadersVisible(stringmap& rMap);
     static bool extractEntry(stringmap& rMap);
     static OUString extractIconName(stringmap& rMap);
+    static bool extractShowExpanders(stringmap& rMap);
     static OUString extractTooltipText(stringmap& rMap);
     static bool extractVisible(stringmap& rMap);
     void extractClassAndIdAndCustomProperty(xmlreader::XmlReader& reader, 
OUString& rClass,
diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 7a4269a9ec10..89c8a36d2573 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -291,6 +291,7 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, std:
         QTreeView* pTreeView = new QTreeView(pParentWidget);
         pTreeView->setModel(new QStandardItemModel(pTreeView));
         pTreeView->setHeaderHidden(!extractHeadersVisible(rMap));
+        pTreeView->setRootIsDecorated(extractShowExpanders(rMap));
         pObject = pTreeView;
     }
     else if (sName == u"GtkTreeViewColumn")
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 6cdce48f5cbd..e638eaa21854 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -3535,6 +3535,18 @@ bool BuilderBase::extractResizable(stringmap& rMap)
     return bResizable;
 }
 
+bool BuilderBase::extractShowExpanders(VclBuilder::stringmap& rMap)
+{
+    bool bShowExpanders = true;
+    VclBuilder::stringmap::iterator aFind = rMap.find(u"show-expanders"_ustr);
+    if (aFind != rMap.end())
+    {
+        bShowExpanders = toBool(aFind->second);
+        rMap.erase(aFind);
+    }
+    return bShowExpanders;
+}
+
 OUString BuilderBase::extractTooltipText(stringmap& rMap)
 {
     OUString sTooltipText;

Reply via email to