vcl/inc/qt5/QtInstanceIconView.hxx | 3 +++ vcl/qt5/QtInstanceIconView.cxx | 35 +++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-)
New commits: commit eea7902e922201a5035298e0b071324a2ea1d3da Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Aug 1 17:08:32 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Aug 2 09:17:10 2025 +0200 tdf#130857 qt weld: Implement missing QtInstanceIconView::insert Implement the variant that takes an icon name param. This will be needed e.g. for the "File" -> "Open Remote" dialog. Change-Id: I2cc5d440035e49d9f7bd5d242528a681b4e71a32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188780 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx index 15414a925915..119aa47561c5 100644 --- a/vcl/qt5/QtInstanceIconView.cxx +++ b/vcl/qt5/QtInstanceIconView.cxx @@ -77,10 +77,15 @@ void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* }); } -void QtInstanceIconView::insert(int, const OUString*, const OUString*, const OUString*, - weld::TreeIter*) +void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, weld::TreeIter* pRet) { - assert(false && "Not implemented yet"); + std::optional<QPixmap> oPixmap; + if (pIconName) + oPixmap = loadQPixmapIcon(*pIconName); + + const QPixmap* pPixmapIcon = oPixmap.has_value() ? &oPixmap.value() : nullptr; + insert(nPos, pStr, pId, pPixmapIcon, pRet); } void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* pId, commit 82a0fed842324af53f44939a03dae952924201c6 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Aug 1 17:05:28 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Aug 2 09:17:03 2025 +0200 tdf#130857 qt weld: Extract QtInstanceIconView::insert helper Extract most of the logic from the already implemented QtInstanceIconView::insert variant, but take a QPixmap* param. This will allow reusing the logic when implementing the other QtInstanceIconView::insert variant in an upcoming commit. Change-Id: Ic0619a57b44c8756fc2b4867ced62d7b58af2fbd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188779 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtInstanceIconView.hxx b/vcl/inc/qt5/QtInstanceIconView.hxx index 0422442e665d..58343de025dc 100644 --- a/vcl/inc/qt5/QtInstanceIconView.hxx +++ b/vcl/inc/qt5/QtInstanceIconView.hxx @@ -75,6 +75,9 @@ public: virtual bool eventFilter(QObject* pObject, QEvent* pEvent) override; private: + void 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); diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx index 28bd78360cf8..15414a925915 100644 --- a/vcl/qt5/QtInstanceIconView.cxx +++ b/vcl/qt5/QtInstanceIconView.cxx @@ -48,14 +48,8 @@ int QtInstanceIconView::get_item_width() const void QtInstanceIconView::set_item_width(int) { assert(false && "Not implemented yet"); } -void QtInstanceIconView::insert(int, const OUString*, const OUString*, const OUString*, - weld::TreeIter*) -{ - assert(false && "Not implemented yet"); -} - void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* pId, - const Bitmap* pIcon, weld::TreeIter* pRet) + const QPixmap* pIcon, weld::TreeIter* pRet) { assert(!pRet && "Support for pRet param not implemented yet"); (void)pRet; @@ -73,10 +67,9 @@ void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* pItem->setData(toQString(*pId), ROLE_ID); if (pIcon) { - pItem->setIcon(QIcon(toQPixmap(BitmapEx(*pIcon)))); + pItem->setIcon(QIcon(*pIcon)); // set list view icon size to avoid downscaling - const QSize aIconSize - = m_pListView->iconSize().expandedTo(toQSize(pIcon->GetSizePixel())); + const QSize aIconSize = m_pListView->iconSize().expandedTo(pIcon->size()); m_pListView->setIconSize(aIconSize); } @@ -84,6 +77,23 @@ void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* }); } +void QtInstanceIconView::insert(int, const OUString*, const OUString*, const OUString*, + weld::TreeIter*) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceIconView::insert(int nPos, const OUString* pStr, const OUString* pId, + const Bitmap* pIcon, weld::TreeIter* pRet) +{ + std::optional<QPixmap> oPixmap; + if (pIcon) + oPixmap = toQPixmap(BitmapEx(*pIcon)); + + const QPixmap* pPixmapIcon = oPixmap.has_value() ? &oPixmap.value() : nullptr; + insert(nPos, pStr, pId, pPixmapIcon, pRet); +} + void QtInstanceIconView::insert_separator(int, const OUString*) { assert(false && "Not implemented yet");