From aefb11e0b27b13e03dfc90e2bd620168a234c996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDeljan=20Rikalo?= Date: Tue, 19 Nov 2024 19:28:11 +0000 Subject: [PATCH] Qt5, Qt6: Fixed bug with TListView.LargeImages and vsIcon style. issue #39511 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 4dc3c406966376a10bb132b01d0ad083f4420f06) Co-authored-by: Željan Rikalo --- lcl/interfaces/qt5/qtwscomctrls.pp | 14 ++++++++++++++ lcl/interfaces/qt6/qtwscomctrls.pp | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lcl/interfaces/qt5/qtwscomctrls.pp b/lcl/interfaces/qt5/qtwscomctrls.pp index 56e31dbd54..5bdcb3b2e7 100644 --- a/lcl/interfaces/qt5/qtwscomctrls.pp +++ b/lcl/interfaces/qt5/qtwscomctrls.pp @@ -1582,6 +1582,8 @@ var TWI: QTreeWidgetItemH; Str: WideString; AAlignment: QtAlignment; + ABmp: TBitmap; + AListItem: QListWidgetItemH; begin if not WSCheckHandleAllocated(ALV, 'ItemSetText') then Exit; @@ -1597,6 +1599,18 @@ begin if (TCustomListViewHack(ALV).Columns.Count > 0) and (ASubIndex < TCustomListViewHack(ALV).Columns.Count) then AAlignment := AlignmentToQtAlignmentMap[ALV.Column[ASubIndex].Alignment]; QtListWidget.setItemText(AIndex, AText, AAlignment); + if (TCustomListViewHack(ALV).ViewStyle = vsIcon) and (AItem.ImageIndex < 0) and + Assigned(TListView(ALV).LargeImages) then + begin + ABmp := TBitmap.Create; + ABmp.PixelFormat := pf32bit; + ABmp.SetSize(TListView(ALV).LargeImages.Width, TListView(ALV).LargeImages.Height); + ABmp.Canvas.Brush.Color := clNone; + ABmp.Canvas.FillRect(Rect(0, 0, ABmp.Width, ABmp.Height)); + AListItem := QtListWidget.getItem(AIndex); + QListWidgetItem_setIcon(AListItem, TQtImage(ABmp.Handle).AsIcon); + ABmp.Free; + end; end else begin QtTreeWidget := TQtTreeWidget(ALV.Handle); diff --git a/lcl/interfaces/qt6/qtwscomctrls.pp b/lcl/interfaces/qt6/qtwscomctrls.pp index 802b298352..ed068b053f 100644 --- a/lcl/interfaces/qt6/qtwscomctrls.pp +++ b/lcl/interfaces/qt6/qtwscomctrls.pp @@ -1579,6 +1579,8 @@ var TWI: QTreeWidgetItemH; Str: WideString; AAlignment: QtAlignment; + ABmp: TBitmap; + AListItem: QListWidgetItemH; begin if not WSCheckHandleAllocated(ALV, 'ItemSetText') then Exit; @@ -1594,6 +1596,18 @@ begin if (TCustomListViewHack(ALV).Columns.Count > 0) and (ASubIndex < TCustomListViewHack(ALV).Columns.Count) then AAlignment := AlignmentToQtAlignmentMap[ALV.Column[ASubIndex].Alignment]; QtListWidget.setItemText(AIndex, AText, AAlignment); + if (TCustomListViewHack(ALV).ViewStyle = vsIcon) and (AItem.ImageIndex < 0) and + Assigned(TListView(ALV).LargeImages) then + begin + ABmp := TBitmap.Create; + ABmp.PixelFormat := pf32bit; + ABmp.SetSize(TListView(ALV).LargeImages.Width, TListView(ALV).LargeImages.Height); + ABmp.Canvas.Brush.Color := clNone; + ABmp.Canvas.FillRect(Rect(0, 0, ABmp.Width, ABmp.Height)); + AListItem := QtListWidget.getItem(AIndex); + QListWidgetItem_setIcon(AListItem, TQtImage(ABmp.Handle).AsIcon); + ABmp.Free; + end; end else begin QtTreeWidget := TQtTreeWidget(ALV.Handle);