cody: ppu list: show linked files in a treeview

git-svn-id: trunk@30864 -
This commit is contained in:
mattias 2011-05-22 23:02:57 +00:00
parent 70cef5d805
commit 1c5635529c
2 changed files with 343 additions and 210 deletions

View File

@ -28,61 +28,6 @@ object PPUListDialog: TPPUListDialog
TabOrder = 0
ShowButtons = [pbClose, pbHelp]
end
object UnitsStringGrid: TStringGrid
Left = 6
Height = 244
Top = 30
Width = 728
Align = alTop
AutoFillColumns = True
BorderSpacing.Around = 6
ColCount = 6
Columns = <
item
SizePriority = 10
Title.Caption = 'Unit'
Width = 121
end
item
SizePriority = 10
Title.Caption = 'Size of .ppu file'
Width = 121
end
item
SizePriority = 10
Title.Caption = 'Size of .o file'
Width = 121
end
item
SizePriority = 5
Title.Caption = 'Uses'
Width = 121
end
item
SizePriority = 5
Title.Caption = 'Used by'
Width = 121
end
item
Title.Caption = 'Package'
Width = 121
end>
DefaultColWidth = 150
FixedCols = 0
FixedRows = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goThumbTracking, goColSpanning, goDblClickAutoSize, goSmoothScroll]
TabOrder = 1
OnMouseDown = UnitsStringGridMouseDown
OnSelectCell = UnitsStringGridSelectCell
ColWidths = (
121
121
121
121
121
121
)
end
object ScopeLabel: TLabel
Left = 6
Height = 18
@ -93,169 +38,255 @@ object PPUListDialog: TPPUListDialog
Caption = 'ScopeLabel'
ParentColor = False
end
object Splitter1: TSplitter
Cursor = crVSplit
object PageControl1: TPageControl
Left = 0
Height = 5
Top = 280
Height = 447
Top = 30
Width = 740
Align = alTop
ResizeAnchor = akTop
end
object UnitGroupBox: TGroupBox
Left = 6
Height = 186
Top = 291
Width = 728
ActivePage = LinkedFilesTabSheet
Align = alClient
BorderSpacing.Around = 6
Caption = 'UnitGroupBox'
ClientHeight = 165
ClientWidth = 720
TabOrder = 3
object UnitPageControl: TPageControl
Left = 0
Height = 165
Top = 0
Width = 720
ActivePage = LinkedFilesTabSheet
Align = alClient
TabIndex = 4
TabOrder = 0
object InfoTabSheet: TTabSheet
Caption = 'InfoTabSheet'
ClientHeight = 134
ClientWidth = 716
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
TabIndex = 1
TabOrder = 1
object UnitsTabSheet: TTabSheet
Caption = 'UnitsTabSheet'
ClientHeight = 414
ClientWidth = 736
object UnitsStringGrid: TStringGrid
Left = 6
Height = 209
Top = 11
Width = 724
Align = alTop
AutoFillColumns = True
BorderSpacing.Around = 6
ColCount = 6
Columns = <
item
SizePriority = 10
Title.Caption = 'Unit'
Width = 120
end
item
SizePriority = 10
Title.Caption = 'Size of .ppu file'
Width = 120
end
item
SizePriority = 10
Title.Caption = 'Size of .o file'
Width = 120
end
item
SizePriority = 5
Title.Caption = 'Uses'
Width = 120
end
item
SizePriority = 5
Title.Caption = 'Used by'
Width = 120
end
item
Title.Caption = 'Package'
Width = 124
end>
DefaultColWidth = 150
FixedCols = 0
FixedRows = 2
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goThumbTracking, goColSpanning, goDblClickAutoSize, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitsStringGridMouseDown
OnSelectCell = UnitsStringGridSelectCell
ColWidths = (
120
120
120
120
120
124
)
end
object UsesTabSheet: TTabSheet
Caption = 'UsesTabSheet'
ClientHeight = 132
ClientWidth = 716
object UsesStringGrid: TStringGrid
object Splitter1: TSplitter
Cursor = crVSplit
Left = 0
Height = 5
Top = 0
Width = 736
Align = alTop
ResizeAnchor = akTop
end
object UnitGroupBox: TGroupBox
Left = 6
Height = 182
Top = 226
Width = 724
Align = alClient
BorderSpacing.Around = 6
Caption = 'UnitGroupBox'
ClientHeight = 182
ClientWidth = 724
TabOrder = 2
object UnitPageControl: TPageControl
Left = 0
Height = 132
Height = 161
Top = 0
Width = 716
ActivePage = UnitLinkedFilesTabSheet
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 714
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabIndex = 4
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)
object InfoTabSheet: TTabSheet
Caption = 'InfoTabSheet'
ClientHeight = 134
ClientWidth = 716
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 = 132
ClientWidth = 716
object UsesStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 716
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
716
)
end
end
object UsedByTabSheet: TTabSheet
Caption = 'UsedByTabSheet'
ClientHeight = 132
ClientWidth = 716
object UsedByStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 716
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
716
)
end
end
object UsesPathTabSheet: TTabSheet
Caption = 'UsesPathTabSheet'
ClientHeight = 132
ClientWidth = 716
object UsesPathStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 716
end>
FixedCols = 0
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
716
)
end
end
object UnitLinkedFilesTabSheet: TTabSheet
Caption = 'UnitLinkedFilesTabSheet'
ClientHeight = 128
ClientWidth = 712
object UnitLinkedFilesStringGrid: TStringGrid
Left = 0
Height = 128
Top = 0
Width = 712
Align = alClient
AutoFillColumns = True
ColCount = 3
Columns = <
item
Title.Caption = 'Type'
Width = 237
end
item
Title.Caption = 'File'
Width = 237
end
item
Title.Caption = 'Flags'
Width = 238
end>
FixedCols = 0
TabOrder = 0
ColWidths = (
237
237
238
)
end
end
end
end
object UsedByTabSheet: TTabSheet
Caption = 'UsedByTabSheet'
ClientHeight = 132
ClientWidth = 716
object UsedByStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 714
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goThumbTracking, goSmoothScroll]
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)
end
end
object UsesPathTabSheet: TTabSheet
Caption = 'UsesPathTabSheet'
ClientHeight = 132
ClientWidth = 716
object UsesPathStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 1
Columns = <
item
Title.Caption = 'Unit'
Width = 714
end>
FixedCols = 0
TabOrder = 0
OnMouseDown = UnitStringGridMouseDown
ColWidths = (
714
)
end
end
object LinkedFilesTabSheet: TTabSheet
Caption = 'LinkedFilesTabSheet'
ClientHeight = 132
ClientWidth = 716
object UnitLinkedFilesStringGrid: TStringGrid
Left = 0
Height = 132
Top = 0
Width = 716
Align = alClient
AutoFillColumns = True
ColCount = 3
Columns = <
item
Title.Caption = 'Type'
Width = 238
end
item
Title.Caption = 'File'
Width = 238
end
item
Title.Caption = 'Flags'
Width = 238
end>
FixedCols = 0
TabOrder = 0
ColWidths = (
238
238
238
)
end
end
object LinkedFilesTabSheet: TTabSheet
Caption = 'LinkedFilesTabSheet'
ClientHeight = 414
ClientWidth = 736
object LinkedFilesTreeView: TTreeView
Left = 0
Height = 414
Top = 0
Width = 736
Align = alClient
DefaultItemHeight = 19
ReadOnly = True
TabOrder = 0
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end
end
end

