From eaf152e0d7967a334ab972073dcedb4c5f5c88f5 Mon Sep 17 00:00:00 2001 From: zeljko Date: Fri, 20 Feb 2015 19:18:16 +0000 Subject: [PATCH] Qt: fixed getting displaysize of TListView.Item drIcon. part of issue #27509 git-svn-id: trunk@47923 - --- lcl/interfaces/qt/qtwscomctrls.pp | 35 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lcl/interfaces/qt/qtwscomctrls.pp b/lcl/interfaces/qt/qtwscomctrls.pp index 3e0a8d9a0a..17ed6e99ad 100644 --- a/lcl/interfaces/qt/qtwscomctrls.pp +++ b/lcl/interfaces/qt/qtwscomctrls.pp @@ -1607,16 +1607,33 @@ begin if ACode in [drIcon] then begin AIcon := QIcon_create(); - QTreeWidgetItem_icon(TWI, AIcon, 0); - if not QIcon_isNull(AIcon) then - begin - Size.cx := 0; - Size.cy := 0; - QIcon_actualSize(AIcon, @Size, @Size); - Result.Right := Result.Left + Size.cx; - Result.Bottom := Result.Top + Size.cy; + try + QTreeWidgetItem_icon(TWI, AIcon, 0); + if not QIcon_isNull(AIcon) then + begin + Size.cx := 0; + Size.cy := 0; + QIcon_actualSize(AIcon, @Size, @Size); + if (Size.cx = 0) or (Size.cy = 0) then + begin + if Assigned(TCustomListViewHack(ALV).SmallImages) then + Result.Right := Result.Left + TCustomListViewHack(ALV).SmallImages.Width; + end else + begin + Result.Right := Result.Left + Size.cx; + Result.Bottom := Result.Top + Size.cy; + end; + end else + begin + if QtTreeWidget.OwnerData then + begin + if Assigned(TCustomListViewHack(ALV).SmallImages) then + Result.Right := Result.Left + TCustomListViewHack(ALV).SmallImages.Width; + end; + end; + finally + QIcon_destroy(AIcon); end; - QIcon_destroy(AIcon); end; end; end;