IDE: orphaned ppu: delete button

git-svn-id: trunk@48092 -
This commit is contained in:
mattias 2015-03-01 22:53:07 +00:00
parent 6399902356
commit aa72b32e77
5 changed files with 369 additions and 73 deletions

View File

@ -343,7 +343,7 @@ end;
destructor TAddFileToAPackageDialog.Destroy; destructor TAddFileToAPackageDialog.Destroy;
begin begin
fPackages.Free; FreeAndNil(fPackages);
inherited Destroy; inherited Destroy;
end; end;

View File

@ -3,19 +3,19 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
Height = 578 Height = 578
Top = 216 Top = 216
Width = 607 Width = 607
ActiveControl = AvailableFilterEdit
BorderStyle = bsSizeToolWin BorderStyle = bsSizeToolWin
Caption = 'InstallPkgSetDialog' Caption = 'InstallPkgSetDialog'
ClientHeight = 578 ClientHeight = 578
ClientWidth = 607 ClientWidth = 607
Constraints.MinHeight = 400 Constraints.MinHeight = 400
Constraints.MinWidth = 450 Constraints.MinWidth = 450
OnClose = FormClose
OnCreate = InstallPkgSetDialogCreate OnCreate = InstallPkgSetDialogCreate
OnDestroy = InstallPkgSetDialogDestroy OnDestroy = InstallPkgSetDialogDestroy
OnResize = InstallPkgSetDialogResize OnResize = InstallPkgSetDialogResize
OnShow = InstallPkgSetDialogShow OnShow = InstallPkgSetDialogShow
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.3' LCLVersion = '1.5'
object InstallPkgGroupBox: TGroupBox object InstallPkgGroupBox: TGroupBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = NoteLabel AnchorSideTop.Control = NoteLabel
@ -23,7 +23,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
AnchorSideRight.Control = lblMiddle AnchorSideRight.Control = lblMiddle
AnchorSideBottom.Control = PkgInfoGroupBox AnchorSideBottom.Control = PkgInfoGroupBox
Left = 6 Left = 6
Height = 373 Height = 378
Top = 27 Top = 27
Width = 294 Width = 294
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -32,13 +32,13 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
BorderSpacing.Right = 3 BorderSpacing.Right = 3
BorderSpacing.Bottom = 6 BorderSpacing.Bottom = 6
Caption = 'InstallPkgGroupBox' Caption = 'InstallPkgGroupBox'
ClientHeight = 354 ClientHeight = 361
ClientWidth = 290 ClientWidth = 290
TabOrder = 0 TabOrder = 0
object ImportButton: TButton object ImportButton: TButton
Left = 6 Left = 6
Height = 25 Height = 25
Top = 292 Top = 299
Width = 278 Width = 278
Align = alBottom Align = alBottom
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -49,7 +49,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
object ExportButton: TButton object ExportButton: TButton
Left = 6 Left = 6
Height = 25 Height = 25
Top = 323 Top = 330
Width = 278 Width = 278
Align = alBottom Align = alBottom
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -61,7 +61,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
AnchorSideTop.Control = InstalledFilterEdit AnchorSideTop.Control = InstalledFilterEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 8 Left = 8
Height = 227 Height = 234
Top = 28 Top = 28
Width = 278 Width = 278
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -81,7 +81,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
object UninstallButton: TBitBtn object UninstallButton: TBitBtn
Left = 6 Left = 6
Height = 25 Height = 25
Top = 261 Top = 268
Width = 278 Width = 278
Align = alBottom Align = alBottom
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -92,7 +92,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
object InstalledFilterEdit: TTreeFilterEdit object InstalledFilterEdit: TTreeFilterEdit
AnchorSideTop.Control = InstallPkgGroupBox AnchorSideTop.Control = InstallPkgGroupBox
Left = 8 Left = 8
Height = 28 Height = 25
Top = 3 Top = 3
Width = 276 Width = 276
ButtonWidth = 23 ButtonWidth = 23
@ -115,7 +115,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = PkgInfoGroupBox AnchorSideBottom.Control = PkgInfoGroupBox
Left = 306 Left = 306
Height = 373 Height = 378
Top = 27 Top = 27
Width = 295 Width = 295
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -124,14 +124,14 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
BorderSpacing.Right = 6 BorderSpacing.Right = 6
BorderSpacing.Bottom = 6 BorderSpacing.Bottom = 6
Caption = 'AvailablePkgGroupBox' Caption = 'AvailablePkgGroupBox'
ClientHeight = 354 ClientHeight = 361
ClientWidth = 291 ClientWidth = 291
TabOrder = 1 TabOrder = 1
object AvailableTreeView: TTreeView object AvailableTreeView: TTreeView
AnchorSideTop.Control = AvailableFilterEdit AnchorSideTop.Control = AvailableFilterEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 289 Height = 296
Top = 28 Top = 28
Width = 279 Width = 279
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -154,7 +154,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
object AddToInstallButton: TBitBtn object AddToInstallButton: TBitBtn
Left = 6 Left = 6
Height = 25 Height = 25
Top = 323 Top = 330
Width = 279 Width = 279
Align = alBottom Align = alBottom
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -165,7 +165,7 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
object AvailableFilterEdit: TTreeFilterEdit object AvailableFilterEdit: TTreeFilterEdit
AnchorSideTop.Control = AvailablePkgGroupBox AnchorSideTop.Control = AvailablePkgGroupBox
Left = 6 Left = 6
Height = 28 Height = 25
Top = 3 Top = 3
Width = 279 Width = 279
ButtonWidth = 23 ButtonWidth = 23
@ -183,16 +183,16 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
AnchorSideBottom.Control = BtnPanel AnchorSideBottom.Control = BtnPanel
Left = 0 Left = 0
Height = 127 Height = 127
Top = 406 Top = 411
Width = 607 Width = 607
Align = alBottom Align = alBottom
Caption = 'PkgInfoGroupBox' Caption = 'PkgInfoGroupBox'
ClientHeight = 108 ClientHeight = 110
ClientWidth = 603 ClientWidth = 603
TabOrder = 2 TabOrder = 2
object PkgInfoMemo: TMemo object PkgInfoMemo: TMemo
Left = 6 Left = 6
Height = 96 Height = 98
Top = 6 Top = 6
Width = 591 Width = 591
Align = alClient Align = alClient
@ -204,20 +204,20 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
end end
object BtnPanel: TPanel object BtnPanel: TPanel
Left = 0 Left = 0
Height = 45 Height = 40
Top = 533 Top = 538
Width = 607 Width = 607
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 45 ClientHeight = 40
ClientWidth = 607 ClientWidth = 607
TabOrder = 3 TabOrder = 3
object HelpButton: TBitBtn object HelpButton: TBitBtn
Left = 6 Left = 6
Height = 33 Height = 28
Top = 6 Top = 6
Width = 76 Width = 75
Align = alLeft Align = alLeft
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -228,10 +228,10 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
TabOrder = 0 TabOrder = 0
end end
object CancelButton: TBitBtn object CancelButton: TBitBtn
Left = 156 Left = 215
Height = 33 Height = 28
Top = 6 Top = 6
Width = 90 Width = 75
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -243,10 +243,10 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
TabOrder = 1 TabOrder = 1
end end
object SaveAndExitButton: TBitBtn object SaveAndExitButton: TBitBtn
Left = 441 Left = 462
Height = 33 Height = 28
Top = 6 Top = 6
Width = 160 Width = 139
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -292,10 +292,10 @@ object InstallPkgSetDialog: TInstallPkgSetDialog
TabOrder = 3 TabOrder = 3
end end
object SaveAndRebuildButton: TBitBtn object SaveAndRebuildButton: TBitBtn
Left = 252 Left = 296
Height = 33 Height = 28
Top = 6 Top = 6
Width = 183 Width = 160
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6

