ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/ibcontrols/IBTreeView.pas
(Generate patch)

Comparing ibx/trunk/ibcontrols/IBTreeView.pas (file contents):
Revision 79 by tony, Tue May 17 08:14:52 2016 UTC vs.
Revision 80 by tony, Mon Jan 1 11:31:07 2018 UTC

# Line 77 | Line 77 | type
77    private
78      FKeyValue: variant;
79    public
80 +    constructor Create(AnOwner: TTreeNodes); override;
81      procedure DeleteAll;
82      property KeyValue: variant read FKeyValue;
83    end;
# Line 134 | Line 135 | type
135      { Public declarations }
136      constructor Create(TheComponent: TComponent); override;
137      destructor Destroy; override;
138 <    function FindNode(KeyValuePath: array of variant; SelectNode: boolean): TIBTreeNode; overload;
138 >    function FindNode(KeyValuePath: TVariantArray; SelectNode: boolean): TIBTreeNode; overload;
139      function FindNode(KeyValue: variant): TIBTreeNode; overload;
140      function GetNodePath(Node: TTreeNode): TVariantArray;
141      property DataSet: TDataSet read GetDataSet;
# Line 301 | Line 302 | end;
302  
303   { TIBTreeNode }
304  
305 + constructor TIBTreeNode.Create(AnOwner: TTreeNodes);
306 + begin
307 +  inherited Create(AnOwner);
308 +  FKeyValue := NULL;
309 + end;
310 +
311   procedure TIBTreeNode.DeleteAll;
312   var Node, NextNode: TTreeNode;
313   begin
# Line 501 | Line 508 | begin
508    if Result then
509    begin
510      if DataSet.Active and (DataSet.RecordCount > 0)
511 <         and (Node.KeyValue = DataSet.FieldByName(KeyField).AsVariant) then Exit;
511 >         and DataSet.Locate(KeyField,Node.KeyValue,[]) then Exit;
512  
513      FUpdateNode := Node;
514      try
# Line 687 | Line 694 | begin
694    inherited Destroy;
695   end;
696  
697 < function TIBTreeView.FindNode(KeyValuePath: array of variant;
698 <  SelectNode: boolean): TIBTreeNode;
697 > function TIBTreeView.FindNode(KeyValuePath: TVariantArray; SelectNode: boolean
698 >  ): TIBTreeNode;
699   var Node: TTreeNode;
700      i,j: integer;
701   begin
702    Result := nil;
703 +  if Length(KeyValuePath) = 0 then Exit;
704 +
705    FLocatingNode := true;
706    try
707     for j := 0 to Items.TopLvlCount - 1 do
# Line 702 | Line 711 | begin
711      Node.Expand(false);
712      while assigned(Node)  do
713      begin
714 <      if TIBTreeNode(Node).KeyValue = KeyValuePath[i] then
714 >      if not VarIsNull(TIBTreeNode(Node).KeyValue) and
715 >                        (TIBTreeNode(Node).KeyValue = KeyValuePath[i]) then
716        begin
717          Inc(i);
718          if i = Length(KeyValuePath) then

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines