vcl/CustomTarget_qt5_moc.mk        |    1 
 vcl/CustomTarget_qt6_moc.mk        |    1 
 vcl/Library_vclplug_qt5.mk         |    1 
 vcl/Library_vclplug_qt6.mk         |    1 
 vcl/inc/qt5/QtInstanceIconView.hxx |   10 +------
 vcl/inc/qt5/QtInstanceItemView.hxx |   39 ++++++++++++++++++++++++++++++
 vcl/inc/qt5/QtInstanceTreeView.hxx |    9 +------
 vcl/inc/qt6/QtInstanceItemView.hxx |   12 +++++++++
 vcl/inc/salvtables.hxx             |   23 +++++++++++-------
 vcl/qt5/QtInstanceIconView.cxx     |   47 +++++++++----------------------------
 vcl/qt5/QtInstanceItemView.cxx     |   43 +++++++++++++++++++++++++++++++++
 vcl/qt5/QtInstanceTreeView.cxx     |   29 ----------------------
 vcl/qt6/QtInstanceItemView.cxx     |   12 +++++++++
 vcl/source/app/salvtables.cxx      |   29 +++++++++++-----------
 14 files changed, 156 insertions(+), 101 deletions(-)

New commits:
commit fcf901230034575565209a563196c8e9c434176a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 17 15:24:33 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 07:20:38 2025 +0100

    vcl weld: Introduce SalInstanceItemView
    
    This is the implementation for the abstract
    weld::ItemView class introduced in
    
        commit 94aee0cd3d6cfc2bdc8375f9e1938a92c15eae1f
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Dec 17 12:14:41 2025 +0100
    
            weld: Introduce weld::ItemView as IconView/TreeView base
    
    Having an equivalent for the vcl-based weld implementation
    will allow sharing code between SalInstanceIconView
    and SalInstanceTreeView.
    
    In an initial step, move the m_aUserData member that both
    subclasses have to the base class and deduplicate the
    weld::ItemView::do_clear implementations by implementing the
    logic in the base class and dropping the equivalent overrides
    in both subclasses.
    
    Change-Id: I6f35e2cac1c2f1851590307699631c2b9598f9eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195797
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 17f2b67fa86e..c22a9b3cc7c5 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1482,11 +1482,23 @@ struct SalInstanceTreeIter final : public weld::TreeIter
     SvTreeListEntry* iter;
 };
 
-class SalInstanceTreeView : public SalInstanceWidget, public virtual 
weld::TreeView
+class SalInstanceItemView : public SalInstanceWidget, public virtual 
weld::ItemView
 {
+    VclPtr<SvTreeListBox> m_pTreeListBox;
+
 protected:
     // owner for UserData
     std::vector<std::unique_ptr<OUString>> m_aUserData;
+
+    SalInstanceItemView(SvTreeListBox* pTreeListBox, SalInstanceBuilder* 
pBuilder,
+                        bool bTakeOwnership);
+
+    virtual void do_clear() override;
+};
+
+class SalInstanceTreeView : public SalInstanceItemView, public virtual 
weld::TreeView
+{
+protected:
     VclPtr<SvTabListBox> m_xTreeView;
     SvLBoxButtonData m_aCheckButtonData;
     SvLBoxButtonData m_aRadioButtonData;
@@ -1610,8 +1622,6 @@ public:
 
     virtual void swap(int pos1, int pos2) override;
 
-    virtual void do_clear() override;
-
     virtual void select_all() override;
     virtual void unselect_all() override;
 
@@ -1882,7 +1892,7 @@ public:
     virtual ~SalInstanceExpander() override;
 };
 
-class SalInstanceIconView : public SalInstanceWidget, public virtual 
weld::IconView
+class SalInstanceIconView : public SalInstanceItemView, public virtual 
weld::IconView
 {
 protected:
     VclPtr<::IconView> m_xIconView;
@@ -1890,9 +1900,6 @@ protected:
 private:
     bool m_bFixedItemWidth = false;
 
-    // owner for UserData
-    std::vector<std::unique_ptr<OUString>> m_aUserData;
-
     DECL_LINK(SelectHdl, SvTreeListBox*, void);
     DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
     DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
@@ -1979,8 +1986,6 @@ public:
 
     virtual tools::Rectangle get_rect(int pos) const override;
 
-    virtual void do_clear() override;
-
     virtual ~SalInstanceIconView() override;
 };
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index bf1c815d4bbd..8b82e6d8af7e 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -3510,6 +3510,19 @@ public:
 };
 }
 