View File

@ -41,9 +41,9 @@ uses
KeywordFuncLists, BasicCodeTools, StdCtrls, Buttons, FileUtil, ExtCtrls, KeywordFuncLists, BasicCodeTools, StdCtrls, Buttons, FileUtil, ExtCtrls,
ComCtrls, EditBtn, LCLType, ImgList, AvgLvlTree, Laz2_XMLCfg, LazUTF8, ComCtrls, EditBtn, LCLType, ImgList, AvgLvlTree, Laz2_XMLCfg, LazUTF8,
LazFileUtils, TreeFilterEdit, PackageIntf, IDEImagesIntf, IDEHelpIntf, LazFileUtils, TreeFilterEdit, PackageIntf, IDEImagesIntf, IDEHelpIntf,
IDEDialogs, LazarusIDEStrConsts, EnvironmentOpts, InputHistory, LazConf, IDEDialogs, IDEWindowIntf, LazarusIDEStrConsts, EnvironmentOpts, InputHistory,
IDEProcs, PackageDefs, PackageSystem, PackageLinks, IDEContextHelpEdit, LazConf, IDEProcs, PackageDefs, PackageSystem, PackageLinks,
LPKCache; IDEContextHelpEdit, LPKCache;
type type
TOnCheckInstallPackageList = TOnCheckInstallPackageList =
@ -75,6 +75,7 @@ type
procedure AddToInstallButtonClick(Sender: TObject); procedure AddToInstallButtonClick(Sender: TObject);
function FilterEditGetImageIndex(Str: String; Data: TObject; function FilterEditGetImageIndex(Str: String; Data: TObject;
var AIsEnabled: Boolean): Integer; var AIsEnabled: Boolean): Integer;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure InstallTreeViewKeyPress(Sender: TObject; var Key: char); procedure InstallTreeViewKeyPress(Sender: TObject; var Key: char);
procedure LPKParsingTimerTimer(Sender: TObject); procedure LPKParsingTimerTimer(Sender: TObject);
procedure OnAllLPKParsed(Sender: TObject); procedure OnAllLPKParsed(Sender: TObject);
@ -185,6 +186,8 @@ end;
procedure TInstallPkgSetDialog.InstallPkgSetDialogCreate(Sender: TObject); procedure TInstallPkgSetDialog.InstallPkgSetDialogCreate(Sender: TObject);
begin begin
IDEDialogLayoutList.ApplyLayout(Self,Width,Height);
InstallTreeView.Images := IDEImages.Images_16; InstallTreeView.Images := IDEImages.Images_16;
AvailableTreeView.Images := IDEImages.Images_16; AvailableTreeView.Images := IDEImages.Images_16;
ImgIndexPackage := IDEImages.LoadImage(16, 'item_package'); ImgIndexPackage := IDEImages.LoadImage(16, 'item_package');
@ -319,6 +322,12 @@ begin
Result:=0; Result:=0;
end; end;
procedure TInstallPkgSetDialog.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TInstallPkgSetDialog.InstallTreeViewKeyPress(Sender: TObject; var Key: char); procedure TInstallPkgSetDialog.InstallTreeViewKeyPress(Sender: TObject; var Key: char);
begin begin
if Key = char(VK_RETURN) then if Key = char(VK_RETURN) then

