Changeset 5 for trunk/UKConfig.pas
- Timestamp:
- May 1, 2014, 11:31:03 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UKConfig.pas
r4 r5 41 41 procedure LoadTreeNode(Node: TTreeNode; Options: TLoadTreeOptions = []); virtual; 42 42 procedure LoadStats(List: TStrings); virtual; 43 procedure GetNodes(List: TStrings); virtual; 43 44 procedure SaveToList(List: TStrings); virtual; 44 procedure PrepareMoveList(var List: TObjectMoves); virtual; 45 procedure PrepareMoveList(Lookup: TStringList; var List: TObjectMoves); virtual; 46 function GetCount: Integer; virtual; 45 47 function GetTopNode: TMenuNode; virtual; 46 48 function FindNode(ID: string): TMenuNode; virtual; … … 63 65 TopNode: TMenuNode; 64 66 BaseDir: string; 67 procedure PrepareMoveList(var List: TObjectMoves); 68 procedure CompareStringLists(List1, List2: TStringList; Missing1, 69 Missing2: TStrings); 65 70 procedure LoadFromDir(Dir: string; Arch: string); 66 71 property OnLog: TOnLogEvent read FOnLog write FOnLog; … … 133 138 end; 134 139 140 procedure TMenuNode.GetNodes(List: TStrings); 141 var 142 I: Integer; 143 begin 144 if ID <> '' then List.AddObject(ID, Self); 145 for I := 0 to Items.Count - 1 do 146 with TMenuNode(Items[I]) do begin 147 GetNodes(List); 148 end; 149 end; 150 135 151 procedure TMenuNode.SaveToList(List: TStrings); 136 152 var … … 144 160 end; 145 161 146 procedure TMenuNode.PrepareMoveList( var List: TObjectMoves);162 procedure TMenuNode.PrepareMoveList(Lookup: TStringList; var List: TObjectMoves); 147 163 var 148 164 I: Integer; 149 165 Node: TMenuNode; 150 166 NewMove: TObjectMove; 167 Index: Integer; 151 168 begin 152 169 if Depends.Count > 0 then begin 153 Node := GetTopNode.FindNode(Depends[0]); 170 Index := Lookup.IndexOf(Depends[0]); 171 if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index]) 172 else Node := nil; 154 173 if Assigned(Node) and (Parent <> Node) then begin 155 174 NewMove.Source := Self; … … 160 179 end else 161 180 if Condition <> '' then begin 162 Node := GetTopNode.FindNode(Condition); 181 Index := Lookup.IndexOf(Condition); 182 if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index]) 183 else Node := nil; 163 184 if Assigned(Node) and (Parent <> Node) then begin 164 185 NewMove.Source := Self; … … 171 192 while I < Items.Count do 172 193 with TMenuNode(Items[I]) do begin 173 PrepareMoveList(L ist);194 PrepareMoveList(Lookup, List); 174 195 Inc(I); 196 end; 197 end; 198 199 function TMenuNode.GetCount: Integer; 200 var 201 I: Integer; 202 begin 203 Result := 1; 204 for I := 0 to Items.Count - 1 do 205 with TMenuNode(Items[I]) do begin 206 Result := Result + GetCount; 175 207 end; 176 208 end; … … 460 492 end; 461 493 494 procedure TConfigMenu.PrepareMoveList(var List: TObjectMoves); 495 var 496 Lookup: TStringList; 497 begin 498 try 499 Lookup := TStringList.Create; 500 Lookup.OwnsObjects := False; 501 TopNode.GetNodes(Lookup); 502 Lookup.Sorted := True; 503 TopNode.PrepareMoveList(Lookup, List); 504 finally 505 Lookup.Free; 506 end; 507 end; 508 509 procedure TConfigMenu.CompareStringLists(List1, List2: TStringList; 510 Missing1, Missing2: TStrings); 511 var 512 I: Integer; 513 J: Integer; 514 begin 515 List1.Sort; 516 List2.Sort; 517 I := 0; 518 J := 0; 519 while (I < List1.Count) and (J < List2.Count) do 520 begin 521 if List1[I] < List2[J] then 522 begin 523 Missing2.Add(List1[I]); 524 Inc(I); 525 end 526 else if List1[I] > List2[J] then 527 begin 528 Missing1.Add(List2[J]); 529 Inc(J); 530 end 531 else 532 begin 533 Inc(I); 534 Inc(J); 535 end; 536 end; 537 for I := I to List1.Count - 1 do 538 Missing2.Add(List1[I]); 539 for J := J to List2.Count - 1 do 540 Missing1.Add(List2[J]); 541 end; 542 462 543 procedure TConfigMenu.LoadFromDir(Dir: string; Arch: string); 463 544 var … … 473 554 ParseFile(BaseDir + DirectorySeparator + 'Kconfig'); 474 555 475 TopNode.PrepareMoveList(Moves);556 PrepareMoveList(Moves); 476 557 for I := 0 to Length(Moves) - 1 do 477 558 with Moves[I] do begin
Note:
See TracChangeset
for help on using the changeset viewer.