vcl/Library_vclplug_qt5.mk | 1 + vcl/Library_vclplug_qt6.mk | 1 + vcl/inc/qt5/QtInstanceTreeIter.hxx | 23 +++++++++++++++++++++++ vcl/inc/qt6/QtInstanceTreeIter.hxx | 12 ++++++++++++ vcl/qt5/QtInstanceTreeIter.cxx | 22 ++++++++++++++++++++++ vcl/qt5/QtInstanceTreeView.cxx | 37 ++++++++++++------------------------- vcl/qt6/QtInstanceTreeIter.cxx | 12 ++++++++++++ 7 files changed, 83 insertions(+), 25 deletions(-)
New commits: commit 4a25132b4a3199a294302405f2e568c27b699a6c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Feb 13 10:40:42 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 13 19:43:35 2025 +0100 tdf#130857 qt weld: Move QtInstanceTreeIter to own header/source Move QtInstanceTreeIter from vcl/qt5/QtInstanceTreeView.cxx to its own header and source files, so it can be reused in QtInstanceIconView in upcoming commits. Change-Id: If5bc4de8e2f02f859d3f8954e3503a670d5bd060 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181608 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index 9b70d16ca1b2..31b8f75076fa 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -129,6 +129,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtInstanceTextView \ vcl/qt5/QtInstanceToggleButton \ vcl/qt5/QtInstanceToolbar \ + vcl/qt5/QtInstanceTreeIter \ vcl/qt5/QtInstanceTreeView \ vcl/qt5/QtInstanceWidget \ vcl/qt5/QtInstanceWindow \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 21d7134b6a48..09208e7c36af 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -128,6 +128,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtInstanceTextView \ vcl/qt6/QtInstanceToggleButton \ vcl/qt6/QtInstanceToolbar \ + vcl/qt6/QtInstanceTreeIter \ vcl/qt6/QtInstanceTreeView \ vcl/qt6/QtInstanceWidget \ vcl/qt6/QtInstanceWindow \ diff --git a/vcl/inc/qt5/QtInstanceTreeIter.hxx b/vcl/inc/qt5/QtInstanceTreeIter.hxx new file mode 100644 index 000000000000..c91a3e41f499 --- /dev/null +++ b/vcl/inc/qt5/QtInstanceTreeIter.hxx @@ -0,0 +1,23 @@ +/* -*- 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 <QtGui/QStandardItemModel> +#include <vcl/weld.hxx> + +struct QtInstanceTreeIter final : public weld::TreeIter +{ + QModelIndex m_aModelIndex; + + explicit QtInstanceTreeIter(QModelIndex aModelIndex); + virtual bool equal(const TreeIter& rOther) const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt6/QtInstanceTreeIter.hxx b/vcl/inc/qt6/QtInstanceTreeIter.hxx new file mode 100644 index 000000000000..be8b9e7e2c1a --- /dev/null +++ b/vcl/inc/qt6/QtInstanceTreeIter.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/QtInstanceTreeIter.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtInstanceTreeIter.cxx b/vcl/qt5/QtInstanceTreeIter.cxx new file mode 100644 index 000000000000..06634efaab6f --- /dev/null +++ b/vcl/qt5/QtInstanceTreeIter.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 <QtInstanceTreeIter.hxx> + +QtInstanceTreeIter::QtInstanceTreeIter(QModelIndex aModelIndex) + : m_aModelIndex(aModelIndex) +{ +} + +bool QtInstanceTreeIter::equal(const TreeIter& rOther) const +{ + return m_aModelIndex == static_cast<const QtInstanceTreeIter&>(rOther).m_aModelIndex; +} + +/* 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 32e16ca33365..857e63455ab3 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -10,29 +10,13 @@ #include <QtInstanceTreeView.hxx> #include <QtInstanceTreeView.moc> +#include <QtInstanceTreeIter.hxx> + #include <vcl/qt/QtUtils.hxx> // role used for the ID in the QStandardItem constexpr int ROLE_ID = Qt::UserRole + 1000; -namespace -{ -struct QtInstanceTreeIter final : public weld::TreeIter -{ - QModelIndex m_aModelIndex; - - explicit QtInstanceTreeIter(QModelIndex aModelIndex) - : m_aModelIndex(aModelIndex) - { - } - - virtual bool equal(const TreeIter& rOther) const override - { - return m_aModelIndex == static_cast<const QtInstanceTreeIter&>(rOther).m_aModelIndex; - } -}; -}; - QtInstanceTreeView::QtInstanceTreeView(QTreeView* pTreeView) : QtInstanceWidget(pTreeView) , m_pTreeView(pTreeView) diff --git a/vcl/qt6/QtInstanceTreeIter.cxx b/vcl/qt6/QtInstanceTreeIter.cxx new file mode 100644 index 000000000000..daa6695d2ffd --- /dev/null +++ b/vcl/qt6/QtInstanceTreeIter.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/QtInstanceTreeIter.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ commit c8f1f72cf5e60540526fa3f8352ff4f3f04611ae Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Feb 13 09:44:30 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 13 19:43:21 2025 +0100 tdf#130857 qt weld: Implement QtInstanceTreeView::set_id(int,...) Change-Id: I6747877b475eedb9ee380edc26a72fb63bfb3eaf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181546 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx index 6efb57998898..32e16ca33365 100644 --- a/vcl/qt5/QtInstanceTreeView.cxx +++ b/vcl/qt5/QtInstanceTreeView.cxx @@ -207,7 +207,15 @@ bool QtInstanceTreeView::get_sensitive(int, int) const return false; } -void QtInstanceTreeView::set_id(int, const OUString&) { assert(false && "Not implemented yet"); } +void QtInstanceTreeView::set_id(int nRow, const OUString& rId) +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + QModelIndex aIndex = modelIndex(nRow); + m_pModel->setData(aIndex, toQString(rId), ROLE_ID); + }); +} void QtInstanceTreeView::set_toggle(int, TriState, int) { assert(false && "Not implemented yet"); } @@ -554,12 +562,7 @@ OUString QtInstanceTreeView::get_text(const weld::TreeIter&, int) const void QtInstanceTreeView::set_id(const weld::TreeIter& rIter, const OUString& rId) { - SolarMutexGuard g; - - GetQtInstance().RunInMainThread([&] { - QModelIndex aIndex = modelIndex(rIter); - m_pModel->setData(aIndex, toQString(rId), ROLE_ID); - }); + set_id(rowIndex(rIter), rId); } OUString QtInstanceTreeView::get_id(const weld::TreeIter& rIter) const