View File

@ -85,12 +85,16 @@ type
TPPUListDialog = class(TForm)
ButtonPanel1: TButtonPanel;
LinkedFilesTreeView: TTreeView;
PageControl1: TPageControl;
UnitsTabSheet: TTabSheet;
LinkedFilesTabSheet: TTabSheet;
ScopeLabel: TLabel;
Splitter1: TSplitter;
InfoTabSheet: TTabSheet;
PPUFileLabel: TLabel;
SourceFileLabel: TLabel;
LinkedFilesTabSheet: TTabSheet;
UnitLinkedFilesTabSheet: TTabSheet;
UnitLinkedFilesStringGrid: TStringGrid;
UsesPathStringGrid: TStringGrid;
UsesPathTabSheet: TTabSheet;
@ -118,6 +122,7 @@ type
FSearchingItems: TAvgLvlTree; // tree of TPPUListItem sorted for TheUnitName
FItems: TAvgLvlTree; // tree of TPPUListItem sorted for TheUnitName
FSort: array[1..3] of TPPUListSortRec;
FLinkedFiles: TAvgLvlTree; // tree of TPPULinkedFile sorted for ID, file, flags
procedure SetProject(const AValue: TLazProject);
procedure SetIdleConnected(const AValue: boolean);
@ -132,7 +137,7 @@ type
procedure UpdateAll;
// grid
// units grid
procedure UpdateUnitsGrid;
function CompareUnits({%H-}Tree: TAvgLvlTree; Data1, Data2: Pointer): integer;
procedure JumpToUnit(TheUnitName: string);
@ -141,6 +146,9 @@ type
procedure FillUnitsInfo(AnUnitName: string);
function FindUsesPath(UsingUnit, UsedUnit: TPPUListItem): TFPList;
// linked files
procedure UpdateLinkedFilesTreeView;
function DoubleAsPercentage(const d: double): string;
function BytesToStr(b: int64): string;
public
@ -152,6 +160,7 @@ type
procedure ShowPPUList(Sender: TObject);
function ComparePPUListItems(Item1, Item2: Pointer): integer;
function CompareUnitNameWithPPUListItem(TheUnitName, Item: Pointer): integer;
function ComparePPULinkedFiles(Item1, Item2: Pointer): integer;
implementation
@ -191,6 +200,20 @@ begin
Result:=CompareIdentifiers(un,PChar(li.TheUnitName));
end;
function ComparePPULinkedFiles(Item1, Item2: Pointer): integer;
var
File1: TPPULinkedFile absolute Item1;
File2: TPPULinkedFile absolute Item2;
begin
if File1.ID<File2.ID then exit(1)
else if File1.ID>File2.ID then exit(-1);
Result:=CompareFilenames(File1.Filename,File2.Filename);
if Result<>0 then exit;
if File1.Flags<File2.Flags then exit(1)
else if File1.Flags>File2.Flags then exit(-1);
Result:=0;
end;
{ TPPUListItem }
destructor TPPUListItem.Destroy;
@ -223,10 +246,14 @@ procedure TPPUListDialog.FormCreate(Sender: TObject);
begin
FSearchingItems:=TAvgLvlTree.Create(@ComparePPUListItems);
FItems:=TAvgLvlTree.Create(@ComparePPUListItems);
FLinkedFiles:=TAvgLvlTree.Create(@ComparePPULinkedFiles);
FSort[1].Category:=plsOSize;
FSort[2].Category:=plsName;
FSort[3].Category:=plsPPUSize;
UnitsTabSheet.Caption:='Units';
// UnitsStringGrid header
UnitsStringGrid.Columns[0].Title.Caption:=crsUnit;
UnitsStringGrid.Columns[1].Title.Caption:=crsSizeOfPpuFile;
@ -246,13 +273,15 @@ begin
UsesPathTabSheet.Caption:=lisCOUsesPath;
UsesPathStringGrid.Columns[0].Title.Caption:=crsUnit;
LinkedFilesTabSheet.Caption:=crsLinkedFiles;
UnitLinkedFilesTabSheet.Caption:=crsLinkedFiles;
UnitLinkedFilesStringGrid.Columns[0].Title.Caption:=crsType;
UnitLinkedFilesStringGrid.Columns[1].Title.Caption:=crsFile;
UnitLinkedFilesStringGrid.Columns[2].Title.Caption:=crsFlags;
UnitPageControl.PageIndex:=0;
LinkedFilesTabSheet.Caption:=crsLinkedFiles;
ButtonPanel1.HelpButton.Caption:=crsHelp;
ButtonPanel1.CloseButton.Caption:=crsClose;
@ -264,6 +293,8 @@ begin
FreeAndNil(FSearchingItems);
FItems.FreeAndClear;
FreeAndNil(FItems);
FLinkedFiles.FreeAndClear;
FreeAndNil(FLinkedFiles);
end;
procedure TPPUListDialog.UnitsStringGridMouseDown(Sender: TObject;
@ -806,6 +837,76 @@ begin
end;
end;
procedure TPPUListDialog.UpdateLinkedFilesTreeView;
function GetLinkedFilesCategoryNode(ID: byte): TTreeNode;
var
i: Integer;
begin
for i:=0 to LinkedFilesTreeView.Items.TopLvlCount-1 do begin
Result:=LinkedFilesTreeView.Items.TopLvlItems[i];
if {%H-}PtrUInt(Result.Data)=ID then exit;
end;
Result:=nil;
end;
function CreateCategoryNode(ID: byte): TTreeNode;
begin
Result:=LinkedFilesTreeView.Items.AddObject(nil,PPUEntryName(ID),{%H-}Pointer(ID));
end;
var
Node: TAvgLvlTreeNode;
Item: TPPUListItem;
LinkedFile: TPPULinkedFile;
NewLinkedFile: TPPULinkedFile;
CategoryNode: TTreeNode;
s: String;
i: Integer;
begin
LinkedFilesTreeView.BeginUpdate;
try
LinkedFilesTreeView.Items.Clear;
FLinkedFiles.FreeAndClear;
Node:=FItems.FindLowest;
while Node<>nil do begin
Item:=TPPUListItem(Node.Data);
if Item.LinkedFiles<>nil then begin
for i:=0 to Item.LinkedFiles.Count-1 do begin
LinkedFile:=TPPULinkedFile(Item.LinkedFiles[i]);
if FLinkedFiles.Find(LinkedFile)=nil then begin
NewLinkedFile:=TPPULinkedFile.Create;
NewLinkedFile.ID:=LinkedFile.ID;
NewLinkedFile.Filename:=LinkedFile.Filename;
NewLinkedFile.Flags:=LinkedFile.Flags;
FLinkedFiles.Add(NewLinkedFile);
end;
end;
end;
Node:=FItems.FindSuccessor(Node);
end;
// create category nodes
for i:=iblinkunitofiles to iblinkothersharedlibs do
CreateCategoryNode(i);
CreateCategoryNode(iblinkotherframeworks);
Node:=FLinkedFiles.FindLowest;
while Node<>nil do begin
LinkedFile:=TPPULinkedFile(Node.Data);
CategoryNode:=GetLinkedFilesCategoryNode(LinkedFile.ID);
s:=LinkedFile.Filename+' ['+PPULinkContainerFlagToStr(LinkedFile.Flags)+']';
LinkedFilesTreeView.Items.AddChildObject(CategoryNode,s,LinkedFile);
Node:=FLinkedFiles.FindSuccessor(Node);
end;
finally
LinkedFilesTreeView.EndUpdate;
end;
end;
procedure TPPUListDialog.OnIdle(Sender: TObject; var Done: Boolean);
const
MaxNonIdleTime = (1/86400)/2;
@ -926,6 +1027,7 @@ begin
end;
UpdateUnitsGrid;
UpdateLinkedFilesTreeView;
if FSearchingItems.Count=0 then
IdleConnected:=false;