Qt,Qt5: Fixed checkboxes states after sorting in TListView. issue #38137

(cherry picked from commit 5466d422e1)
This commit is contained in:
Željan Rikalo 2021-08-28 17:21:08 +02:00 committed by Maxim Ganetsky
parent 1c91d06358
commit 109c9f14ba
2 changed files with 36 additions and 6 deletions

View File

@ -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

View File

@ -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