include/vcl/weld/IconView.hxx |    8 --------
 include/vcl/weld/ItemView.hxx |    5 +++++
 include/vcl/weld/TreeView.hxx |    8 --------
 vcl/Library_vcl.mk            |    1 +
 vcl/source/weld/ItemView.cxx  |   22 ++++++++++++++++++++++
 5 files changed, 28 insertions(+), 16 deletions(-)

New commits:
commit 538377c0afe4be36134326d15aeb041854efd2a2
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 17 12:40:40 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Dec 17 18:20:54 2025 +0100

    weld: Move clear logic to weld::ItemView base
    
    weld::TreeView::clear and weld::IconView::clear
    have the same logic. Deduplicate that by moving
    it to the new weld::ItemView base class introduced
    in previous commit
    
        Change-Id: Id8d243712bedf8dd42c2d9d909dc43e335689e34
        Author: Michael Weghorn <[email protected]>
        Date:   Wed Dec 17 12:14:41 2025 +0100
    
            weld: Introduce weld::ItemView as IconView/TreeView base
    
    Change-Id: I434a35c3a070163a690fe98464c3aee558b29356
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195786
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/weld/IconView.hxx b/include/vcl/weld/IconView.hxx
index 73c8eecfc15e..41cf3667f2a5 100644
--- a/include/vcl/weld/IconView.hxx
+++ b/include/vcl/weld/IconView.hxx
@@ -58,7 +58,6 @@ protected:
         = 0;
     virtual void do_select(int pos) = 0;
     virtual void do_unselect(int pos) = 0;
-    virtual void do_clear() = 0;
     virtual void do_remove(int pos) = 0;
     virtual void do_set_cursor(const TreeIter& rIter) = 0;
     virtual void do_scroll_to_item(const TreeIter& rIter) = 0;
@@ -123,13 +122,6 @@ public:
 
     virtual OUString get_selected_id() const = 0;
 
-    void clear()
-    {
-        disable_notify_events();
-        do_clear();
-        enable_notify_events();
-    }
-
     virtual int count_selected_items() const = 0;
 
     virtual OUString get_selected_text() const = 0;
diff --git a/include/vcl/weld/ItemView.hxx b/include/vcl/weld/ItemView.hxx
index 4d0445f108ac..5366bf1007a7 100644
--- a/include/vcl/weld/ItemView.hxx
+++ b/include/vcl/weld/ItemView.hxx
@@ -17,10 +17,15 @@ namespace weld
 /* Abstract base class for TreeView and IconView. */
 class VCL_DLLPUBLIC ItemView : virtual public Widget
 {
+protected:
+    virtual void do_clear() = 0;
+
 public:
     virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = 
nullptr) const = 0;
     virtual bool get_selected(TreeIter* pIter) const = 0;
     virtual bool get_cursor(TreeIter* pIter) const = 0;
+
+    void clear();
 };
 }
 
diff --git a/include/vcl/weld/TreeView.hxx b/include/vcl/weld/TreeView.hxx
index 441af2149b0f..a30f9080eae7 100644
--- a/include/vcl/weld/TreeView.hxx
+++ b/include/vcl/weld/TreeView.hxx
@@ -143,7 +143,6 @@ protected:
     virtual void do_unselect(const TreeIter& rIter) = 0;
     virtual void do_scroll_to_row(const TreeIter& rIter) = 0;
     virtual void do_set_children_on_demand(const TreeIter& rIter, bool 
bChildrenOnDemand) = 0;
-    virtual void do_clear() = 0;
     virtual void do_remove_selection() = 0;
 
 public:
@@ -558,13 +557,6 @@ public:
         m_aCustomSort = func;
     }
 
-    void clear()
-    {
-        disable_notify_events();
-        do_clear();
-        enable_notify_events();
-    }
-
     virtual int get_height_rows(int nRows) const = 0;
 
     virtual void columns_autosize() = 0;
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 60283b1fb23e..df79327f38cc 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -582,6 +582,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/uitest/uitest \
     vcl/source/uitest/uno/uiobject_uno \
     vcl/source/uitest/uno/uitest_uno \
+    vcl/source/weld/ItemView \
     vcl/source/weld/weldutils \
     vcl/backendtest/outputdevice/bitmap \
     vcl/backendtest/outputdevice/clip \
diff --git a/vcl/source/weld/ItemView.cxx b/vcl/source/weld/ItemView.cxx
new file mode 100644
index 000000000000..c8628f9b093c
--- /dev/null
+++ b/vcl/source/weld/ItemView.cxx
@@ -0,0 +1,22 @@
+/* -*- 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 <vcl/weld/ItemView.hxx>
+
+namespace weld
+{
+void ItemView::clear()
+{
+    disable_notify_events();
+    do_clear();
+    enable_notify_events();
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */

Reply via email to