From 2ebcfcc4ceb0a09bb8cc1a83fdfe84df8bb3c623 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 4 Dec 2016 15:16:40 +0100 Subject: [PATCH] add TListItems.findCaption overload for simple and full lookups --- src/ce_common.pas | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 178b3968..05b9ce14 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -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;