mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 01:55:54 +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 DoFinalizeWnd;
|
||||||
procedure SetCount(const ACount: Integer); virtual;
|
procedure SetCount(const ACount: Integer); virtual;
|
||||||
procedure SetItem(const AIndex: Integer; const AValue: TListItem);
|
procedure SetItem(const AIndex: Integer; const AValue: TListItem);
|
||||||
|
procedure ClearSelection;
|
||||||
|
procedure SelectAll;
|
||||||
public
|
public
|
||||||
function Add: TListItem;
|
function Add: TListItem;
|
||||||
procedure AddItem(AItem: TListItem);
|
procedure AddItem(AItem: TListItem);
|
||||||
@ -1536,6 +1538,9 @@ type
|
|||||||
If no item is found Nil is returned.}
|
If no item is found Nil is returned.}
|
||||||
function GetNextItem(StartItem: TListItem; Direction: TSearchDirection; States: TListItemStates): TListItem;
|
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
|
function IsEditing: Boolean; // Delphi compatibile function which returns if our listview editor is active
|
||||||
property BoundingRect: TRect read GetBoundingRect;
|
property BoundingRect: TRect read GetBoundingRect;
|
||||||
property BorderStyle default bsSingle;
|
property BorderStyle default bsSingle;
|
||||||
|
@ -1252,6 +1252,31 @@ begin
|
|||||||
end
|
end
|
||||||
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;
|
function TCustomListView.IsEditing: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Assigned(Self.FEditor) and FEditor.Visible;
|
Result := Assigned(Self.FEditor) and FEditor.Visible;
|
||||||
|
@ -336,6 +336,36 @@ begin
|
|||||||
InsertItem(Result, AIndex);
|
InsertItem(Result, AIndex);
|
||||||
end;
|
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
|
TListItems InsertItem
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
@ -186,12 +186,13 @@ type
|
|||||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; 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 SetAllocBy(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||||
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
class procedure SetDefaultItemHeight(const ALV: TCustomListView; const {%H-}AValue: Integer); override;
|
||||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
class procedure SetHotTrackStyles(const ALV: TCustomListView; const {%H-}AValue: TListHotTrackStyles); 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 SetIconOptions(const ALV: TCustomListView; const AValue: TIconOptions); override;
|
||||||
class procedure SetImageList(const ALV: TCustomListView; const AList: TListViewImageList; const AValue: TCustomImageList); 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;
|
class procedure SetItemsCount(const ALV: TCustomListView; const {%H-}Avalue: Integer); override;
|
||||||
|
@ -2023,6 +2023,40 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
class procedure TGtk2WSCustomListView.SetAllocBy(const ALV: TCustomListView;
|
||||||
const AValue: Integer);
|
const AValue: Integer);
|
||||||
begin
|
begin
|
||||||
@ -2074,13 +2108,6 @@ begin
|
|||||||
then Exit;
|
then Exit;
|
||||||
end;
|
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;
|
class procedure TGtk2WSCustomListView.SetImageList(const ALV: TCustomListView;
|
||||||
const AList: TListViewImageList; const AValue: TCustomImageList);
|
const AList: TListViewImageList; const AValue: TCustomImageList);
|
||||||
var
|
var
|
||||||
|
@ -158,6 +158,8 @@ type
|
|||||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; 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 SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||||
class procedure SetIconArrangement(const ALV: TCustomListView; const AValue: TIconArrangement); override;
|
class procedure SetIconArrangement(const ALV: TCustomListView; const AValue: TIconArrangement); override;
|
||||||
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
|
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
|
||||||
@ -1912,6 +1914,17 @@ begin
|
|||||||
Result := TQtAbstractItemView(ALV.Handle).getVisibleRowCount;
|
Result := TQtAbstractItemView(ALV.Handle).getVisibleRowCount;
|
||||||
end;
|
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;
|
class procedure TQtWSCustomListView.SetAllocBy(const ALV: TCustomListView;
|
||||||
const AValue: Integer);
|
const AValue: Integer);
|
||||||
var
|
var
|
||||||
@ -2075,7 +2088,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TQtWSCustomListView.SetViewStyle(const ALV: TCustomListView;
|
class procedure TQtWSCustomListView.SetViewStyle(const ALV: TCustomListView;
|
||||||
const AValue: TViewStyle);
|
const Avalue: TViewStyle);
|
||||||
var
|
var
|
||||||
QtItemView: TQtAbstractItemView;
|
QtItemView: TQtAbstractItemView;
|
||||||
QtListWidget: TQtListWidget;
|
QtListWidget: TQtListWidget;
|
||||||
|
@ -170,6 +170,7 @@ type
|
|||||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
class function GetViewOrigin(const ALV: TCustomListView): TPoint; override;
|
||||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; 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 SetAllocBy(const ALV: TCustomListView; const AValue: Integer); override;
|
||||||
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||||
|
@ -975,6 +975,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
class function TWin32WSCustomListView.GetHeader(const AHandle: THandle): THandle;
|
||||||
begin
|
begin
|
||||||
Result := THandle(SendMessage(AHandle, LVM_GETHEADER, 0, 0));
|
Result := THandle(SendMessage(AHandle, LVM_GETHEADER, 0, 0));
|
||||||
|
@ -152,6 +152,7 @@ type
|
|||||||
class function GetViewOrigin(const ALV: TCustomListView): TPoint; virtual;
|
class function GetViewOrigin(const ALV: TCustomListView): TPoint; virtual;
|
||||||
class function GetVisibleRowCount(const ALV: TCustomListView): Integer; 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 SetAllocBy(const ALV: TCustomListView; const AValue: Integer); virtual;
|
||||||
class procedure SetDefaultItemHeight(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;
|
class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); virtual;
|
||||||
@ -650,7 +651,8 @@ class procedure TWSCustomListView.SetImageList(const ALV: TCustomListView; const
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWSCustomListView.SetOwnerData(const ALV: TCustomListView; const Avalue: Boolean);
|
class procedure TWSCustomListView.SetOwnerData(const ALV: TCustomListView;
|
||||||
|
const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -684,6 +686,12 @@ class procedure TWSCustomListView.SetItemsCount(const ALV: TCustomListView; cons
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWSCustomListView.SelectAll(const ALV: TCustomListView;
|
||||||
|
const AIsSet: Boolean);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWSProgressBar }
|
{ TWSProgressBar }
|
||||||
|
|
||||||
class procedure TWSProgressBar.ApplyChanges(const AProgressBar: TCustomProgressBar);
|
class procedure TWSProgressBar.ApplyChanges(const AProgressBar: TCustomProgressBar);
|
||||||
|
Loading…
Reference in New Issue
Block a user