+SalInstanceItemView::SalInstanceItemView(SvTreeListBox* pTreeListBox, 
SalInstanceBuilder* pBuilder,
+                                         bool bTakeOwnership)
+    : SalInstanceWidget(pTreeListBox, pBuilder, bTakeOwnership)
+    , m_pTreeListBox(pTreeListBox)
+{
+}
+
+void SalInstanceItemView::do_clear()
+{
+    m_pTreeListBox->Clear();
+    m_aUserData.clear();
+}
+
 // Each row has a cell for the expander image, (and an optional cell for a
 // checkbutton if enable_toggle_buttons has been called) which precede
 // index 0
@@ -3738,7 +3751,7 @@ void SalInstanceTreeView::set_header_item_width(const 
std::vector<int>& rWidths)
 
 SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* pTreeView, 
SalInstanceBuilder* pBuilder,
                                          bool bTakeOwnership)
-    : SalInstanceWidget(pTreeView, pBuilder, bTakeOwnership)
+    : SalInstanceItemView(pTreeView, pBuilder, bTakeOwnership)
     , m_xTreeView(pTreeView)
     , m_aCheckButtonData(*pTreeView, false)
     , m_aRadioButtonData(*pTreeView, true)
@@ -4035,12 +4048,6 @@ void SalInstanceTreeView::swap(int pos1, int pos2)
     pModel->Move(pEntry1, pEntry2);
 }
 
-void SalInstanceTreeView::do_clear()
-{
-    m_xTreeView->Clear();
-    m_aUserData.clear();
-}
-
 void SalInstanceTreeView::select_all() { unselect(-1); }
 
 void SalInstanceTreeView::unselect_all() { select(-1); }