View File

@ -5,6 +5,8 @@ object PGIPConflictsDialog: TPGIPConflictsDialog
Width = 469 Width = 469
ClientHeight = 424 ClientHeight = 424
ClientWidth = 469 ClientWidth = 469
OnClose = FormClose
OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.5' LCLVersion = '1.5'
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
@ -33,10 +35,16 @@ object PGIPConflictsDialog: TPGIPConflictsDialog
DefaultItemHeight = 18 DefaultItemHeight = 18
ReadOnly = True ReadOnly = True
TabOrder = 1 TabOrder = 1
OnAdvancedCustomDrawItem = ConflictsTreeViewAdvancedCustomDrawItem
OnMouseDown = ConflictsTreeViewMouseDown
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
end end
object IDEDialogLayoutStorage1: TIDEDialogLayoutStorage object IDEDialogLayoutStorage1: TIDEDialogLayoutStorage
left = 161 left = 161
top = 104 top = 104
end end
object ImageList1: TImageList
left = 290
top = 104
end
end end

View File

@ -25,9 +25,10 @@
Check source files and compiled files for name conflicts between packages. Check source files and compiled files for name conflicts between packages.
ToDo: ToDo:
- allow to delete ppu files - don't check when building clean
- save ignore - save ignore date for ?
- ignore - ignore
- clear ignore date on clean build
} }
unit InterPkgConflictFiles; unit InterPkgConflictFiles;
@ -36,14 +37,14 @@ unit InterPkgConflictFiles;
interface interface
uses uses
Classes, SysUtils, contnrs, InterfaceBase, Forms, ComCtrls, Classes, SysUtils, types, math, contnrs, InterfaceBase, Forms, ComCtrls,
Controls, ButtonPanel, FileProcs, LazFileUtils, AvgLvlTree, BasicCodeTools, Controls, ButtonPanel, Themes, Graphics, StdCtrls, Buttons, FileProcs,
DefineTemplates, CodeToolManager, LazFileUtils, AvgLvlTree, BasicCodeTools, DefineTemplates, CodeToolManager,
// IDEIntf // IDEIntf
ProjectIntf, CompOptsIntf, IDEWindowIntf, LazIDEIntf, ProjectIntf, CompOptsIntf, IDEWindowIntf, LazIDEIntf, IDEImagesIntf,
// IDE // IDE
LazarusIDEStrConsts, CompilerOptions, EnvironmentOpts, IDEProcs, LazarusIDEStrConsts, CompilerOptions, EnvironmentOpts, IDEProcs, DialogProcs,
TransferMacros, LazConf, IDECmdLine, PackageDefs, PackageSystem; TransferMacros, LazConf, IDECmdLine, PackageDefs, PackageSystem, InputHistory;
type type
TPGInterPkgOwnerInfo = class TPGInterPkgOwnerInfo = class
@ -95,6 +96,23 @@ type
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
ConflictsTreeView: TTreeView; ConflictsTreeView: TTreeView;
IDEDialogLayoutStorage1: TIDEDialogLayoutStorage; IDEDialogLayoutStorage1: TIDEDialogLayoutStorage;
ImageList1: TImageList;
procedure ConflictsTreeViewAdvancedCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage;
var PaintImages, DefaultDraw: Boolean);
procedure ConflictsTreeViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure DeleteSelectedFilesButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
private
DeleteSelectedFilesButton: TButton;
FImgIndexChecked: integer;
FImgIndexUnchecked: integer;
procedure UpdateButtons;
procedure IgnoreConflicts;
procedure IgnoreConflict(AmbFile: TPGIPAmbiguousFile);
public public
SrcFiles: TObjectList; // list of TPGIPAmbiguousFile SrcFiles: TObjectList; // list of TPGIPAmbiguousFile
CompiledFiles: TObjectList; // list of TPGIPAmbiguousCompiledFile CompiledFiles: TObjectList; // list of TPGIPAmbiguousCompiledFile
@ -155,6 +173,244 @@ begin
o:=OwnerInfo; OwnerInfo:=ConflictOwner; ConflictOwner:=o; o:=OwnerInfo; OwnerInfo:=ConflictOwner; ConflictOwner:=o;
end; end;
{ TPGIPConflictsDialog }
procedure TPGIPConflictsDialog.ConflictsTreeViewAdvancedCustomDrawItem(
Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState;
Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean);
var
Detail: TThemedButton;
Details: TThemedElementDetails;
aSize: TSize;
NodeRect: Classes.TRect;
r: TRect;
begin
if Stage<>cdPostPaint then exit;
if TObject(Node.Data) is TPGIPAmbiguousFile then begin
if Node.ImageIndex=FImgIndexChecked then
Detail := tbCheckBoxCheckedNormal
else
Detail := tbCheckBoxUncheckedNormal;
Details := ThemeServices.GetElementDetails(Detail);
aSize := ThemeServices.GetDetailSize(Details);
NodeRect:=Node.DisplayRect(false);
r:=Bounds(Node.DisplayIconLeft+(ImageList1.Width-aSize.cx) div 2,
NodeRect.Top+(NodeRect.Bottom-NodeRect.Top-aSize.cy) div 2,
aSize.cx,aSize.cy);
ThemeServices.DrawElement(ConflictsTreeView.Canvas.Handle,Details,r);
end;
end;
procedure TPGIPConflictsDialog.ConflictsTreeViewMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Node: TTreeNode;
begin
Node:=ConflictsTreeView.GetNodeAt(X,Y);
if Node=nil then exit;
if TObject(Node.Data) is TPGIPAmbiguousFile then begin
if (X>=Node.DisplayIconLeft) and (X<Node.DisplayTextLeft) then begin
if Node.ImageIndex=FImgIndexChecked then
Node.ImageIndex:=FImgIndexUnchecked
else
Node.ImageIndex:=FImgIndexChecked;
Node.SelectedIndex:=Node.ImageIndex;
UpdateButtons;
end;
end;
end;
procedure TPGIPConflictsDialog.DeleteSelectedFilesButtonClick(Sender: TObject);
function DeleteFileGroup(aFilename: string): boolean;
begin
{$IFDEF VerboseCheckInterPkgFiles}
debugln(['DeleteFileGroup ',aFilename]);
{$ENDIF}
if DeleteFileInteractive(aFilename)<>mrOk then exit(false);
if FilenameIsPascalUnit(aFilename) then
begin
DeleteFileUTF8(ChangeFileExt(aFilename,'.ppu'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.o'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.rst'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.rsj'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.lfm'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.dfm'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.xfm'));
end else if (CompareFileExt(aFilename,'ppu')=0)
or (CompareFileExt(aFilename,'o')=0) then begin
DeleteFileUTF8(ChangeFileExt(aFilename,'.ppu'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.o'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.rst'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.rsj'));
if FileExistsCached(ChangeFileExt(aFilename,'.pas'))
or FileExistsCached(ChangeFileExt(aFilename,'.pp'))
or FileExistsCached(ChangeFileExt(aFilename,'.p')) then begin
// delete only compiled file
end else begin
// no source in this directory => delete copied lfm file
DeleteFileUTF8(ChangeFileExt(aFilename,'.lfm'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.dfm'));
DeleteFileUTF8(ChangeFileExt(aFilename,'.xfm'));
end;
end;
Result:=true;
end;
var
Node: TTreeNode;
AmbFile: TPGIPAmbiguousFile;
LastAmbFile: TPGIPAmbiguousFile;
NextNode: TTreeNode;
DeleteFile1: Boolean;
DeleteFile2: Boolean;
begin
ConflictsTreeView.Items.BeginUpdate;
try
Node:=ConflictsTreeView.Items.GetFirstNode;
LastAmbFile:=nil;
while Node<>nil do
begin
NextNode:=Node.GetNext;
if TObject(Node.Data) is TPGIPAmbiguousFile then
begin
AmbFile:=TPGIPAmbiguousFile(Node.Data);
{$IFDEF VerboseCheckInterPkgFiles}
debugln(['TPGIPConflictsDialog.DeleteSelectedFilesButtonClick ',Node.Text,' File=',AmbFile.Filename]);
{$ENDIF}
if AmbFile<>LastAmbFile then
begin
DeleteFile1:=Node.ImageIndex=FImgIndexChecked;
DeleteFile2:=false;
end else begin
DeleteFile2:=Node.ImageIndex=FImgIndexChecked;
{$IFDEF VerboseCheckInterPkgFiles}
debugln(['TPGIPConflictsDialog.DeleteSelectedFilesButtonClick Delete 1=',DeleteFile1,' 2=',DeleteFile2]);
{$ENDIF}
if DeleteFile1 then
if not DeleteFileGroup(AmbFile.Filename) then exit;
if DeleteFile2 then
if not DeleteFileGroup(AmbFile.ConflictFilename) then exit;
if not FileExistsUTF8(AmbFile.Filename)
or not FileExistsUTF8(AmbFile.ConflictFilename) then begin
// conflict does not exist anymore
FilesChanged:=true;
Node:=Node.Parent;
NextNode:=Node.GetNextSkipChildren;
Node.Delete;
end;
end;
LastAmbFile:=AmbFile;
end;
Node:=NextNode;
end;
finally
ConflictsTreeView.Items.EndUpdate;
UpdateButtons;
end;
end;
procedure TPGIPConflictsDialog.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TPGIPConflictsDialog.FormCreate(Sender: TObject);
var
Details: TThemedElementDetails;
aSize: TSize;
Img: TBitmap;
begin
IDEDialogLayoutList.ApplyLayout(Self,Width,Height);
DeleteSelectedFilesButton:=TButton.Create(Self);
with DeleteSelectedFilesButton do
begin
Name:='DeleteSelectedFilesButton';
Caption:='Delete selected files';
Align:=alLeft;
AutoSize:=true;
OnClick:=@DeleteSelectedFilesButtonClick;
Parent:=ButtonPanel1;
end;
ButtonPanel1.OKButton.Kind:=bkIgnore;
ButtonPanel1.OKButton.Caption:='Ignore';
ButtonPanel1.OKButton.OnClick:=@OkButtonClick;
Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
aSize := ThemeServices.GetDetailSize(Details);
ImageList1.Width:=Max(16,aSize.cx);
ImageList1.Height:=Max(16,aSize.cy);
// add empty images
Img:=TBitmap.Create;
Img.TransparentMode:=tmFixed;
Img.TransparentColor:=0;
Img.Transparent:=true;
Img.SetSize(ImageList1.Width,ImageList1.Height);
FImgIndexChecked:=ImageList1.Add(Img,nil);
FImgIndexUnchecked:=ImageList1.Add(Img,nil);
Img.Free;
end;
procedure TPGIPConflictsDialog.OkButtonClick(Sender: TObject);
begin
IgnoreConflicts;
end;
procedure TPGIPConflictsDialog.UpdateButtons;
var
Node: TTreeNode;
DeleteCount: Integer;
ConflictCount: Integer;
begin
DeleteCount:=0;
ConflictCount:=0;
Node:=ConflictsTreeView.Items.GetFirstNode;
while Node<>nil do begin
if TObject(Node.Data) is TPGIPAmbiguousFile then
begin
inc(ConflictCount);
if Node.ImageIndex=FImgIndexChecked then
inc(DeleteCount);
end;
Node:=Node.GetNext;
end;
DeleteSelectedFilesButton.Enabled:=DeleteCount>0;
if ConflictCount=0 then
IgnoreConflicts;
end;
procedure TPGIPConflictsDialog.IgnoreConflicts;
var
Node: TTreeNode;
AmbFile: TPGIPAmbiguousFile;
LastAmbFile: TPGIPAmbiguousFile;
begin
Node:=ConflictsTreeView.Items.GetFirstNode;
LastAmbFile:=nil;
while Node<>nil do begin
if TObject(Node.Data) is TPGIPAmbiguousFile then
begin
AmbFile:=TPGIPAmbiguousFile(Node.Data);
if AmbFile<>LastAmbFile then begin
IgnoreConflict(AmbFile);
end;
LastAmbFile:=AmbFile;
end;
Node:=Node.GetNext;
end;
ModalResult:=mrOk;
end;
procedure TPGIPConflictsDialog.IgnoreConflict(AmbFile: TPGIPAmbiguousFile);
begin
//InputHistories.Ignores.Add(Identifier);
end;
procedure TPGIPConflictsDialog.Init(TheSrcFiles, TheCompiledFiles: TObjectList); procedure TPGIPConflictsDialog.Init(TheSrcFiles, TheCompiledFiles: TObjectList);
function AddChild(ParentNode: TTreeNode; Caption: string): TTreeNode; function AddChild(ParentNode: TTreeNode; Caption: string): TTreeNode;
@ -165,56 +421,79 @@ procedure TPGIPConflictsDialog.Init(TheSrcFiles, TheCompiledFiles: TObjectList);
var var
MainNode: TTreeNode; MainNode: TTreeNode;
i: Integer; i: Integer;
CurFile: TPGIPAmbiguousCompiledFile; AmbFile: TPGIPAmbiguousCompiledFile;
ItemNode: TTreeNode; ItemNode: TTreeNode;
s: String; s: String;
ConflictNode: TTreeNode;
begin begin
SrcFiles:=TheSrcFiles; SrcFiles:=TheSrcFiles;
CompiledFiles:=TheCompiledFiles; CompiledFiles:=TheCompiledFiles;
ConflictsTreeView.Items.BeginUpdate; ConflictsTreeView.Items.BeginUpdate;
ConflictsTreeView.Items.Clear; ConflictsTreeView.Items.Clear;
ConflictsTreeView.Images:=ImageList1;
if CompiledFiles.Count>0 then if CompiledFiles.Count>0 then
begin begin
MainNode:=ConflictsTreeView.Items.Add(nil,'Conflicting compiled files'); MainNode:=ConflictsTreeView.Items.Add(nil,'Conflicting compiled files');
for i:=0 to CompiledFiles.Count-1 do for i:=0 to CompiledFiles.Count-1 do
begin begin
CurFile:=TPGIPAmbiguousCompiledFile(CompiledFiles[i]); AmbFile:=TPGIPAmbiguousCompiledFile(CompiledFiles[i]);
s:=ExtractFilename(CurFile.Filename); s:=ExtractFilename(AmbFile.Filename);
// file owner ConflictNode:=AddChild(MainNode,s);
if CurFile.OwnerInfo.Owner is TLazPackage then begin
s+=' of package '+CurFile.OwnerInfo.Name // first file
else s:=ExtractFilename(AmbFile.Filename);
s+=' of '+CurFile.OwnerInfo.Name; if AmbFile.OwnerInfo.Owner is TLazPackage then
ItemNode:=AddChild(MainNode,s); s+=' of package '+AmbFile.OwnerInfo.Name
// file path and src
AddChild(ItemNode,'File: '+CurFile.Filename);
if CurFile.SrcFilename='' then
s:='No source found'
else
s:='Source file: '+CurFile.SrcFilename;
AddChild(ItemNode,s);
// conflict file owner
if CurFile.ConflictOwner.Owner is TLazPackage then
s:='Conflict Package: '+CurFile.ConflictOwner.Name
else
s:=CurFile.ConflictOwner.Name;
AddChild(ItemNode,s);
// conflict file path
AddChild(ItemNode,'Conflict File: '+CurFile.ConflictFilename);
if not FilenameIsPascalSource(CurFile.ConflictFilename) then begin
if CurFile.ConflictSrcFilename='' then
s:='No source found'
else else
s:='Source file: '+CurFile.ConflictSrcFilename; s+=' of '+AmbFile.OwnerInfo.Name;
AddChild(ItemNode,s); ItemNode:=AddChild(ConflictNode,s);
ItemNode.ImageIndex:=FImgIndexChecked; // default: delete
ItemNode.Data:=AmbFile;
begin
// file path and src
AddChild(ItemNode,'File: '+AmbFile.Filename);
if not FilenameIsPascalSource(AmbFile.Filename) then begin
if AmbFile.SrcFilename='' then
s:='No source found'
else
s:='Source file: '+AmbFile.SrcFilename;
AddChild(ItemNode,s);
end;
end;
ItemNode.SelectedIndex:=ItemNode.ImageIndex;
// conflict file owner
s:=ExtractFilename(AmbFile.ConflictFilename);
if AmbFile.ConflictOwner.Owner is TLazPackage then
s+=' of package '+AmbFile.ConflictOwner.Name
else
s+=' of '+AmbFile.ConflictOwner.Name;
ItemNode:=AddChild(ConflictNode,s);
ItemNode.ImageIndex:=FImgIndexUnchecked; // default: keep
ItemNode.Data:=AmbFile;
begin
// file path
AddChild(ItemNode,'File: '+AmbFile.ConflictFilename);
if not FilenameIsPascalSource(AmbFile.ConflictFilename) then begin
if AmbFile.ConflictSrcFilename='' then begin
s:='No source found';
ItemNode.ImageIndex:=FImgIndexChecked; // default: delete
end
else
s:='Source file: '+AmbFile.ConflictSrcFilename;
AddChild(ItemNode,s);
end;
end;
ItemNode.SelectedIndex:=ItemNode.ImageIndex;
end; end;
end; end;
MainNode.Expand(true); MainNode.Expand(true);
end; end;
ConflictsTreeView.Items.EndUpdate; ConflictsTreeView.Items.EndUpdate;
UpdateButtons;
end; end;
{ TPGInterPkgFile } { TPGInterPkgFile }