mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 13:40:23 +02:00
Merged revision(s) 47906-47907 #e15144d7eb-#e15144d7eb, 47923 #eaf152e0d7, 47939 #d2f2c0b358, 47942 #279f0f5ba5, 47946 #90e075c93b from trunk:
Qt: fixed TListView.OnData when we use TQtListWidget (vsList) ........ Qt: fixed selection behaviour of TListView.vsList when OwnerData = true. ........ Qt: fixed getting displaysize of TListView.Item drIcon. part of issue #27509 ........ Qt: do not send resize event on restore of minimized mdichild form. issue #27518 ........ Qt: fixed TListItem DisplayRect for drLabel & drIcon. part of issue #27509 ........ Qt: return correct displayrect(drLabel, drIcon) for TListView.vsList. issue #27509 ........ git-svn-id: branches/fixes_1_4@48001 -
This commit is contained in:
parent
adc86f3d63
commit
d0d5319843
@ -7260,9 +7260,20 @@ begin
|
||||
|
||||
Msg.SizeType := Msg.SizeType or Size_SourceIsInterface;
|
||||
|
||||
Msg.Width := Word(getWidth);
|
||||
Msg.Height := Word(getHeight);
|
||||
|
||||
{Mdichild sends size of minimized title, and that's bad, after restore client
|
||||
rect is mismatched and provokes OnResize events.We are sending
|
||||
to the LCL Width and Height of LCLObject so resize event won't trigger.
|
||||
issue #27518}
|
||||
if IsMDIChild and Assigned(LCLObject) and
|
||||
(getWindowState and QtWindowMinimized <> 0) then
|
||||
begin
|
||||
Msg.Width := Word(LCLObject.Width);
|
||||
Msg.Height := Word(LCLObject.Height);
|
||||
end else
|
||||
begin
|
||||
Msg.Width := Word(getWidth);
|
||||
Msg.Height := Word(getHeight);
|
||||
end;
|
||||
DeliverMessage(Msg);
|
||||
end;
|
||||
|
||||
@ -11520,6 +11531,11 @@ var
|
||||
WStr: WideString;
|
||||
DataStr: WideString;
|
||||
ASelected: Boolean;
|
||||
ImgList: TCustomImageList;
|
||||
AImageIndex: TImageIndex;
|
||||
Bmp: TBitmap;
|
||||
v2: QVariantH;
|
||||
AOk: Boolean;
|
||||
begin
|
||||
|
||||
{do not set items during design time}
|
||||
@ -11555,9 +11571,47 @@ begin
|
||||
if (TopItem < 0) or (TopItem > TCustomListViewHack(LCLObject).Items.Count - 1) then
|
||||
break;
|
||||
|
||||
if (TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex <> -1) then
|
||||
ImgList := TCustomListViewHack(LCLObject).SmallImages;
|
||||
if Assigned(ImgList) then
|
||||
begin
|
||||
// TODO: paint icons and reduce paint overhead by checking icon
|
||||
AImageIndex := TCustomListViewHack(LCLObject).Items[TopItem].ImageIndex;
|
||||
if (ImgList.Count > 0) and
|
||||
((AImageIndex >= 0) and (AImageIndex < ImgList.Count)) then
|
||||
begin
|
||||
Bmp := TBitmap.Create;
|
||||
try
|
||||
ImgList.GetBitmap(AImageIndex, Bmp);
|
||||
v2 := QVariant_create;
|
||||
QListWidgetItem_data(item, v2, QtListViewOwnerDataRole);
|
||||
if not QVariant_isNull(v2) then
|
||||
begin
|
||||
AOk := True;
|
||||
if QVariant_toInt(v2, @AOk) <> AImageIndex then
|
||||
begin
|
||||
v2 := QVariant_create(AImageIndex);
|
||||
QListWidgetItem_setData(item, QtListViewOwnerDataRole, v2);
|
||||
QVariant_destroy(v2);
|
||||
QListWidgetItem_setIcon(item, TQtImage(Bmp.Handle).AsIcon)
|
||||
end;
|
||||
// else we are imageIndex and that''s fine.
|
||||
end else
|
||||
begin
|
||||
v2 := QVariant_create(AImageIndex);
|
||||
QListWidgetItem_setData(item, QtListViewOwnerDataRole, v2);
|
||||
QVariant_destroy(v2);
|
||||
QListWidgetItem_setIcon(item, TQtImage(Bmp.Handle).AsIcon);
|
||||
end;
|
||||
finally
|
||||
Bmp.Free;
|
||||
end;
|
||||
end else
|
||||
if (AImageIndex < 0) then
|
||||
begin
|
||||
v2 := QVariant_create;
|
||||
QListWidgetItem_setData(item, QtListViewOwnerDataRole, v2);
|
||||
QVariant_destroy(v2);
|
||||
QListWidgetItem_setIcon(item, nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
WStr := GetUTF8String(TCustomListViewHack(LCLObject).Items[TopItem].Caption);
|
||||
@ -11571,7 +11625,7 @@ begin
|
||||
DataStr := '';
|
||||
QVariant_destroy(v);
|
||||
|
||||
ASelected := TCustomListViewHack(LCLObject).Items[TopItem].Selected;
|
||||
// ASelected := not TCustomListViewHack(LCLObject).Items[TopItem].Selected;
|
||||
|
||||
if (DataStr <> WStr) then
|
||||
begin
|
||||
@ -11582,8 +11636,9 @@ begin
|
||||
QVariant_destroy(v);
|
||||
end;
|
||||
end;
|
||||
if QListWidgetItem_isSelected(Item) <> ASelected then
|
||||
QListWidgetItem_setSelected(Item, ASelected);
|
||||
|
||||
// if (QListWidgetItem_isSelected(Item) <> ASelected) then
|
||||
// QListWidgetItem_setSelected(Item, ASelected);
|
||||
|
||||
end else
|
||||
break;
|
||||
@ -11836,6 +11891,8 @@ begin
|
||||
begin
|
||||
HasPaint := True;
|
||||
QPaintEvent_rect(QPaintEventH(Event), @R);
|
||||
if FOwnerData then
|
||||
OwnerDataNeeded(R);
|
||||
DC := TQtDeviceContext.Create(QWidgetH(Sender), True);
|
||||
try
|
||||
TCustomListViewAccess(LCLObject).Canvas.handle := HDC(DC);
|
||||
@ -11908,8 +11965,7 @@ begin
|
||||
// trigger selectionChanged() here
|
||||
// Multiselection needs special handling to get proper
|
||||
// order of OnSelectItem.
|
||||
|
||||
if getSelectionMode > QAbstractItemViewSingleSelection then
|
||||
if (getSelectionMode > QAbstractItemViewSingleSelection) or FOwnerData then
|
||||
begin
|
||||
Modifiers := QInputEvent_modifiers(QInputEventH(Event));
|
||||
SlotMouse(Sender, Event);
|
||||
|
@ -1579,6 +1579,9 @@ var
|
||||
TWI: QTreeWidgetItemH;
|
||||
Size: TSize;
|
||||
AIcon: QIconH;
|
||||
IconRect: TRect;
|
||||
i: Integer;
|
||||
APixelMetric: Integer;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemDisplayRect') then
|
||||
Exit;
|
||||
@ -1588,6 +1591,49 @@ begin
|
||||
QtListWidget := TQtListWidget(ALV.Handle);
|
||||
LWI := QtListWidget.getItem(AIndex);
|
||||
Result := QtListWidget.getVisualItemRect(LWI);
|
||||
if TCustomListViewHack(ALV).ViewStyle = vsList then
|
||||
begin
|
||||
if ACode in [drBounds, drSelectBounds] then
|
||||
exit;
|
||||
APixelMetric := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtListWidget.Widget);
|
||||
IconRect := Result;
|
||||
// always get icon size
|
||||
AIcon := QIcon_create();
|
||||
try
|
||||
QListWidgetItem_icon(LWI, AIcon);
|
||||
if QIcon_isNull(AIcon) then
|
||||
IconRect := Rect(Result.Left, Result.Top, Result.Left, Result.Top)
|
||||
else
|
||||
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
|
||||
IconRect.Right := IconRect.Left + TCustomListViewHack(ALV).SmallImages.Width;
|
||||
end else
|
||||
begin
|
||||
IconRect.Right := IconRect.Left + Size.cx;
|
||||
IconRect.Bottom := IconRect.Top + Size.cy;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
QIcon_destroy(AIcon);
|
||||
end;
|
||||
|
||||
IconRect.Left += APixelMetric;
|
||||
IconRect.Right += APixelMetric;
|
||||
|
||||
if ACode = drLabel then
|
||||
begin
|
||||
inc(Result.Left, APixelMetric + (IconRect.Right - IconRect.Left));
|
||||
if (IconRect.Right - IconRect.Left > 0) then
|
||||
Result.Left += APixelMetric;
|
||||
end else
|
||||
if ACode in [drIcon] then
|
||||
Result := IconRect;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
QtTreeWidget := TQtTreeWidget(ALV.Handle);
|
||||
@ -1595,29 +1641,67 @@ begin
|
||||
if (QTreeWidgetItem_columnCount(TWI) > 1) and (ASubItem >= 0) then
|
||||
begin
|
||||
Result := QtTreeWidget.visualItemRect(TWI);
|
||||
Result.Left := QTreeView_columnViewportPosition(QTreeWidgeth(QtTreeWidget.Widget), ASubItem);
|
||||
Result.Left := QTreeView_columnViewportPosition(QTreeWidgetH(QtTreeWidget.Widget), ASubItem);
|
||||
Result.Right := QtTreeWidget.ColWidth[ASubItem] + Result.Left;
|
||||
end else
|
||||
begin
|
||||
Result := QtTreeWidget.visualItemRect(TWI);
|
||||
end;
|
||||
if ACode in [drLabel, drSelectBounds] then
|
||||
Result.Right := Result.Left + QtTreeWidget.ColWidth[ASubItem]
|
||||
else
|
||||
if ACode in [drIcon] then
|
||||
|
||||
if ACode = drBounds then
|
||||
begin
|
||||
QWidget_rect(QtTreeWidget.viewportWidget, @IconRect);
|
||||
for i := ASubItem + 1 to QtTreeWidget.ColCount - 1 do
|
||||
Result.Right += QtTreeWidget.ColWidth[i];
|
||||
if Result.Right > IconRect.Right - IconRect.Left then
|
||||
Result.Right := IconRect.Right - IconRect.Left;
|
||||
exit;
|
||||
end else
|
||||
begin
|
||||
IconRect := Result;
|
||||
// always get icon size
|
||||
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, ASubItem);
|
||||
if QIcon_isNull(AIcon) then
|
||||
IconRect := Rect(Result.Left, Result.Top, Result.Left, Result.Top)
|
||||
else
|
||||
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
|
||||
IconRect.Right := IconRect.Left + TCustomListViewHack(ALV).SmallImages.Width;
|
||||
end else
|
||||
begin
|
||||
IconRect.Right := IconRect.Left + Size.cx;
|
||||
IconRect.Bottom := IconRect.Top + Size.cy;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
QIcon_destroy(AIcon);
|
||||
end;
|
||||
QIcon_destroy(AIcon);
|
||||
end;
|
||||
|
||||
APixelMetric := QStyle_pixelMetric(QApplication_style(), QStylePM_FocusFrameHMargin, nil, QtTreeWidget.Widget);
|
||||
IconRect.Left += APixelMetric;
|
||||
IconRect.Right += APixelMetric;
|
||||
|
||||
if ACode = drLabel then
|
||||
begin
|
||||
inc(Result.Left, APixelMetric + (IconRect.Right - IconRect.Left));
|
||||
if (IconRect.Right - IconRect.Left > 0) then
|
||||
Result.Left += APixelMetric;
|
||||
end else
|
||||
if ACode = drSelectBounds then
|
||||
begin
|
||||
Result.Left += APixelMetric;
|
||||
Result.Right := Result.Left + (QtTreeWidget.ColWidth[ASubItem] - APixelMetric);
|
||||
end else
|
||||
if ACode in [drIcon] then
|
||||
Result := IconRect;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user