vcl/inc/qt5/QtInstanceTreeView.hxx |    2 +-
 vcl/qt5/QtInstanceBuilder.cxx      |    1 +
 vcl/qt5/QtInstanceTreeView.cxx     |   29 ++++++++++++++++++++++++++---
 3 files changed, 28 insertions(+), 4 deletions(-)

New commits:
commit 35babbeeaeb1f7cda73f19f0c1e6e3549f59a19c
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Apr 1 13:08:46 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 1 16:28:05 2025 +0200

    tdf#130857 qt weld: Support "Tab Order" dialog for form controls
    
    This means that native Qt widgets are used for that dialog
    now when using the qt5 or qt6 VCL plugin and starting LO with
    environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set.
    
    The dialog can e.g. be triggered like this:
    
    * start Writer
    * ensure "Form" -> "Design Mode" is enabled
    * select "Form" -> "Check Box"
    * insert multiple check boxes into the document
    * "Form" -> "Activation Order"
    
    Change-Id: I2f9593b92ca13c097435785cd13245795ec07cbf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183587
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 443eb851b87f..9df7422e4b67 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -102,6 +102,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& 
rUIFile)
         u"modules/smath/ui/fontsizedialog.ui"_ustr,
         u"modules/smath/ui/savedefaultsdialog.ui"_ustr,
         u"modules/smath/ui/smathsettings.ui"_ustr,
+        u"modules/spropctrlr/ui/taborder.ui"_ustr,
         u"modules/swriter/ui/authenticationsettingsdialog.ui"_ustr,
         u"modules/swriter/ui/columnwidth.ui"_ustr,
         u"modules/swriter/ui/endnotepage.ui"_ustr,
commit fdad3dd5a9c5e524233c497af01ebb16cf32136e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Apr 1 12:41:50 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 1 16:28:00 2025 +0200

    tdf#130857 qt weld: Implement QtInstanceTreeView::swap
    
    Check whether any of the rows to be swapped
    are selected before removing/reinserting them,
    and restore that selection again in that case.
    
    This method is used by the "Form" -> "Activation Order"
    dialog in Writer, for which support will be declared
    in an upcoming commit.
    
    Change-Id: If94a6bb2758d4a0f08574db76b963047cfe7c128
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183586
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx 
b/vcl/inc/qt5/QtInstanceTreeView.hxx
index ef6fa68c5059..86c64a606d10 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -59,7 +59,7 @@ public:
     virtual void set_text_emphasis(int row, bool bOn, int col) override;
     virtual bool get_text_emphasis(int row, int col) const override;
     virtual void set_text_align(int row, double fAlign, int col) override;
-    virtual void swap(int pos1, int pos2) override;
+    virtual void swap(int nPos1, int nPos2) override;
     virtual std::vector<int> get_selected_rows() const override;
     virtual void set_font_color(int pos, const Color& rColor) override;
     virtual void scroll_to_row(int nRow) override;
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 1caffe289992..a209be729990 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -325,7 +325,28 @@ void QtInstanceTreeView::set_text_align(int, double, int)
     assert(false && "Not implemented yet");
 }
 
-void QtInstanceTreeView::swap(int, int) { assert(false && "Not implemented 
yet"); }
+void QtInstanceTreeView::swap(int nPos1, int nPos2)
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        const bool bPos1Selected = m_pSelectionModel->isRowSelected(nPos1);
+        const bool bPos2Selected = m_pSelectionModel->isRowSelected(nPos2);
+
+        const int nMin = std::min(nPos1, nPos2);
+        const int nMax = std::max(nPos2, nPos2);
+        QList<QStandardItem*> aMaxRow = m_pModel->takeRow(nMax);
+        QList<QStandardItem*> aMinRow = m_pModel->takeRow(nMin);
+        m_pModel->insertRow(nMin, aMaxRow);
+        m_pModel->insertRow(nMax, aMinRow);
+
+        // restore selection
+        if (bPos1Selected)
+            select(nPos2);
+        if (bPos2Selected)
+            select(nPos1);
+    });
+}
 
 std::vector<int> QtInstanceTreeView::get_selected_rows() const
 {
commit b08ff27d8a5f5801cf7531b0f0630cfb2f84d028
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Apr 1 12:34:52 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 1 16:27:55 2025 +0200

    tdf#130857 qt weld: Select whole tree view row
    
    weld::TreeView::select only takes a row number.
    Select the whole row, not just the first cell
    in that row.
    
    This e.g. makes a difference when using the
    "Move Up" button in the "Form" -> "Activation Order"
    dialog once support for that dialog is declared
    (which will happen in an upcoming commit).
    
    Change-Id: Ib5d2ce5de02f2d4e552e28163ed978176be466ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183585
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index 56d4be60210a..1caffe289992 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -148,8 +148,10 @@ int QtInstanceTreeView::get_selected_index() const
 void QtInstanceTreeView::select(int nPos)
 {
     SolarMutexGuard g;
-    GetQtInstance().RunInMainThread(
-        [&] { m_pSelectionModel->select(modelIndex(nPos), 
QItemSelectionModel::Select); });
+    GetQtInstance().RunInMainThread([&] {
+        m_pSelectionModel->select(modelIndex(nPos),
+                                  QItemSelectionModel::Select | 
QItemSelectionModel::Rows);
+    });
 }
 
 void QtInstanceTreeView::unselect(int nPos)

Reply via email to