mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 02:19:57 +02:00
LCL: TCustomListView: implemented SelectAll & ClearSelection for delphi compatibility. issue #19812
git-svn-id: trunk@43244 -
This commit is contained in:
parent
6471321801
commit
f6fa81d118
@ -1094,6 +1094,8 @@ type
|
||||
procedure DoFinalizeWnd;
|
||||
procedure SetCount(const ACount: Integer); virtual;
|
||||
procedure SetItem(const AIndex: Integer; const AValue: TListItem);
|
||||
procedure ClearSelection;
|
||||
procedure SelectAll;
|
||||
public
|
||||
function Add: TListItem;
|
||||
procedure AddItem(AItem: TListItem);
|
||||
@ -1536,6 +1538,9 @@ type
|
||||
If no item is found Nil is returned.}
|
||||
function GetNextItem(StartItem: TListItem; Direction: TSearchDirection; States: TListItemStates): TListItem;
|
||||
|
||||
procedure ClearSelection;
|
||||
procedure SelectAll;
|
||||
|
||||
function IsEditing: Boolean; // Delphi compatibile function which returns if our listview editor is active
|
||||
property BoundingRect: TRect read GetBoundingRect;
|
||||
property BorderStyle default bsSingle;
|
||||
|
@ -1252,6 +1252,31 @@ begin
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TCustomListView.ClearSelection;
|
||||
begin
|
||||
Self.BeginUpdate;
|
||||
if MultiSelect then
|
||||
begin
|
||||
if HandleAllocated then
|
||||
TWSCustomListViewClass(WidgetSetClass).SelectAll(Self, False);
|
||||
Items.ClearSelection;
|
||||
end else
|
||||
if (ItemIndex >= 0) and (ItemIndex < Items.Count) then
|
||||
Items.Item[ItemIndex].Selected := False;
|
||||
Self.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TCustomListView.SelectAll;
|
||||
begin
|
||||
if not MultiSelect then
|
||||
exit;
|
||||
Self.BeginUpdate;
|
||||
if HandleAllocated then
|
||||
TWSCustomListViewClass(WidgetSetClass).SelectAll(Self, True);
|
||||
Items.SelectAll;
|
||||
Self.EndUpdate;
|
||||
end;
|
||||
|
||||
function TCustomListView.IsEditing: Boolean;
|
||||
begin
|
||||
Result := Assigned(Self.FEditor) and FEditor.Visible;
|
||||
|
@ -336,6 +336,36 @@ begin
|
||||
InsertItem(Result, AIndex);
|
||||
end;
|
||||
|
||||
procedure TListItems.SelectAll;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to Count - 1 do
|
||||
begin
|
||||
if not (lisSelected in Item[i].FStates) then
|
||||
begin
|
||||
Self.Item[i].FStates := Self.Item[i].FStates + [lisSelected];
|
||||
if Assigned(Owner.OnSelectItem) then
|
||||
Owner.OnSelectItem(Owner, Item[i], True);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TListItems.ClearSelection;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to Count - 1 do
|
||||
begin
|
||||
if (lisSelected in Item[i].FStates) then
|
||||
begin
|
||||
Self.Item[i].FStates := Self.Item[i].FStates - [lisSelected];
|
||||
if Assigned(Owner.OnSelectItem) then
|
||||
Owner.OnSelectItem(Owner, Item[i], False);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TListItems InsertItem
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -186,12 +186,13 @@ type
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||
class procedure SetHotTrackStyles(const ALV: TCustomListView; const {%H-}AValue: TListHotTrackStyles); override;
|
||||
class procedure SetHoverTime(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||
// class procedure SetHoverTime(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||
// class procedure SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
|
||||
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); override;
|
||||
class procedure SetItemsCount(const ALV: TCustomListView; const {%H-}Avalue: Integer); override;
|
||||
|
@ -2023,6 +2023,40 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
var
|
||||
Widgets: PTVWidgets;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SelectAll') then
|
||||
exit;
|
||||
GetCommonTreeViewWidgets({%H-}PGtkWidget(ALV.Handle), Widgets);
|
||||
Include(Widgets^.WidgetInfo^.Flags, wwiInvalidEvent);
|
||||
try
|
||||
with Widgets^ do
|
||||
begin
|
||||
if GTK_IS_TREE_VIEW(MainView) then
|
||||
begin
|
||||
if AIsSet then
|
||||
gtk_tree_selection_select_all(gtk_tree_view_get_selection(PGtkTreeView(MainView)))
|
||||
else
|
||||
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(PGtkTreeView(MainView)));
|
||||
end else
|
||||
begin
|
||||
if GTK_IS_ICON_VIEW(MainView) then
|
||||
begin
|
||||
if AIsSet then
|
||||
gtk_icon_view_select_all(PGtkIconView(MainView))
|
||||
else
|
||||
gtk_icon_view_unselect_all(PGtkIconView(MainView));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Exclude(Widgets^.WidgetInfo^.Flags, wwiInvalidEvent);
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomListView.SetAllocBy(const ALV: TCustomListView;
|
||||
const AValue: Integer);
|
||||
begin
|
||||
@ -2074,13 +2108,6 @@ begin
|
||||
then Exit;
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomListView.SetHoverTime(const ALV: TCustomListView;
|
||||
const AValue: Integer);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SetHoverTime')
|
||||
then Exit;
|
||||
end;
|
||||
|
||||
class procedure TGtk2WSCustomListView.SetImageList(const ALV: TCustomListView;
|
||||
const AList: TListViewImageList; const AValue: TCustomImageList);
|
||||
var
|
||||
|
@ -158,6 +158,8 @@ type
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
|
||||
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||
class procedure SetIconArrangement(const ALV: TCustomListView; const AValue: TIconArrangement); override;
|
||||
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
|
||||
@ -1912,6 +1914,17 @@ begin
|
||||
Result := TQtAbstractItemView(ALV.Handle).getVisibleRowCount;
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SelectAll') then
|
||||
Exit;
|
||||
if AIsSet then
|
||||
QAbstractItemView_selectAll(QAbstractItemViewH(TQtWidget(ALV.Handle).Widget))
|
||||
else
|
||||
QAbstractItemView_clearSelection(QAbstractItemViewH(TQtWidget(ALV.Handle).Widget));
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomListView.SetAllocBy(const ALV: TCustomListView;
|
||||
const AValue: Integer);
|
||||
var
|
||||
@ -2075,7 +2088,7 @@ begin
|
||||
end;
|
||||
|
||||
class procedure TQtWSCustomListView.SetViewStyle(const ALV: TCustomListView;
|
||||
const AValue: TViewStyle);
|
||||
const Avalue: TViewStyle);
|
||||
var
|
||||
QtItemView: TQtAbstractItemView;
|
||||
QtListWidget: TQtListWidget;
|
||||
|
@ -170,6 +170,7 @@ type
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; override;
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); override;
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
|
@ -975,6 +975,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
begin
|
||||
if not WSCheckHandleAllocated(ALV, 'SelectAll') then
|
||||
exit;
|
||||
// Index param -1 means select all.
|
||||
if AIsSet then
|
||||
ListView_SetItemState(ALV.Handle, -1, LVIS_SELECTED, LVIS_SELECTED)
|
||||
else
|
||||
ListView_SetItemState(ALV.Handle, -1, 0, LVIS_SELECTED);
|
||||
end;
|
||||
|
||||
class function TWin32WSCustomListView.GetHeader(const AHandle: THandle): THandle;
|
||||
begin
|
||||
Result := THandle(SendMessage(AHandle, LVM_GETHEADER, 0, 0));
|
||||
|
@ -151,7 +151,8 @@ type
|
||||
class function GetTopItem(const ALV: TCustomListView): Integer; virtual;
|
||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; virtual;
|
||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; virtual;
|
||||
|
||||
|
||||
class procedure SelectAll(const ALV: TCustomListView; const AIsSet: Boolean); virtual;
|
||||
class procedure SetAllocBy(const ALV: TCustomListView; const AValue: Integer); virtual;
|
||||
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const AValue: Integer); virtual;
|
||||
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); virtual;
|
||||
@ -650,7 +651,8 @@ class procedure TWSCustomListView.SetImageList(const ALV: TCustomListView; const
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomListView.SetOwnerData(const ALV: TCustomListView; const Avalue: Boolean);
|
||||
class procedure TWSCustomListView.SetOwnerData(const ALV: TCustomListView;
|
||||
const AValue: Boolean);
|
||||
begin
|
||||
end;
|
||||
|
||||
@ -684,6 +686,12 @@ class procedure TWSCustomListView.SetItemsCount(const ALV: TCustomListView; cons
|
||||
begin
|
||||
end;
|
||||
|
||||
class procedure TWSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||
const AIsSet: Boolean);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
{ TWSProgressBar }
|
||||
|
||||
class procedure TWSProgressBar.ApplyChanges(const AProgressBar: TCustomProgressBar);
|
||||
|
Loading…
Reference in New Issue
Block a user