mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 23:40:26 +02:00
Qt,Qt5: Fixed checkboxes states after sorting in TListView. issue #38137
(cherry picked from commit 5466d422e1
)
This commit is contained in:
parent
1c91d06358
commit
109c9f14ba
@ -163,6 +163,8 @@ type
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
||||
|
||||
class function RestoreItemCheckedAfterSort(const ALV: TCustomListView): Boolean; override;
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
|
||||
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||
@ -2034,10 +2036,17 @@ begin
|
||||
QtTreeWidget.setItemData(Item, 0, AItem);
|
||||
if AList.Checkboxes then
|
||||
begin
|
||||
if AItem.Checked then
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
|
||||
if RestoreItemCheckedAfterSort(AList) then
|
||||
// when true checkboxes are fixed by LCL, so we uncheck each item first
|
||||
// look at TCustomListView.SortWithParams. issue #38137
|
||||
QtTreeWidget.ItemChecked[i] := False
|
||||
else
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
|
||||
begin
|
||||
if AItem.Checked then
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
|
||||
else
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
|
||||
end;
|
||||
end;
|
||||
|
||||
if ImgListRes.Valid and (ImgListRes.Count > 0) and
|
||||
@ -2189,6 +2198,12 @@ begin
|
||||
Result := TQtAbstractItemView(ALV.Handle).getVisibleRowCount;
|
||||
end;
|
||||
|
||||
class function TQtWSCustomListView.RestoreItemCheckedAfterSort(
|
||||
const ALV: TCustomListView): Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
begin
|
||||
|
@ -165,6 +165,8 @@ type
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
||||
|
||||
class function RestoreItemCheckedAfterSort(const ALV: TCustomListView): Boolean; override;
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
|
||||
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||
@ -2069,10 +2071,17 @@ begin
|
||||
QtTreeWidget.setItemData(Item, 0, AItem);
|
||||
if AList.Checkboxes then
|
||||
begin
|
||||
if AItem.Checked then
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
|
||||
if RestoreItemCheckedAfterSort(AList) then
|
||||
// when true checkboxes are fixed by LCL, so we uncheck each item first
|
||||
// look at TCustomListView.SortWithParams. issue #38137
|
||||
QtTreeWidget.ItemChecked[i] := False
|
||||
else
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
|
||||
begin
|
||||
if AItem.Checked then
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
|
||||
else
|
||||
QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
|
||||
end;
|
||||
end;
|
||||
|
||||
if ImgListRes.Valid and (ImgListRes.Count > 0) and
|
||||
@ -2224,6 +2233,12 @@ begin
|
||||
Result := TQtAbstractItemView(ALV.Handle).getVisibleRowCount;
|
||||
end;
|
||||
|
||||
class function TQtWSCustomListView.RestoreItemCheckedAfterSort(
|
||||
const ALV: TCustomListView): Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user