Changeset 4
- Timestamp:
- May 1, 2014, 7:29:12 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LinuxBuilder.lpi
r3 r4 33 33 </Item1> 34 34 </RequiredPackages> 35 <Units Count=" 3">35 <Units Count="5"> 36 36 <Unit0> 37 37 <Filename Value="LinuxBuilder.lpr"/> … … 52 52 <UnitName Value="UKConfig"/> 53 53 </Unit2> 54 <Unit3> 55 <Filename Value="UFormList.pas"/> 56 <IsPartOfProject Value="True"/> 57 <ComponentName Value="FormList"/> 58 <ResourceBaseClass Value="Form"/> 59 <UnitName Value="UFormList"/> 60 </Unit3> 61 <Unit4> 62 <Filename Value="UFormLog.pas"/> 63 <IsPartOfProject Value="True"/> 64 <ComponentName Value="FormLog"/> 65 <ResourceBaseClass Value="Form"/> 66 <UnitName Value="UFormLog"/> 67 </Unit4> 54 68 </Units> 55 69 </ProjectOptions> -
trunk/LinuxBuilder.lpr
r3 r4 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UKConfig 10 Forms, UFormMain, UKConfig, UFormList, UFormLog 11 11 { you can add units after this }; 12 12 … … 17 17 Application.Initialize; 18 18 Application.CreateForm(TFormMain, FormMain); 19 Application.CreateForm(TFormList, FormList); 20 Application.CreateForm(TFormLog, FormLog); 19 21 Application.Run; 20 22 end. -
trunk/UFormMain.lfm
r3 r4 18 18 Height = 504 19 19 Top = 0 20 Width = 84020 Width = 520 21 21 Anchors = [akTop, akLeft, akRight, akBottom] 22 22 DefaultItemHeight = 24 23 ReadOnly = True 24 RowSelect = True 23 25 TabOrder = 0 26 OnSelectionChanged = TreeView1SelectionChanged 27 Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRowSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] 24 28 end 25 29 object StatusBar1: TStatusBar … … 45 49 Style = tbsCheck 46 50 end 51 object ToolButton1: TToolButton 52 Left = 24 53 Top = 2 54 Action = AShowList 55 end 56 end 57 object Memo1: TMemo 58 Left = 536 59 Height = 498 60 Top = 0 61 Width = 312 62 Anchors = [akTop, akRight, akBottom] 63 ReadOnly = True 64 ScrollBars = ssAutoBoth 65 TabOrder = 3 47 66 end 48 67 object MainMenu1: TMainMenu … … 61 80 Action = AViemSystem 62 81 end 82 object MenuItem5: TMenuItem 83 Action = AShowList 84 end 85 object MenuItem6: TMenuItem 86 Action = AShowLog 87 end 63 88 end 64 89 end … … 75 100 OnExecute = AViemSystemExecute 76 101 end 102 object AShowList: TAction 103 Caption = 'Show list' 104 OnExecute = AShowListExecute 105 end 106 object AShowLog: TAction 107 Caption = 'Show log' 108 OnExecute = AShowLogExecute 109 end 77 110 end 78 111 object ImageList1: TImageList -
trunk/UFormMain.pas
r3 r4 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 ActnList, ComCtrls, UKConfig;9 ActnList, ComCtrls, StdCtrls, UKConfig; 10 10 11 11 type … … 14 14 15 15 TFormMain = class(TForm) 16 AShowList: TAction; 17 AShowLog: TAction; 16 18 AViemSystem: TAction; 17 19 AOpenDir: TAction; … … 19 21 ImageList1: TImageList; 20 22 MainMenu1: TMainMenu; 23 Memo1: TMemo; 21 24 MenuItem1: TMenuItem; 22 25 MenuItem2: TMenuItem; 23 26 MenuItem3: TMenuItem; 24 27 MenuItem4: TMenuItem; 28 MenuItem5: TMenuItem; 29 MenuItem6: TMenuItem; 25 30 StatusBar1: TStatusBar; 26 31 ToolBar1: TToolBar; 32 ToolButton1: TToolButton; 27 33 ToolButton2: TToolButton; 28 34 TreeView1: TTreeView; 29 35 procedure AOpenDirExecute(Sender: TObject); 36 procedure AShowListExecute(Sender: TObject); 37 procedure AShowLogExecute(Sender: TObject); 30 38 procedure AViemSystemExecute(Sender: TObject); 31 39 procedure FormCreate(Sender: TObject); 32 40 procedure FormDestroy(Sender: TObject); 33 41 procedure FormShow(Sender: TObject); 42 procedure TreeView1SelectionChanged(Sender: TObject); 34 43 private 35 { private declarations }44 procedure DoLog(Text: string); 36 45 public 37 46 Config: TConfigMenu; … … 44 53 implementation 45 54 55 uses 56 UFormList, UFormLog; 57 46 58 {$R *.lfm} 47 59 … … 52 64 Config.LoadFromDir('/home/chronos/Stažené/linux-3.14.1', 'x86'); 53 65 Reload; 66 end; 67 68 procedure TFormMain.TreeView1SelectionChanged(Sender: TObject); 69 begin 70 if Assigned(TreeView1.Selected) then begin 71 if Assigned(TreeView1.Selected.Data) then 72 TMenuNode(TreeView1.Selected.Data).LoadStats(Memo1.Lines) 73 else Memo1.Lines.Clear; 74 end; 75 end; 76 77 procedure TFormMain.DoLog(Text: string); 78 begin 79 FormLog.Memo1.Lines.Add(Text); 54 80 end; 55 81 … … 76 102 end; 77 103 104 procedure TFormMain.AShowListExecute(Sender: TObject); 105 begin 106 FormList.Show; 107 end; 108 109 procedure TFormMain.AShowLogExecute(Sender: TObject); 110 begin 111 FormLog.Show; 112 end; 113 78 114 procedure TFormMain.AViemSystemExecute(Sender: TObject); 79 115 begin … … 85 121 begin 86 122 Config := TConfigMenu.Create; 123 Config.OnLog := DoLog; 87 124 end; 88 125 -
trunk/UKConfig.pas
r2 r4 14 14 TLoadTreeOption = (toShowSystem); 15 15 TLoadTreeOptions = set of TLoadTreeOption; 16 TObjectMove = record 17 Source: TObject; 18 NewParent: TObject; 19 end; 20 TObjectMoves = array of TObjectMove; 16 21 17 22 { TMenuNode } … … 33 38 destructor Destroy; override; 34 39 function GetName: string; virtual; 40 function GetabsoluteName: string; virtual; 35 41 procedure LoadTreeNode(Node: TTreeNode; Options: TLoadTreeOptions = []); virtual; 36 end; 42 procedure LoadStats(List: TStrings); virtual; 43 procedure SaveToList(List: TStrings); virtual; 44 procedure PrepareMoveList(var List: TObjectMoves); virtual; 45 function GetTopNode: TMenuNode; virtual; 46 function FindNode(ID: string): TMenuNode; virtual; 47 end; 48 49 TOnLogEvent = procedure (Text: string) of object; 37 50 38 51 { TConfigMenu } … … 42 55 CurrentMenu: TMenuNode; 43 56 Arch: string; 57 FOnLog: TOnLogEvent; 58 procedure Log(Text: string); 44 59 function IsWhiteSpace(Character: Char): Boolean; 45 60 function GetNextToken(var Text: string): string; … … 49 64 BaseDir: string; 50 65 procedure LoadFromDir(Dir: string; Arch: string); 66 property OnLog: TOnLogEvent read FOnLog write FOnLog; 51 67 end; 52 68 … … 81 97 end; 82 98 99 function TMenuNode.GetabsoluteName: string; 100 begin 101 if Assigned(Parent) then Result := Parent.GetabsoluteName + ' - '; 102 Result := Result + GetName; 103 end; 104 83 105 procedure TMenuNode.LoadTreeNode(Node: TTreeNode; Options: TLoadTreeOptions); 84 106 var … … 90 112 if (Name <> '') or ((Name = '') and (toShowSystem in Options)) then begin 91 113 NewNode := Node.TreeNodes.AddChild(Node, GetName); 114 NewNode.Data := TMenuNode(Self.Items[I]); 92 115 LoadTreeNode(NewNode, Options); 93 116 end; … … 95 118 end; 96 119 120 procedure TMenuNode.LoadStats(List: TStrings); 121 begin 122 with List do begin 123 Clear; 124 Add('ID: ' + ID); 125 Add('Name: ' + Name); 126 Add('Depends on: ' + Depends.Text); 127 Add('Selects: ' + Selects.Text); 128 Add('Description: ' + Description.Text); 129 Add('Condition: ' + Condition); 130 Add('Value type: ' + IntToStr(Integer(ValueType))); 131 Add('Default value: ' + DefaultValue); 132 end; 133 end; 134 135 procedure TMenuNode.SaveToList(List: TStrings); 136 var 137 I: Integer; 138 begin 139 if ID <> '' then List.Add(ID); 140 for I := 0 to Items.Count - 1 do 141 with TMenuNode(Items[I]) do begin 142 SaveToList(List); 143 end; 144 end; 145 146 procedure TMenuNode.PrepareMoveList(var List: TObjectMoves); 147 var 148 I: Integer; 149 Node: TMenuNode; 150 NewMove: TObjectMove; 151 begin 152 if Depends.Count > 0 then begin 153 Node := GetTopNode.FindNode(Depends[0]); 154 if Assigned(Node) and (Parent <> Node) then begin 155 NewMove.Source := Self; 156 NewMove.NewParent := Node; 157 SetLength(List, Length(List) + 1); 158 List[Length(List) - 1] := NewMove; 159 end; 160 end else 161 if Condition <> '' then begin 162 Node := GetTopNode.FindNode(Condition); 163 if Assigned(Node) and (Parent <> Node) then begin 164 NewMove.Source := Self; 165 NewMove.NewParent := Node; 166 SetLength(List, Length(List) + 1); 167 List[Length(List) - 1] := NewMove; 168 end; 169 end; 170 I := 0; 171 while I < Items.Count do 172 with TMenuNode(Items[I]) do begin 173 PrepareMoveList(List); 174 Inc(I); 175 end; 176 end; 177 178 function TMenuNode.GetTopNode: TMenuNode; 179 begin 180 if Assigned(Parent) then Result := Parent.GetTopNode 181 else Result := Self; 182 end; 183 184 function TMenuNode.FindNode(ID: string): TMenuNode; 185 var 186 I: Integer; 187 begin 188 Result := nil; 189 if Self.ID = ID then Result := Self 190 else begin 191 I := 0; 192 while (I < Items.Count) do begin 193 Result := TMenuNode(Items[I]).FindNode(ID); 194 if Assigned(Result) then Break; 195 Inc(I); 196 end; 197 end; 198 end; 199 97 200 { TConfigMenu } 201 202 procedure TConfigMenu.Log(Text: string); 203 begin 204 if Assigned(FOnLog) then FOnLog(Text); 205 end; 98 206 99 207 function TConfigMenu.IsWhiteSpace(Character: Char): Boolean; … … 155 263 156 264 begin 265 Log('FILE ' + FileName); 157 266 try 158 267 Content := TStringList.Create; … … 165 274 for I := 0 to Content.Count - 1 do begin 166 275 Line := MergedLines + Content[I]; 276 MergedLines := ''; 167 277 LineIndent := 1; 168 278 while (LineIndent <= Length(Line)) and IsWhiteSpace(Line[LineIndent]) do Inc(LineIndent); … … 317 427 if Command = 'menu' then begin 318 428 Parameter := GetNextToken(Line); 429 Log('MENU ' + Parameter + ' IN ' + CurrentMenu.GetAbsoluteName); 319 430 NewMenu := TMenuNode.Create; 320 431 NewMenu.Name := Parameter; 321 432 NewMenu.Parent := CurrentMenu; 433 NewMenu.Condition := Condition; 434 Condition := ''; 322 435 NewItem := NewMenu; 323 436 CurrentMenu.Items.Add(NewMenu); … … 325 438 end else 326 439 if command = 'endmenu' then begin 327 if Assigned(CurrentMenu.Parent) then 328 CurrentMenu := CurrentMenu.Parent 329 else raise Exception.Create('Can''t change menu level up. ' + GetLog); 440 Log('ENDMENU ' + CurrentMenu.GetAbsoluteName); 441 if Assigned(CurrentMenu.Parent) then begin 442 Condition := CurrentMenu.Condition; 443 CurrentMenu := CurrentMenu.Parent; 444 end else raise Exception.Create('Can''t change menu level up. ' + GetLog); 330 445 end else 331 446 if Command = 'if' then begin … … 346 461 347 462 procedure TConfigMenu.LoadFromDir(Dir: string; Arch: string); 463 var 464 Moves: TObjectMoves; 465 I: Integer; 348 466 begin 349 467 Self.Arch := Arch; … … 354 472 CurrentMenu := TopNode; 355 473 ParseFile(BaseDir + DirectorySeparator + 'Kconfig'); 474 475 TopNode.PrepareMoveList(Moves); 476 for I := 0 to Length(Moves) - 1 do 477 with Moves[I] do begin 478 TMenuNode(Source).Parent.Items.OwnsObjects := False; 479 TMenuNode(Source).Parent.Items.Remove(Source); 480 TMenuNode(Source).Parent.Items.OwnsObjects := True; 481 TMenuNode(Source).Parent := TMenuNode(NewParent); 482 TMenuNode(NewParent).Items.Add(Source); 483 end; 356 484 end; 357 485
Note:
See TracChangeset
for help on using the changeset viewer.