LCL: TTReeView: added FindNodeWithTextPath

git-svn-id: trunk@42720 -
This commit is contained in:
mattias 2013-09-10 13:09:21 +00:00
parent d32498513b
commit eea2c866ec
2 changed files with 24 additions and 0 deletions

View File

@ -2895,6 +2895,7 @@ type
Data: Pointer): TTreeNode;
function FindNodeWithData(const NodeData: Pointer): TTreeNode;
function FindNodeWithText(const NodeText: string): TTreeNode;
function FindNodeWithTextPath(TextPath: string): TTreeNode;
function FindTopLvlNode(const NodeText: string): TTreeNode;
function GetEnumerator: TTreeNodesEnumerator;
function GetFirstNode: TTreeNode;

View File

@ -2377,6 +2377,29 @@ begin
Result := Result.GetNext;
end;
function TTreeNodes.FindNodeWithTextPath(TextPath: string): TTreeNode;
var
p: SizeInt;
CurText: String;
begin
Result:=nil;
repeat
p:=System.Pos('/',TextPath);
if p>0 then begin
CurText:=LeftStr(TextPath,p-1);
System.Delete(TextPath,1,p);
end else begin
CurText:=TextPath;
TextPath:='';
end;
//debugln(['TTreeNodes.FindNodeWithTextPath CurText=',CurText,' Rest=',TextPath]);
if Result=nil then
Result:=FindTopLvlNode(CurText)
else
Result:=Result.FindNode(CurText);
until (Result=nil) or (TextPath='');
end;
function TTreeNodes.FindNodeWithData(const NodeData: Pointer): TTreeNode;
begin
Result := GetFirstNode;