mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 21:50:18 +02:00
cody: show uses path
git-svn-id: trunk@29515 -
This commit is contained in:
parent
d1c893c176
commit
bba3e2b3fc
@ -34,7 +34,9 @@ resourcestring
|
|||||||
crsPleaseOpenAProjectFirst = 'Please open a project first.';
|
crsPleaseOpenAProjectFirst = 'Please open a project first.';
|
||||||
crsPPUFilesOfProject = 'PPU files of project "%s"';
|
crsPPUFilesOfProject = 'PPU files of project "%s"';
|
||||||
crsUses = 'Uses';
|
crsUses = 'Uses';
|
||||||
|
lisCOGeneral = 'General';
|
||||||
crsUsedBy = 'Used by';
|
crsUsedBy = 'Used by';
|
||||||
|
lisCOUsesPath = 'Uses path';
|
||||||
crsProjectHasNoMainSourceFile = 'Project has no main source file.';
|
crsProjectHasNoMainSourceFile = 'Project has no main source file.';
|
||||||
crsMainSourceFile = 'Main source file: %s';
|
crsMainSourceFile = 'Main source file: %s';
|
||||||
crsSizeOfPpuFile = 'Size of .ppu file';
|
crsSizeOfPpuFile = 'Size of .ppu file';
|
||||||
|
@ -49,3 +49,11 @@ msgstr ""
|
|||||||
msgid "Uses"
|
msgid "Uses"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: codystrconsts.liscogeneral
|
||||||
|
msgid "General"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: codystrconsts.liscousespath
|
||||||
|
msgid "Uses path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
@ -57,3 +57,11 @@ msgstr "Используется"
|
|||||||
msgid "Uses"
|
msgid "Uses"
|
||||||
msgstr "Использует"
|
msgstr "Использует"
|
||||||
|
|
||||||
|
#: codystrconsts.liscogeneral
|
||||||
|
msgid "General"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: codystrconsts.liscousespath
|
||||||
|
msgid "Uses path"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
object PPUListDialog: TPPUListDialog
|
object PPUListDialog: TPPUListDialog
|
||||||
Left = 275
|
Left = 275
|
||||||
Height = 526
|
Height = 531
|
||||||
Top = 250
|
Top = 250
|
||||||
Width = 613
|
Width = 740
|
||||||
Caption = 'PPUListDialog'
|
Caption = 'PPUListDialog'
|
||||||
ClientHeight = 526
|
ClientHeight = 531
|
||||||
ClientWidth = 613
|
ClientWidth = 740
|
||||||
OnClose = FormClose
|
OnClose = FormClose
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
@ -14,8 +14,8 @@ object PPUListDialog: TPPUListDialog
|
|||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 40
|
Height = 40
|
||||||
Top = 480
|
Top = 485
|
||||||
Width = 601
|
Width = 728
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.Caption = '&OK'
|
OKButton.Caption = '&OK'
|
||||||
OKButton.Enabled = False
|
OKButton.Enabled = False
|
||||||
@ -34,7 +34,7 @@ object PPUListDialog: TPPUListDialog
|
|||||||
Left = 6
|
Left = 6
|
||||||
Height = 244
|
Height = 244
|
||||||
Top = 30
|
Top = 30
|
||||||
Width = 601
|
Width = 728
|
||||||
Align = alTop
|
Align = alTop
|
||||||
AutoFillColumns = True
|
AutoFillColumns = True
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
@ -42,27 +42,27 @@ object PPUListDialog: TPPUListDialog
|
|||||||
item
|
item
|
||||||
SizePriority = 10
|
SizePriority = 10
|
||||||
Title.Caption = 'Unit'
|
Title.Caption = 'Unit'
|
||||||
Width = 119
|
Width = 145
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
SizePriority = 10
|
SizePriority = 10
|
||||||
Title.Caption = 'Size of .ppu file'
|
Title.Caption = 'Size of .ppu file'
|
||||||
Width = 119
|
Width = 145
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
SizePriority = 10
|
SizePriority = 10
|
||||||
Title.Caption = 'Size of .o file'
|
Title.Caption = 'Size of .o file'
|
||||||
Width = 119
|
Width = 145
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
SizePriority = 5
|
SizePriority = 5
|
||||||
Title.Caption = 'Uses'
|
Title.Caption = 'Uses'
|
||||||
Width = 119
|
Width = 145
|
||||||
end
|
end
|
||||||
item
|
item
|
||||||
SizePriority = 5
|
SizePriority = 5
|
||||||
Title.Caption = 'Used by'
|
Title.Caption = 'Used by'
|
||||||
Width = 123
|
Width = 146
|
||||||
end>
|
end>
|
||||||
DefaultColWidth = 150
|
DefaultColWidth = 150
|
||||||
FixedCols = 0
|
FixedCols = 0
|
||||||
@ -72,18 +72,18 @@ object PPUListDialog: TPPUListDialog
|
|||||||
OnMouseDown = UnitsStringGridMouseDown
|
OnMouseDown = UnitsStringGridMouseDown
|
||||||
OnSelectCell = UnitsStringGridSelectCell
|
OnSelectCell = UnitsStringGridSelectCell
|
||||||
ColWidths = (
|
ColWidths = (
|
||||||
119
|
145
|
||||||
119
|
145
|
||||||
119
|
145
|
||||||
119
|
145
|
||||||
123
|
146
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
object ScopeLabel: TLabel
|
object ScopeLabel: TLabel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 18
|
Height = 18
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 601
|
Width = 728
|
||||||
Align = alTop
|
Align = alTop
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'ScopeLabel'
|
Caption = 'ScopeLabel'
|
||||||
@ -94,77 +94,121 @@ object PPUListDialog: TPPUListDialog
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 5
|
Height = 5
|
||||||
Top = 280
|
Top = 280
|
||||||
Width = 613
|
Width = 740
|
||||||
Align = alTop
|
Align = alTop
|
||||||
ResizeAnchor = akTop
|
ResizeAnchor = akTop
|
||||||
end
|
end
|
||||||
object UnitGroupBox: TGroupBox
|
object UnitGroupBox: TGroupBox
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 183
|
Height = 188
|
||||||
Top = 291
|
Top = 291
|
||||||
Width = 601
|
Width = 728
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'UnitGroupBox'
|
Caption = 'UnitGroupBox'
|
||||||
ClientHeight = 162
|
ClientHeight = 167
|
||||||
ClientWidth = 593
|
ClientWidth = 720
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
object UnitPageControl: TPageControl
|
object UnitPageControl: TPageControl
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 162
|
Height = 167
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 593
|
Width = 720
|
||||||
ActivePage = UnitUsesTabSheet
|
ActivePage = UsesPathTabSheet
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabIndex = 0
|
TabIndex = 3
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object UnitUsesTabSheet: TTabSheet
|
object InfoTabSheet: TTabSheet
|
||||||
Caption = 'UnitUsesTabSheet'
|
Caption = 'InfoTabSheet'
|
||||||
ClientHeight = 129
|
ClientHeight = 134
|
||||||
ClientWidth = 589
|
ClientWidth = 716
|
||||||
object UnitUsesStringGrid: TStringGrid
|
object SourceFileLabel: TLabel
|
||||||
|
Left = 9
|
||||||
|
Height = 18
|
||||||
|
Top = 14
|
||||||
|
Width = 109
|
||||||
|
Caption = 'SourceFileLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object PPUFileLabel: TLabel
|
||||||
|
AnchorSideTop.Control = SourceFileLabel
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 9
|
||||||
|
Height = 18
|
||||||
|
Top = 38
|
||||||
|
Width = 91
|
||||||
|
BorderSpacing.Top = 6
|
||||||
|
Caption = 'PPUFileLabel'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object UsesTabSheet: TTabSheet
|
||||||
|
Caption = 'UsesTabSheet'
|
||||||
|
ClientHeight = 134
|
||||||
|
ClientWidth = 716
|
||||||
|
object UsesStringGrid: TStringGrid
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 129
|
Height = 134
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 589
|
Width = 716
|
||||||
Align = alClient
|
Align = alClient
|
||||||
AutoFillColumns = True
|
AutoFillColumns = True
|
||||||
ColCount = 1
|
ColCount = 1
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Title.Caption = 'Unit'
|
Title.Caption = 'Unit'
|
||||||
Width = 587
|
Width = 714
|
||||||
end>
|
end>
|
||||||
FixedCols = 0
|
FixedCols = 0
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
ColWidths = (
|
ColWidths = (
|
||||||
587
|
714
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object UnitUsedByTabSheet: TTabSheet
|
object UsedByTabSheet: TTabSheet
|
||||||
Caption = 'UnitUsedByTabSheet'
|
Caption = 'UsedByTabSheet'
|
||||||
ClientHeight = 129
|
ClientHeight = 134
|
||||||
ClientWidth = 589
|
ClientWidth = 716
|
||||||
object UnitUsedByStringGrid: TStringGrid
|
object UsedByStringGrid: TStringGrid
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 129
|
Height = 134
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 589
|
Width = 716
|
||||||
Align = alClient
|
Align = alClient
|
||||||
AutoFillColumns = True
|
AutoFillColumns = True
|
||||||
ColCount = 1
|
ColCount = 1
|
||||||
Columns = <
|
Columns = <
|
||||||
item
|
item
|
||||||
Title.Caption = 'Unit'
|
Title.Caption = 'Unit'
|
||||||
Width = 589
|
Width = 714
|
||||||
end>
|
end>
|
||||||
FixedCols = 0
|
FixedCols = 0
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
ColWidths = (
|
ColWidths = (
|
||||||
589
|
714
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
object UsesPathTabSheet: TTabSheet
|
||||||
|
Caption = 'UsesPathTabSheet'
|
||||||
|
ClientHeight = 134
|
||||||
|
ClientWidth = 716
|
||||||
|
object UsesPathStringGrid: TStringGrid
|
||||||
|
Left = 0
|
||||||
|
Height = 134
|
||||||
|
Top = 0
|
||||||
|
Width = 716
|
||||||
|
Align = alClient
|
||||||
|
AutoFillColumns = True
|
||||||
|
ColCount = 1
|
||||||
|
FixedCols = 0
|
||||||
|
FixedRows = 0
|
||||||
|
TabOrder = 0
|
||||||
|
ColWidths = (
|
||||||
|
714
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -82,10 +82,15 @@ type
|
|||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
ScopeLabel: TLabel;
|
ScopeLabel: TLabel;
|
||||||
Splitter1: TSplitter;
|
Splitter1: TSplitter;
|
||||||
UnitUsedByStringGrid: TStringGrid;
|
InfoTabSheet: TTabSheet;
|
||||||
UnitUsesStringGrid: TStringGrid;
|
PPUFileLabel: TLabel;
|
||||||
UnitUsesTabSheet: TTabSheet;
|
SourceFileLabel: TLabel;
|
||||||
UnitUsedByTabSheet: TTabSheet;
|
UsesPathStringGrid: TStringGrid;
|
||||||
|
UsesPathTabSheet: TTabSheet;
|
||||||
|
UsedByStringGrid: TStringGrid;
|
||||||
|
UsesStringGrid: TStringGrid;
|
||||||
|
UsesTabSheet: TTabSheet;
|
||||||
|
UsedByTabSheet: TTabSheet;
|
||||||
UnitGroupBox: TGroupBox;
|
UnitGroupBox: TGroupBox;
|
||||||
UnitPageControl: TPageControl;
|
UnitPageControl: TPageControl;
|
||||||
UnitsStringGrid: TStringGrid;
|
UnitsStringGrid: TStringGrid;
|
||||||
@ -97,6 +102,7 @@ type
|
|||||||
procedure UnitsStringGridSelectCell(Sender: TObject; {%H-}aCol, aRow: Integer;
|
procedure UnitsStringGridSelectCell(Sender: TObject; {%H-}aCol, aRow: Integer;
|
||||||
var {%H-}CanSelect: Boolean);
|
var {%H-}CanSelect: Boolean);
|
||||||
private
|
private
|
||||||
|
FMainItem: TPPUListItem;
|
||||||
FProject: TLazProject;
|
FProject: TLazProject;
|
||||||
FIdleConnected: boolean;
|
FIdleConnected: boolean;
|
||||||
FSearchingItems: TAvgLvlTree; // tree of TPPUListItem sorted for TheUnitName
|
FSearchingItems: TAvgLvlTree; // tree of TPPUListItem sorted for TheUnitName
|
||||||
@ -111,6 +117,7 @@ type
|
|||||||
|
|
||||||
function FindUnit(AnUnitName: string): TPPUListItem;
|
function FindUnit(AnUnitName: string): TPPUListItem;
|
||||||
function FindUnitInList(AnUnitName: string; List: TStrings): integer;
|
function FindUnitInList(AnUnitName: string; List: TStrings): integer;
|
||||||
|
function FindUnitOfListitem(List: TStrings; Index: integer): TPPUListItem;
|
||||||
|
|
||||||
procedure UpdateAll;
|
procedure UpdateAll;
|
||||||
|
|
||||||
@ -120,12 +127,14 @@ type
|
|||||||
|
|
||||||
// units info
|
// units info
|
||||||
procedure FillUnitsInfo(AnUnitName: string);
|
procedure FillUnitsInfo(AnUnitName: string);
|
||||||
|
function FindUsesPath(UsingUnit, UsedUnit: TPPUListItem): TFPList;
|
||||||
|
|
||||||
function DoubleAsPercentage(const d: double): string;
|
function DoubleAsPercentage(const d: double): string;
|
||||||
function BytesToStr(b: int64): string;
|
function BytesToStr(b: int64): string;
|
||||||
public
|
public
|
||||||
property AProject: TLazProject read FProject write SetProject;
|
property AProject: TLazProject read FProject write SetProject;
|
||||||
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
|
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
|
||||||
|
property MainItem: TPPUListItem read FMainItem;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ShowPPUList(Sender: TObject);
|
procedure ShowPPUList(Sender: TObject);
|
||||||
@ -221,9 +230,11 @@ begin
|
|||||||
FSort[2].Category:=plsName;
|
FSort[2].Category:=plsName;
|
||||||
FSort[3].Category:=plsPPUSize;
|
FSort[3].Category:=plsPPUSize;
|
||||||
|
|
||||||
UnitUsesTabSheet.Caption:=crsUses;
|
InfoTabSheet.Caption:=lisCOGeneral;
|
||||||
UnitUsedByTabSheet.Caption:=crsUsedBy;
|
UsesTabSheet.Caption:=crsUses;
|
||||||
|
UsedByTabSheet.Caption:=crsUsedBy;
|
||||||
UnitPageControl.PageIndex:=0;
|
UnitPageControl.PageIndex:=0;
|
||||||
|
UsesPathTabSheet.Caption:=lisCOUsesPath;
|
||||||
|
|
||||||
IDEDialogLayoutList.ApplyLayout(Self);
|
IDEDialogLayoutList.ApplyLayout(Self);
|
||||||
end;
|
end;
|
||||||
@ -295,6 +306,7 @@ procedure TPPUListDialog.SetProject(const AValue: TLazProject);
|
|||||||
begin
|
begin
|
||||||
if FProject=AValue then exit;
|
if FProject=AValue then exit;
|
||||||
FProject:=AValue;
|
FProject:=AValue;
|
||||||
|
FMainItem:=nil;
|
||||||
UpdateAll;
|
UpdateAll;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -308,6 +320,16 @@ begin
|
|||||||
Application.RemoveOnIdleHandler(@OnIdle);
|
Application.RemoveOnIdleHandler(@OnIdle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPPUListDialog.FindUnitOfListitem(List: TStrings; Index: integer
|
||||||
|
): TPPUListItem;
|
||||||
|
begin
|
||||||
|
Result:=TPPUListItem(List.Objects[Index]);
|
||||||
|
if Result<>nil then exit;
|
||||||
|
Result:=FindUnit(List[Index]);
|
||||||
|
if Result<>nil then
|
||||||
|
List.Objects[Index]:=Result;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPPUListDialog.UpdateAll;
|
procedure TPPUListDialog.UpdateAll;
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
@ -334,6 +356,7 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
ScopeLabel.Caption:=Format(crsMainSourceFile, [MainUnit.Filename]);
|
ScopeLabel.Caption:=Format(crsMainSourceFile, [MainUnit.Filename]);
|
||||||
Item:=TPPUListItem.Create;
|
Item:=TPPUListItem.Create;
|
||||||
|
FMainItem:=Item;
|
||||||
Item.TheUnitName:=ExtractFileName(MainUnit.Filename);
|
Item.TheUnitName:=ExtractFileName(MainUnit.Filename);
|
||||||
Item.SrcFile:=MainUnit.Filename;
|
Item.SrcFile:=MainUnit.Filename;
|
||||||
Item.PPUFile:=AProject.LazCompilerOptions.CreatePPUFilename(Item.SrcFile);
|
Item.PPUFile:=AProject.LazCompilerOptions.CreatePPUFilename(Item.SrcFile);
|
||||||
@ -543,6 +566,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
UsesUnitName: string;
|
UsesUnitName: string;
|
||||||
UsedByUnitName: string;
|
UsedByUnitName: string;
|
||||||
|
UsesPath: TFPList;
|
||||||
begin
|
begin
|
||||||
Item:=FindUnit(AnUnitName);
|
Item:=FindUnit(AnUnitName);
|
||||||
if Item=nil then begin
|
if Item=nil then begin
|
||||||
@ -551,26 +575,79 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
UnitGroupBox.Caption:='Unit: '+AnUnitName;
|
UnitGroupBox.Caption:='Unit: '+AnUnitName;
|
||||||
UnitGroupBox.Enabled:=true;
|
UnitGroupBox.Enabled:=true;
|
||||||
|
// info
|
||||||
|
SourceFileLabel.Caption:='Source: '+Item.SrcFile;
|
||||||
|
PPUFileLabel.Caption:='PPU: '+Item.PPUFile;
|
||||||
// uses
|
// uses
|
||||||
if Item.UsesUnits<>nil then begin
|
if Item.UsesUnits<>nil then begin
|
||||||
UnitUsesStringGrid.RowCount:=1+Item.UsesUnits.Count;
|
UsesStringGrid.RowCount:=1+Item.UsesUnits.Count;
|
||||||
for i:=0 to Item.UsesUnits.Count-1 do begin
|
for i:=0 to Item.UsesUnits.Count-1 do begin
|
||||||
UsesUnitName:=Item.UsesUnits[i];
|
UsesUnitName:=Item.UsesUnits[i];
|
||||||
UnitUsesStringGrid.Cells[0,i+1]:=UsesUnitName;
|
UsesStringGrid.Cells[0,i+1]:=UsesUnitName;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
UnitUsesStringGrid.RowCount:=1;
|
UsesStringGrid.RowCount:=1;
|
||||||
end;
|
end;
|
||||||
// used by
|
// used by
|
||||||
if Item.UsedByUnits<>nil then begin
|
if Item.UsedByUnits<>nil then begin
|
||||||
UnitUsedByStringGrid.RowCount:=1+Item.UsedByUnits.Count;
|
UsedByStringGrid.RowCount:=1+Item.UsedByUnits.Count;
|
||||||
for i:=0 to Item.UsedByUnits.Count-1 do begin
|
for i:=0 to Item.UsedByUnits.Count-1 do begin
|
||||||
UsedByUnitName:=Item.UsedByUnits[i];
|
UsedByUnitName:=Item.UsedByUnits[i];
|
||||||
UnitUsedByStringGrid.Cells[0,i+1]:=UsedByUnitName;
|
UsedByStringGrid.Cells[0,i+1]:=UsedByUnitName;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
UnitUsedByStringGrid.RowCount:=1;
|
UsedByStringGrid.RowCount:=1;
|
||||||
end;
|
end;
|
||||||
|
// uses path
|
||||||
|
UsesPath:=FindUsesPath(MainItem,Item);
|
||||||
|
try
|
||||||
|
UsesPathStringGrid.RowCount:=UsesPath.Count;
|
||||||
|
for i:=0 to UsesPath.Count-1 do begin
|
||||||
|
UsesPathStringGrid.Cells[0,i]:=TPPUListItem(UsesPath[i]).TheUnitName;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
UsesPath.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPPUListDialog.FindUsesPath(UsingUnit, UsedUnit: TPPUListItem): TFPList;
|
||||||
|
{ Search a path from UsingUnit to UsedUnit
|
||||||
|
Result is a list of TPPUListItem
|
||||||
|
}
|
||||||
|
var
|
||||||
|
Visited: TAvgLvlTree;
|
||||||
|
|
||||||
|
function Search(Item: TPPUListItem; Path: TFPList): boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
ParentUnit: TPPUListItem;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Visited.Find(Item)<>nil then exit;
|
||||||
|
Visited.Add(Item);
|
||||||
|
if Item.UsedByUnits<>nil then begin
|
||||||
|
for i:=0 to Item.UsedByUnits.Count-1 do begin
|
||||||
|
ParentUnit:=FindUnitOfListitem(Item.UsedByUnits,i);
|
||||||
|
if (ParentUnit=nil) or (Visited.Find(ParentUnit)<>nil) then continue;
|
||||||
|
if (ParentUnit=UsingUnit) or Search(ParentUnit,Path) then begin
|
||||||
|
// path found
|
||||||
|
Path.Add(ParentUnit);
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=TFPList.Create;
|
||||||
|
if (UsingUnit=nil) or (UsedUnit=nil) then exit;
|
||||||
|
Visited:=TAvgLvlTree.Create(@ComparePPUListItems);
|
||||||
|
try
|
||||||
|
if Search(UsedUnit,Result) then
|
||||||
|
Result.Add(UsedUnit);
|
||||||
|
finally
|
||||||
|
Visited.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -700,13 +777,14 @@ begin
|
|||||||
for i:=0 to UsedUnits.Count-1 do begin
|
for i:=0 to UsedUnits.Count-1 do begin
|
||||||
AnUnitName:=UsedUnits[i];
|
AnUnitName:=UsedUnits[i];
|
||||||
//debugln(['TPPUListDialog.AddUses ',SrcItem.TheUnitName,' uses ',AnUnitName]);
|
//debugln(['TPPUListDialog.AddUses ',SrcItem.TheUnitName,' uses ',AnUnitName]);
|
||||||
UsedUnit:=FindUnit(AnUnitName);
|
UsedUnit:=FindUnitOfListitem(UsedUnits,i);
|
||||||
if UsedUnit=nil then begin
|
if UsedUnit=nil then begin
|
||||||
// new unit
|
// new unit
|
||||||
UsedUnit:=TPPUListItem.Create;
|
UsedUnit:=TPPUListItem.Create;
|
||||||
UsedUnit.TheUnitName:=AnUnitName;
|
UsedUnit.TheUnitName:=AnUnitName;
|
||||||
FItems.Add(UsedUnit);
|
FItems.Add(UsedUnit);
|
||||||
FSearchingItems.Add(UsedUnit);
|
FSearchingItems.Add(UsedUnit);
|
||||||
|
UsedUnits.Objects[i]:=UsedUnit;
|
||||||
UsedUnit.UsedByUnits:=TStringList.Create;
|
UsedUnit.UsedByUnits:=TStringList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user