add TListItems.findCaption overload for simple and full lookups

This commit is contained in:
Basile Burg 2016-12-04 15:16:40 +01:00
parent 3998474470
commit 2ebcfcc4ce
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 18 additions and 1 deletions

View File

@ -13,7 +13,7 @@ uses
ExtCtrls, FileUtil,
{$ENDIF}
{$IFNDEF CEBUILD}
forms,
forms, ComCtrls,
{$ENDIF}
LazFileUtils, process, asyncprocess, ghashmap, ghashset, LCLIntf, strutils,
xfpjson;
@ -96,6 +96,10 @@ type
function findAny(const key: TJSONStringType; out value: TJSONData): boolean;
end;
TListItemsHelper = class helper for TListItems
function findCaption(const value: string; out res: TListItem): boolean; overload;
end;
(**
* TProcess with assign() 'overriden'.
*)
@ -511,6 +515,19 @@ begin
result := value.isNotNil;
end;
function TListItemsHelper.findCaption(const value: string; out res: TListItem): boolean;
var
i: integer;
begin
result := false;
for i := 0 to self.Count-1 do
begin
res := self.Item[i];
if res.Caption = value then
exit(true);
end;
end;
procedure TProcessEx.Assign(value: TPersistent);
var
src: TProcess;