mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 18:19:34 +02:00
Cocoa/ListView: fix items count and index error after ItemDelete()
This commit is contained in:
parent
5d63a16ea4
commit
6715cb64ed
@ -13,7 +13,7 @@ uses
|
|||||||
// RTL, FCL, LCL
|
// RTL, FCL, LCL
|
||||||
MacOSAll, CocoaAll,
|
MacOSAll, CocoaAll,
|
||||||
Classes, LCLType, SysUtils, LCLMessageGlue, LMessages,
|
Classes, LCLType, SysUtils, LCLMessageGlue, LMessages,
|
||||||
Controls, ComCtrls, Types, StdCtrls, LCLProc, Graphics, ImgList,
|
Controls, ComCtrls, Types, StdCtrls, LCLProc, Graphics, ImgList, Forms,
|
||||||
Math,
|
Math,
|
||||||
// WS
|
// WS
|
||||||
WSComCtrls,
|
WSComCtrls,
|
||||||
@ -420,9 +420,11 @@ type
|
|||||||
private
|
private
|
||||||
_listView: TCocoaListView;
|
_listView: TCocoaListView;
|
||||||
_collectionView: TCocoaCollectionView;
|
_collectionView: TCocoaCollectionView;
|
||||||
|
private
|
||||||
|
function getCallback: TLCLListViewCallback;
|
||||||
|
procedure doReloadDataAfterDelete( AIndex: PtrInt);
|
||||||
public
|
public
|
||||||
constructor Create( listView: TCocoaListView );
|
constructor Create( listView: TCocoaListView );
|
||||||
function getCallback: TLCLListViewCallback;
|
|
||||||
public
|
public
|
||||||
// Column
|
// Column
|
||||||
procedure ColumnDelete( const AIndex: Integer ); override;
|
procedure ColumnDelete( const AIndex: Integer ); override;
|
||||||
@ -1050,16 +1052,21 @@ procedure TCocoaWSListView_CollectionViewHandler.ColumnSetSortIndicator(
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// when LCL call ItemDelete, the Item isn't Deleted at LCL
|
||||||
|
// delayed reload is necessary
|
||||||
procedure TCocoaWSListView_CollectionViewHandler.ItemDelete(
|
procedure TCocoaWSListView_CollectionViewHandler.ItemDelete(
|
||||||
const AIndex: Integer);
|
const AIndex: Integer);
|
||||||
|
begin
|
||||||
|
Application.QueueAsyncCall( doReloadDataAfterDelete, AIndex );
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCocoaWSListView_CollectionViewHandler.doReloadDataAfterDelete( AIndex: PtrInt);
|
||||||
var
|
var
|
||||||
lclcb : TLCLListViewCallback;
|
lclcb : TLCLListViewCallback;
|
||||||
begin
|
begin
|
||||||
lclcb:= getCallback;
|
lclcb:= getCallback;
|
||||||
lclcb.tempItemsCountDelta:= -1;
|
lclcb.selectionIndexSet.shiftIndexesStartingAtIndex_by( AIndex+1, -1 );
|
||||||
lclcb.selectionIndexSet.shiftIndexesStartingAtIndex_by(AIndex, -1);
|
|
||||||
_collectionView.reloadData;
|
_collectionView.reloadData;
|
||||||
lclcb.tempItemsCountDelta:= 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
/// to do
|
/// to do
|
||||||
|
Loading…
Reference in New Issue
Block a user