@@ -5252,7 +5259,7 @@ IMPL_LINK(SalInstanceTreeView, EditedEntryHdl, const 
IterString&, rIterString, b
 
 SalInstanceIconView::SalInstanceIconView(::IconView* pIconView, 
SalInstanceBuilder* pBuilder,
                                          bool bTakeOwnership)
-    : SalInstanceWidget(pIconView, pBuilder, bTakeOwnership)
+    : SalInstanceItemView(pIconView, pBuilder, bTakeOwnership)
     , m_xIconView(pIconView)
 {
     m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
@@ -5603,12 +5610,6 @@ tools::Rectangle SalInstanceIconView::get_rect(int pos) 
const
     return m_xIconView->GetBoundingRect(aEntry);
 }
 
-void SalInstanceIconView::do_clear()
-{
-    m_xIconView->Clear();
-    m_aUserData.clear();
-}
-
 SalInstanceIconView::~SalInstanceIconView()
 {
     m_xIconView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
commit 63b8d16d15b24a2a1c2583f2b175f90701f14e3a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 17 14:57:46 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 07:20:31 2025 +0100

    tdf#130857 qt weld: Deduplicate IconView/TreeView iter logic
    
    Now that
    
        Change-Id: I91edd89743afc5cfa53d3b8343a3a69ab0a0c51b
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Dec 17 14:28:38 2025 +0100
    
            tdf#130857 qt weld: Introduce QtInstanceItemView
    
    introduced a shared base class, move the QtInstanceTreeView
    logic to convert between position/index, model index and
    iterators to the new QtInstanceItemView base class.
    
    Reuse that existing logic in QtInstanceIconView as well,
    and drop the logic from there that is comparable, but
    only handles one dimension.
    (The implemenation in QtInstanceItemView uses a default
    column index of 0, which is fine.)
    
    Adjust QtInstanceIconView::get_id to follow the same
    logic as implemented in QtInstanceTreeView: In the variant
    called with an index, call the variant taking an iterator,
    not the other way around.
    
    Change-Id: I045a7ca336f68c1128605aadef63b0303839a02c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195796
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/inc/qt5/QtInstanceIconView.hxx 
b/vcl/inc/qt5/QtInstanceIconView.hxx
index 2ed4506c380d..8dbe5159d24a 100644
--- a/vcl/inc/qt5/QtInstanceIconView.hxx
+++ b/vcl/inc/qt5/QtInstanceIconView.hxx
@@ -80,10 +80,6 @@ private:
     void do_insert(int nPos, const OUString* pStr, const OUString* pId, const 
QPixmap* pIcon,
                    weld::TreeIter* pRet);
 
-    QModelIndex modelIndex(int nPos) const;
-    QModelIndex modelIndex(const weld::TreeIter& rIter) const;
-    static int position(const weld::TreeIter& rIter);
-
 private Q_SLOTS:
     void handleActivated();
     void handleSelectionChanged();
diff --git a/vcl/inc/qt5/QtInstanceItemView.hxx 
b/vcl/inc/qt5/QtInstanceItemView.hxx
index f238aa229ac5..2644762acbca 100644
--- a/vcl/inc/qt5/QtInstanceItemView.hxx
+++ b/vcl/inc/qt5/QtInstanceItemView.hxx
@@ -9,6 +9,7 @@
 
 #pragma once
 
+#include "QtInstanceTreeIter.hxx"
 #include "QtInstanceWidget.hxx"
 
 #include <vcl/weld/ItemView.hxx>
@@ -27,6 +28,12 @@ protected:
 
 public:
     QtInstanceItemView(QAbstractItemView* pItemView, QAbstractItemModel& 
rModel);
+
+protected:
+    QModelIndex modelIndex(int nRow, int nCol = 0,
+                           const QModelIndex& rParentIndex = QModelIndex()) 
const;
+    QModelIndex modelIndex(const weld::TreeIter& rIter, int nCol = 0) const;
+    QtInstanceTreeIter treeIter(int nRow, const QModelIndex& rParentIndex = 
QModelIndex()) const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx 
b/vcl/inc/qt5/QtInstanceTreeView.hxx
index d779eb8444ca..d0fcefbbc16f 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -213,10 +213,6 @@ public:
     virtual bool eventFilter(QObject* pObject, QEvent* pEvent) override;
 
 private:
-    QModelIndex modelIndex(int nRow, int nCol = 0,
-                           const QModelIndex& rParentIndex = QModelIndex()) 
const;
-    QModelIndex modelIndex(const weld::TreeIter& rIter, int nCol = 0) const;
-    QtInstanceTreeIter treeIter(int nRow, const QModelIndex& rParentIndex = 
QModelIndex()) const;
     QStandardItem* itemFromIndex(const QModelIndex& rIndex) const;
     QModelIndex toggleButtonModelIndex(const weld::TreeIter& rIter) const;
     QModelIndex firstTextColumnModelIndex(const weld::TreeIter& rIter) const;
diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx
index 02b63fee94dc..f8f617364a5e 100644
--- a/vcl/qt5/QtInstanceIconView.cxx
+++ b/vcl/qt5/QtInstanceIconView.cxx
@@ -131,19 +131,7 @@ OUString QtInstanceIconView::get_selected_text() const
     return OUString();
 }
 
-OUString QtInstanceIconView::get_id(int nPos) const
-{
-    SolarMutexGuard g;
-
-    OUString sId;
-    GetQtInstance().RunInMainThread([&] {
-        QVariant aRoleData = m_pModel->data(modelIndex(nPos), ROLE_ID);
-        if (aRoleData.canConvert<QString>())
-            sId = toOUString(aRoleData.toString());
-    });
-
-    return sId;
-}
+OUString QtInstanceIconView::get_id(int nPos) const { return 
get_id(treeIter(nPos)); }
 
 void QtInstanceIconView::do_select(int nPos)
 {
@@ -255,7 +243,16 @@ bool QtInstanceIconView::get_iter_first(weld::TreeIter&) 
const
 
 OUString QtInstanceIconView::get_id(const weld::TreeIter& rIter) const
 {
-    return get_id(position(rIter));
+    SolarMutexGuard g;
+
+    OUString sId;
+    GetQtInstance().RunInMainThread([&] {
+        QVariant aRoleData = m_pModel->data(modelIndex(rIter), ROLE_ID);
+        if (aRoleData.canConvert<QString>())
+            sId = toOUString(aRoleData.toString());
+    });
+
+    return sId;
 }
 
 OUString QtInstanceIconView::get_text(const weld::TreeIter& rIter) const
@@ -312,19 +309,6 @@ int QtInstanceIconView::n_children() const
     return nChildren;
 }
 
-QModelIndex QtInstanceIconView::modelIndex(int nPos) const { return 
m_pModel->index(nPos, 0); }
-
-QModelIndex QtInstanceIconView::modelIndex(const weld::TreeIter& rIter) const
-{
-    return modelIndex(position(rIter));
-}
-
-int QtInstanceIconView::position(const weld::TreeIter& rIter)
-{
-    QModelIndex aModelIndex = static_cast<const 
QtInstanceTreeIter&>(rIter).modelIndex();
-    return aModelIndex.row();
-}
-
 bool QtInstanceIconView::handleToolTipEvent(const QHelpEvent& rHelpEvent)
 {
     QModelIndex aIndex = m_pListView->indexAt(rHelpEvent.pos());
diff --git a/vcl/qt5/QtInstanceItemView.cxx b/vcl/qt5/QtInstanceItemView.cxx
index 873d6428a6dc..22bdc7d2f875 100644
--- a/vcl/qt5/QtInstanceItemView.cxx
+++ b/vcl/qt5/QtInstanceItemView.cxx
@@ -23,4 +23,21 @@ void QtInstanceItemView::do_clear()
     GetQtInstance().RunInMainThread([&] { m_rModel.removeRows(0, 
m_rModel.rowCount()); });
 }
 
+QModelIndex QtInstanceItemView::modelIndex(int nRow, int nCol,
+                                           const QModelIndex& rParentIndex) 
const
+{
+    return modelIndex(treeIter(nRow, rParentIndex), nCol);
+}
+
+QModelIndex QtInstanceItemView::modelIndex(const weld::TreeIter& rIter, int 
nCol) const
+{
+    QModelIndex aModelIndex = static_cast<const 
QtInstanceTreeIter&>(rIter).modelIndex();
+    return m_rModel.index(aModelIndex.row(), nCol, aModelIndex.parent());
+}
+
+QtInstanceTreeIter QtInstanceItemView::treeIter(int nRow, const QModelIndex& 
rParentIndex) const
+{
+    return QtInstanceTreeIter(m_rModel.index(nRow, 0, rParentIndex));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index a434157fcd4d..36ad49803d03 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -1103,23 +1103,6 @@ bool QtInstanceTreeView::eventFilter(QObject* pObject, 
QEvent* pEvent)
     return QtInstanceWidget::eventFilter(pObject, pEvent);
 }
 
-QModelIndex QtInstanceTreeView::modelIndex(int nRow, int nCol,
-                                           const QModelIndex& rParentIndex) 
const
-{
-    return modelIndex(treeIter(nRow, rParentIndex), nCol);
-}
-
-QModelIndex QtInstanceTreeView::modelIndex(const weld::TreeIter& rIter, int 
nCol) const
-{
-    QModelIndex aModelIndex = static_cast<const 
QtInstanceTreeIter&>(rIter).modelIndex();
-    return m_pModel->index(aModelIndex.row(), nCol, aModelIndex.parent());
-}
-
-QtInstanceTreeIter QtInstanceTreeView::treeIter(int nRow, const QModelIndex& 
rParentIndex) const
-{
-    return QtInstanceTreeIter(m_pModel->index(nRow, 0, rParentIndex));
-}
-
 QStandardItem* QtInstanceTreeView::itemFromIndex(const QModelIndex& rIndex) 
const
 {
     const QModelIndex aSourceIndex = m_pModel->mapToSource(rIndex);
commit 63b6ce5cbaa26bb13ec1cacf6398e2b7e2130752
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 17 14:28:38 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 07:20:24 2025 +0100

    tdf#130857 qt weld: Introduce QtInstanceItemView
    
    This is the implementation for the abstract
    weld::ItemView class introduced in
    
        commit 94aee0cd3d6cfc2bdc8375f9e1938a92c15eae1f
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Dec 17 12:14:41 2025 +0100
    
            weld: Introduce weld::ItemView as IconView/TreeView base
    
    Having an equivalent for the Qt-based weld implementation
    will allow sharing code between QtInstanceIconView
    and QtInstanceTreeView.
    
    In an initial step, deduplicate the weld::ItemView::do_clear
    implementations by moving the QtInstanceTreeView one to
    the new base class and dropping the implementations in the
    subclasses.
    
    Change-Id: I91edd89743afc5cfa53d3b8343a3a69ab0a0c51b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195795
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk
index 8a27acd7656e..918f1b6ca0f6 100644
--- a/vcl/CustomTarget_qt5_moc.mk
+++ b/vcl/CustomTarget_qt5_moc.mk
@@ -35,6 +35,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceGrid.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceIconView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceImage.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceItemView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLabel.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLinkButton.moc \
diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk
index 9402a72d6fce..c90468650892 100644
--- a/vcl/CustomTarget_qt6_moc.mk
+++ b/vcl/CustomTarget_qt6_moc.mk
@@ -35,6 +35,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceGrid.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceIconView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceImage.moc \
+       $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceItemView.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLabel.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \
        $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLinkButton.moc \
diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk
index 75f09754b893..954f497b0e97 100644
--- a/vcl/Library_vclplug_qt5.mk
+++ b/vcl/Library_vclplug_qt5.mk
@@ -118,6 +118,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
     vcl/qt5/QtInstanceGrid \
     vcl/qt5/QtInstanceIconView \
     vcl/qt5/QtInstanceImage \
+    vcl/qt5/QtInstanceItemView \
     vcl/qt5/QtInstanceLabel \
     vcl/qt5/QtInstanceLevelBar \
     vcl/qt5/QtInstanceLinkButton \
diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk
index 73b8856c30f6..8408d417c07e 100644
--- a/vcl/Library_vclplug_qt6.mk
+++ b/vcl/Library_vclplug_qt6.mk
@@ -117,6 +117,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
     vcl/qt6/QtInstanceGrid \
     vcl/qt6/QtInstanceIconView \
     vcl/qt6/QtInstanceImage \
+    vcl/qt6/QtInstanceItemView \
     vcl/qt6/QtInstanceLabel \
     vcl/qt6/QtInstanceLevelBar \
     vcl/qt6/QtInstanceLinkButton \
diff --git a/vcl/inc/qt5/QtInstanceIconView.hxx 
b/vcl/inc/qt5/QtInstanceIconView.hxx
index 6d527c9d99c6..2ed4506c380d 100644
--- a/vcl/inc/qt5/QtInstanceIconView.hxx
+++ b/vcl/inc/qt5/QtInstanceIconView.hxx
@@ -9,14 +9,14 @@
 
 #pragma once
 
-#include "QtInstanceWidget.hxx"
+#include "QtInstanceItemView.hxx"
 
 #include <vcl/weld/IconView.hxx>
 
 #include <QtGui/QStandardItemModel>
 #include <QtWidgets/QListView>
 
-class QtInstanceIconView : public QtInstanceWidget, public virtual 
weld::IconView
+class QtInstanceIconView : public QtInstanceItemView, public virtual 
weld::IconView
 {
     Q_OBJECT
 
@@ -40,8 +40,6 @@ public:
 
     virtual OUString get_selected_id() const override;
 
-    virtual void do_clear() override;
-
     virtual int count_selected_items() const override;
 
     virtual OUString get_selected_text() const override;
diff --git a/vcl/inc/qt5/QtInstanceItemView.hxx 
b/vcl/inc/qt5/QtInstanceItemView.hxx
new file mode 100644
index 000000000000..f238aa229ac5
--- /dev/null
+++ b/vcl/inc/qt5/QtInstanceItemView.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include "QtInstanceWidget.hxx"
+
+#include <vcl/weld/ItemView.hxx>
+
+#include <QtCore/QAbstractItemModel>
+#include <QtWidgets/QAbstractItemView>
+
+class QtInstanceItemView : public QtInstanceWidget, public virtual 
weld::ItemView
+{
+    Q_OBJECT
+
+    QAbstractItemModel& m_rModel;
+
+protected:
+    void do_clear() override;
+
+public:
+    QtInstanceItemView(QAbstractItemView* pItemView, QAbstractItemModel& 
rModel);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx 
b/vcl/inc/qt5/QtInstanceTreeView.hxx
index b9d314502363..d779eb8444ca 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -10,7 +10,7 @@
 #pragma once
 
 #include "QtInstanceTreeIter.hxx"
-#include "QtInstanceWidget.hxx"
+#include "QtInstanceItemView.hxx"
 
 #include <vcl/weld/TreeView.hxx>
 
@@ -18,7 +18,7 @@
 #include <QtGui/QStandardItemModel>
 #include <QtWidgets/QTreeView>
 
-class QtInstanceTreeView : public QtInstanceWidget, public virtual 
weld::TreeView
+class QtInstanceTreeView : public QtInstanceItemView, public virtual 
weld::TreeView
 {
     Q_OBJECT
 
@@ -173,7 +173,6 @@ public:
     virtual int get_sort_column() const override;
     virtual void set_sort_column(int nColumn) override;
 
-    virtual void do_clear() override;
     virtual int get_height_rows(int nRows) const override;
 
     virtual void columns_autosize() override;
diff --git a/vcl/inc/qt6/QtInstanceItemView.hxx 
b/vcl/inc/qt6/QtInstanceItemView.hxx
new file mode 100644
index 000000000000..cc74f226234a
--- /dev/null
+++ b/vcl/inc/qt6/QtInstanceItemView.hxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceItemView.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx
index 4a9d825f8a02..02b63fee94dc 100644
--- a/vcl/qt5/QtInstanceIconView.cxx
+++ b/vcl/qt5/QtInstanceIconView.cxx
@@ -21,7 +21,7 @@
 constexpr int ROLE_ID = Qt::UserRole + 1000;
 
 QtInstanceIconView::QtInstanceIconView(QListView* pListView)
-    : QtInstanceWidget(pListView)
+    : QtInstanceItemView(pListView, *pListView->model())
     , m_pListView(pListView)
 {
     assert(m_pListView);
@@ -119,13 +119,6 @@ OUString QtInstanceIconView::get_selected_id() const
     return sId;
 }
 
-void QtInstanceIconView::do_clear()
-{
-    SolarMutexGuard g;
-
-    GetQtInstance().RunInMainThread([&] { m_pModel->clear(); });
-}
-
 int QtInstanceIconView::count_selected_items() const
 {
     assert(false && "Not implemented yet");
diff --git a/vcl/qt5/QtInstanceItemView.cxx b/vcl/qt5/QtInstanceItemView.cxx
new file mode 100644
index 000000000000..873d6428a6dc
--- /dev/null
+++ b/vcl/qt5/QtInstanceItemView.cxx
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QtInstanceItemView.hxx>
+#include <QtInstanceItemView.moc>
+
+QtInstanceItemView::QtInstanceItemView(QAbstractItemView* pItemView, 
QAbstractItemModel& rModel)
+    : QtInstanceWidget(pItemView)
+    , m_rModel(rModel)
+{
+}
+
+void QtInstanceItemView::do_clear()
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] { m_rModel.removeRows(0, 
m_rModel.rowCount()); });
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 75cf1214a926..a434157fcd4d 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -22,7 +22,7 @@ constexpr int ROLE_ID = Qt::UserRole + 1000;
 const char* const PROPERTY_COLUMN_ROLES = "column-roles";
 
 QtInstanceTreeView::QtInstanceTreeView(QTreeView* pTreeView)
-    : QtInstanceWidget(pTreeView)
+    : QtInstanceItemView(pTreeView, *pTreeView->model())
     , m_pTreeView(pTreeView)
 {
     assert(m_pTreeView);
@@ -941,16 +941,6 @@ void QtInstanceTreeView::set_sort_column(int nColumn)
     GetQtInstance().RunInMainThread([&] { m_pModel->sort(nColumn); });
 }
 
-void QtInstanceTreeView::do_clear()
-{
-    SolarMutexGuard g;
-
-    GetQtInstance().RunInMainThread([&] {
-        // don't use QStandardItemModel::clear, as that would remove header 
data as well
-        m_pModel->removeRows(0, m_pModel->rowCount());
-    });
-}
-
 int QtInstanceTreeView::get_height_rows(int) const
 {
     SAL_WARN("vcl.qt", "QtInstanceTreeView::get_height_rows just returns 0 for 
now");
diff --git a/vcl/qt6/QtInstanceItemView.cxx b/vcl/qt6/QtInstanceItemView.cxx
new file mode 100644
index 000000000000..7d84437aa4d3
--- /dev/null
+++ b/vcl/qt6/QtInstanceItemView.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "../qt5/QtInstanceItemView.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to