mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 08:41:42 +01:00 
			
		
		
		
	IDE: package editor: move files: find res files
git-svn-id: trunk@45483 -
This commit is contained in:
		
							parent
							
								
									3e8a908c47
								
							
						
					
					
						commit
						791dda33f3
					
				| @ -194,6 +194,7 @@ type | |||||||
|   public |   public | ||||||
|     function GetString(const Name: string; out Value: string): boolean; |     function GetString(const Name: string; out Value: string): boolean; | ||||||
|     procedure Add(const Name, Value: string); virtual; |     procedure Add(const Name, Value: string); virtual; | ||||||
|  |     procedure AddNames(List: TStrings); | ||||||
|     property Strings[const s: string]: string read GetStrings write SetStrings; default; |     property Strings[const s: string]: string read GetStrings write SetStrings; default; | ||||||
|     function GetNodeData(AVLNode: TAVLTreeNode): PStringToStringTreeItem; inline; |     function GetNodeData(AVLNode: TAVLTreeNode): PStringToStringTreeItem; inline; | ||||||
|     function AsText: string; |     function AsText: string; | ||||||
| @ -1055,6 +1056,19 @@ begin | |||||||
|   Strings[Name]:=Value; |   Strings[Name]:=Value; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | procedure TStringToStringTree.AddNames(List: TStrings); | ||||||
|  | var | ||||||
|  |   i: Integer; | ||||||
|  |   aName: String; | ||||||
|  | begin | ||||||
|  |   if List=nil then exit; | ||||||
|  |   for i:=0 to List.Count-1 do begin | ||||||
|  |     aName:=List[i]; | ||||||
|  |     if not Contains(aName) then | ||||||
|  |       Strings[aName]:=''; | ||||||
|  |   end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| function TStringToStringTree.GetNodeData(AVLNode: TAVLTreeNode | function TStringToStringTree.GetNodeData(AVLNode: TAVLTreeNode | ||||||
|   ): PStringToStringTreeItem; |   ): PStringToStringTreeItem; | ||||||
| begin | begin | ||||||
|  | |||||||
| @ -45,7 +45,7 @@ uses | |||||||
|   // codetools |   // codetools | ||||||
|   CodeAtom, CodeTree, CodeToolManager, FindDeclarationTool, BasicCodeTools, |   CodeAtom, CodeTree, CodeToolManager, FindDeclarationTool, BasicCodeTools, | ||||||
|   KeywordFuncLists, PascalParserTool, CodeCache, CacheCodeTools, CustomCodeTool, |   KeywordFuncLists, PascalParserTool, CodeCache, CacheCodeTools, CustomCodeTool, | ||||||
|   FileProcs, CTXMLFixFragment, DefineTemplates, |   FileProcs, CTXMLFixFragment, DefineTemplates, CodeToolsStructs, | ||||||
|   // synedit |   // synedit | ||||||
|   SynHighlighterPas, |   SynHighlighterPas, | ||||||
|   // IDEIntf |   // IDEIntf | ||||||
| @ -270,9 +270,9 @@ type | |||||||
|                                     ResolveIncludeFiles: Boolean; |                                     ResolveIncludeFiles: Boolean; | ||||||
|                                     out CacheWasUsed: boolean; |                                     out CacheWasUsed: boolean; | ||||||
|                                     CreateIfNotExists: boolean = false): string; |                                     CreateIfNotExists: boolean = false): string; | ||||||
|     procedure GetFPDocFilenamesForSources(SrcFilenames: TStringToStringTree; |     procedure GetFPDocFilenamesForSources(SrcFilenames: TFilenameToStringTree; | ||||||
|                       ResolveIncludeFiles: boolean; |                       ResolveIncludeFiles: boolean; | ||||||
|                       var FPDocFilenames: TStringToStringTree // Names=Filename, Values=ModuleName |                       var FPDocFilenames: TFilenameToStringTree // Filename to ModuleName | ||||||
|                       ); |                       ); | ||||||
|     function GetIDESrcFPDocPath: string; // $(LazarusDir)/docs/xml/ide/ |     function GetIDESrcFPDocPath: string; // $(LazarusDir)/docs/xml/ide/ | ||||||
|     function IsIDESrcFile(const SrcFilename: string): boolean; |     function IsIDESrcFile(const SrcFilename: string): boolean; | ||||||
| @ -1177,9 +1177,9 @@ var | |||||||
|   BaseDir: String; |   BaseDir: String; | ||||||
|   Code: TCodeBuffer; |   Code: TCodeBuffer; | ||||||
|   CurUnitName: String; |   CurUnitName: String; | ||||||
|   AVLNode: TAvgLvlTreeNode; |  | ||||||
|   UnitSet: TFPCUnitSetCache; |   UnitSet: TFPCUnitSetCache; | ||||||
|   IsInFPCSrc: Boolean; |   IsInFPCSrc: Boolean; | ||||||
|  |   AVLNode: TAvgLvlTreeNode; | ||||||
| begin | begin | ||||||
|   Result:=''; |   Result:=''; | ||||||
|   NewOwner:=nil; |   NewOwner:=nil; | ||||||
| @ -1767,29 +1767,25 @@ begin | |||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| procedure TCodeHelpManager.GetFPDocFilenamesForSources( | procedure TCodeHelpManager.GetFPDocFilenamesForSources( | ||||||
|   SrcFilenames: TStringToStringTree; ResolveIncludeFiles: boolean; |   SrcFilenames: TFilenameToStringTree; ResolveIncludeFiles: boolean; | ||||||
|   var FPDocFilenames: TStringToStringTree); |   var FPDocFilenames: TFilenameToStringTree); | ||||||
| var | var | ||||||
|   Node: TAvgLvlTreeNode; |  | ||||||
|   Item: PStringToStringItem; |  | ||||||
|   SrcFilename: String; |   SrcFilename: String; | ||||||
|   CacheWasUsed: boolean; |   CacheWasUsed: boolean; | ||||||
|   AnOwner: TObject; |   AnOwner: TObject; | ||||||
|   FPDocFilename: String; |   FPDocFilename: String; | ||||||
|  |   S2SItem: PStringToStringTreeItem; | ||||||
| begin | begin | ||||||
|   Node:=SrcFilenames.Tree.FindLowest; |   for S2SItem in SrcFilenames do begin | ||||||
|   while Node<>nil do begin |     SrcFilename:=S2SItem^.Name; | ||||||
|     Item:=PStringToStringItem(Node.Data); |  | ||||||
|     SrcFilename:=Item^.Name; |  | ||||||
|     FPDocFilename:=GetFPDocFilenameForSource(SrcFilename,ResolveIncludeFiles, |     FPDocFilename:=GetFPDocFilenameForSource(SrcFilename,ResolveIncludeFiles, | ||||||
|                                              CacheWasUsed,AnOwner); |                                              CacheWasUsed,AnOwner); | ||||||
|     //DebugLn(['TCodeHelpManager.GetFPDocFilenamesForSources FPDoc=',FPDocFilename,' Src=',SrcFilename]); |     //DebugLn(['TCodeHelpManager.GetFPDocFilenamesForSources FPDoc=',FPDocFilename,' Src=',SrcFilename]); | ||||||
|     if FPDocFilename<>'' then begin |     if FPDocFilename<>'' then begin | ||||||
|       if FPDocFilenames=nil then |       if FPDocFilenames=nil then | ||||||
|         FPDocFilenames:=CreateFilenameToStringTree; |         FPDocFilenames:=TFilenameToStringTree.Create(false); | ||||||
|       FPDocFilenames[FPDocFilename]:=GetModuleOwnerName(AnOwner); |       FPDocFilenames[FPDocFilename]:=GetModuleOwnerName(AnOwner); | ||||||
|     end; |     end; | ||||||
|     Node:=SrcFilenames.Tree.FindSuccessor(Node); |  | ||||||
|   end; |   end; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ uses | |||||||
|   laz2_DOM, |   laz2_DOM, | ||||||
|   // codetools |   // codetools | ||||||
|   FileProcs, AVL_Tree, CTUnitGraph, CodeTree, CodeCache, |   FileProcs, AVL_Tree, CTUnitGraph, CodeTree, CodeCache, | ||||||
|   CodeToolManager, |   CodeToolManager, CodeToolsStructs, | ||||||
|   // IDE |   // IDE | ||||||
|   LazarusIDEStrConsts, IDEProcs, IDEWindowIntf, MiscOptions, DialogProcs, |   LazarusIDEStrConsts, IDEProcs, IDEWindowIntf, MiscOptions, DialogProcs, | ||||||
|   LazIDEIntf, IDEDialogs, InputHistory, SearchResultView, CodeHelp, ButtonPanel; |   LazIDEIntf, IDEDialogs, InputHistory, SearchResultView, CodeHelp, ButtonPanel; | ||||||
| @ -365,14 +365,13 @@ function GatherFPDocReferencesForPascalFiles(PascalFiles: TStringList; | |||||||
|   DeclarationCode: TCodeBuffer; const DeclarationCaretXY: TPoint; |   DeclarationCode: TCodeBuffer; const DeclarationCaretXY: TPoint; | ||||||
|   var ListOfLazFPDocNode: TFPList): TModalResult; |   var ListOfLazFPDocNode: TFPList): TModalResult; | ||||||
| var | var | ||||||
|   PascalFilenames, FPDocFilenames: TStringToStringTree; |   PascalFilenames, FPDocFilenames: TFilenameToStringTree; | ||||||
|   CacheWasUsed: boolean; |   CacheWasUsed: boolean; | ||||||
|   Chain: TCodeHelpElementChain; |   Chain: TCodeHelpElementChain; | ||||||
|   CHResult: TCodeHelpParseResult; |   CHResult: TCodeHelpParseResult; | ||||||
|   CHElement: TCodeHelpElement; |   CHElement: TCodeHelpElement; | ||||||
|   AVLNode: TAvgLvlTreeNode; |  | ||||||
|   Item: PStringToStringItem; |  | ||||||
|   FPDocFilename: String; |   FPDocFilename: String; | ||||||
|  |   S2SItem: PStringToStringTreeItem; | ||||||
| begin | begin | ||||||
|   Result:=mrCancel; |   Result:=mrCancel; | ||||||
|   PascalFilenames:=nil; |   PascalFilenames:=nil; | ||||||
| @ -381,7 +380,7 @@ begin | |||||||
|     // gather FPDoc files |     // gather FPDoc files | ||||||
|     CleanUpFileList(PascalFiles); |     CleanUpFileList(PascalFiles); | ||||||
| 
 | 
 | ||||||
|     PascalFilenames:=CreateFilenameToStringTree; |     PascalFilenames:=TFilenameToStringTree.Create(false); | ||||||
|     PascalFilenames.AddNames(PascalFiles); |     PascalFilenames.AddNames(PascalFiles); | ||||||
|     CodeHelpBoss.GetFPDocFilenamesForSources(PascalFilenames,true,FPDocFilenames); |     CodeHelpBoss.GetFPDocFilenamesForSources(PascalFilenames,true,FPDocFilenames); | ||||||
|     if FPDocFilenames=nil then begin |     if FPDocFilenames=nil then begin | ||||||
| @ -400,16 +399,13 @@ begin | |||||||
|     DebugLn(['GatherFPDocReferences OwnerName=',CHElement.ElementOwnerName,' FPDocPkg=',CHElement.ElementFPDocPackageName,' Name=',CHElement.ElementName]); |     DebugLn(['GatherFPDocReferences OwnerName=',CHElement.ElementOwnerName,' FPDocPkg=',CHElement.ElementFPDocPackageName,' Name=',CHElement.ElementName]); | ||||||
| 
 | 
 | ||||||
|     // search FPDoc files |     // search FPDoc files | ||||||
|     AVLNode:=FPDocFilenames.Tree.FindLowest; |     for S2SItem in FPDocFilenames do begin | ||||||
|     while AVLNode<>nil do begin |       FPDocFilename:=S2SItem^.Name; | ||||||
|       Item:=PStringToStringItem(AVLNode.Data); |  | ||||||
|       FPDocFilename:=Item^.Name; |  | ||||||
|       Result:=GatherReferencesInFPDocFile( |       Result:=GatherReferencesInFPDocFile( | ||||||
|                 CHElement.ElementFPDocPackageName,CHElement.ElementUnitName, |                 CHElement.ElementFPDocPackageName,CHElement.ElementUnitName, | ||||||
|                 CHElement.ElementName, |                 CHElement.ElementName, | ||||||
|                 FPDocFilename,ListOfLazFPDocNode); |                 FPDocFilename,ListOfLazFPDocNode); | ||||||
|       if Result<>mrOk then exit; |       if Result<>mrOk then exit; | ||||||
|       AVLNode:=FPDocFilenames.Tree.FindSuccessor(AVLNode); |  | ||||||
|     end; |     end; | ||||||
| 
 | 
 | ||||||
|     Result:=mrOk; |     Result:=mrOk; | ||||||
|  | |||||||
| @ -158,6 +158,8 @@ const | |||||||
|     'CaseInsensitive', |     'CaseInsensitive', | ||||||
|     'File' |     'File' | ||||||
|     ); |     ); | ||||||
|  | function IndexInRecentList(List: TStrings; ListType: TRecentListType; | ||||||
|  |   const Path: string): integer; | ||||||
| function StrToRecentListType(s: string): TRecentListType; | function StrToRecentListType(s: string): TRecentListType; | ||||||
| function CompareRecentListItem(s1, s2: string; ListType: TRecentListType): boolean; | function CompareRecentListItem(s1, s2: string; ListType: TRecentListType): boolean; | ||||||
| procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string; | procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string; | ||||||
| @ -170,6 +172,8 @@ function AddComboTextToRecentList(cb: TCombobox; Max: integer; | |||||||
| procedure RemoveFromRecentList(const s: string; RecentList: TStrings; | procedure RemoveFromRecentList(const s: string; RecentList: TStrings; | ||||||
|                                ListType: TRecentListType); |                                ListType: TRecentListType); | ||||||
| procedure CleanUpRecentList(List: TStrings; ListType: TRecentListType); | procedure CleanUpRecentList(List: TStrings; ListType: TRecentListType); | ||||||
|  | 
 | ||||||
|  | // XMLconfig | ||||||
| procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; | procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; | ||||||
|                    var ARect:TRect); |                    var ARect:TRect); | ||||||
| procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; | procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; | ||||||
| @ -255,10 +259,6 @@ procedure FreeListObjects(List: TList; FreeList: boolean); | |||||||
| procedure FreeListObjects(List: TFPList; FreeList: boolean); | procedure FreeListObjects(List: TFPList; FreeList: boolean); | ||||||
| function CompareMemStreamText(s1, s2: TMemoryStream): Boolean; | function CompareMemStreamText(s1, s2: TMemoryStream): Boolean; | ||||||
| 
 | 
 | ||||||
| function CompareStringToStringItemsFilename(Data1, Data2: Pointer): integer; |  | ||||||
| function ComparePAnsiStringWithStrToStrItemFilename(Key, Data: Pointer): Integer; |  | ||||||
| function CreateFilenameToStringTree: TStringToStringTree; |  | ||||||
| 
 |  | ||||||
| function CheckGroupItemChecked(CheckGroup: TCheckGroup; const Caption: string): Boolean; | function CheckGroupItemChecked(CheckGroup: TCheckGroup; const Caption: string): Boolean; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -946,6 +946,14 @@ begin | |||||||
|   FindCloseUTF8(FileInfo); |   FindCloseUTF8(FileInfo); | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | function IndexInRecentList(List: TStrings; ListType: TRecentListType; | ||||||
|  |   const Path: string): integer; | ||||||
|  | begin | ||||||
|  |   Result:=List.Count-1; | ||||||
|  |   while (Result>=0) and (not CompareRecentListItem(List[Result],Path,ListType)) do | ||||||
|  |     dec(Result); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| function StrToRecentListType(s: string): TRecentListType; | function StrToRecentListType(s: string): TRecentListType; | ||||||
| begin | begin | ||||||
|   for Result:=Low(TRecentListType) to high(TRecentListType)  do |   for Result:=Low(TRecentListType) to high(TRecentListType)  do | ||||||
| @ -2641,23 +2649,6 @@ begin | |||||||
|   end; |   end; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
| function CompareStringToStringItemsFilename(Data1, Data2: Pointer): integer; |  | ||||||
| begin |  | ||||||
|   Result:=CompareFilenames(PStringToStringItem(Data1)^.Name, |  | ||||||
|                            PStringToStringItem(Data2)^.Name); |  | ||||||
| end; |  | ||||||
| 
 |  | ||||||
| function ComparePAnsiStringWithStrToStrItemFilename(Key, Data: Pointer): Integer; |  | ||||||
| begin |  | ||||||
|   Result:=CompareFilenames(PAnsiString(Key)^,PStringToStringItem(Data)^.Name); |  | ||||||
| end; |  | ||||||
| 
 |  | ||||||
| function CreateFilenameToStringTree: TStringToStringTree; |  | ||||||
| begin |  | ||||||
|   Result:=TStringToStringTree.Create(@CompareStringToStringItemsFilename, |  | ||||||
|                                    @ComparePAnsiStringWithStrToStrItemFilename); |  | ||||||
| end; |  | ||||||
| 
 |  | ||||||
| function CheckGroupItemChecked(CheckGroup: TCheckGroup; const Caption: string): Boolean; | function CheckGroupItemChecked(CheckGroup: TCheckGroup; const Caption: string): Boolean; | ||||||
| begin | begin | ||||||
|   Result := CheckGroup.Checked[CheckGroup.Items.IndexOf(Caption)]; |   Result := CheckGroup.Checked[CheckGroup.Items.IndexOf(Caption)]; | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ unit DynQueue; | |||||||
| interface | interface | ||||||
| 
 | 
 | ||||||
| uses | uses | ||||||
|   Classes, SysUtils, LCLProc; |   Classes, SysUtils, LazLoggerBase; | ||||||
|    |    | ||||||
| type | type | ||||||
|   TDynamicQueueItem = record |   TDynamicQueueItem = record | ||||||
| @ -437,7 +437,7 @@ var | |||||||
|   DataCount: LongInt; |   DataCount: LongInt; | ||||||
|   DataOffset: Integer; |   DataOffset: Integer; | ||||||
| begin | begin | ||||||
|   debugln(['TDynamicDataQueue.WriteDebugReport FItemCapacity=',FItemCapacity, |   DebugLn(['TDynamicDataQueue.WriteDebugReport FItemCapacity=',FItemCapacity, | ||||||
|     ' FTopIndex=',FTopIndex,' FTopItemSpace=',FTopItemSpace, |     ' FTopIndex=',FTopIndex,' FTopItemSpace=',FTopItemSpace, | ||||||
|     ' FLastIndex=',FLastIndex,' FLastItemSpace=',FLastItemSpace, |     ' FLastIndex=',FLastIndex,' FLastItemSpace=',FLastItemSpace, | ||||||
|     ' Size=',Size, |     ' Size=',Size, | ||||||
|  | |||||||
| @ -37,12 +37,12 @@ uses | |||||||
|   LCLType, LCLProc, Menus, Dialogs, FileUtil, LazFileCache, |   LCLType, LCLProc, Menus, Dialogs, FileUtil, LazFileCache, | ||||||
|   contnrs, |   contnrs, | ||||||
|   // IDEIntf CodeTools |   // IDEIntf CodeTools | ||||||
|   IDEImagesIntf, MenuIntf, ExtCtrls, LazIDEIntf, ProjectIntf, |   IDEImagesIntf, MenuIntf, ExtCtrls, LazIDEIntf, ProjectIntf, CodeToolsStructs, | ||||||
|   CodeToolsStructs, FormEditingIntf, TreeFilterEdit, PackageIntf, |   FormEditingIntf, TreeFilterEdit, PackageIntf, IDEDialogs, IDEHelpIntf, | ||||||
|   IDEDialogs, IDEHelpIntf, IDEOptionsIntf, IDEProcs, LazarusIDEStrConsts, |   IDEOptionsIntf, IDEProcs, LazarusIDEStrConsts, IDEDefs, CompilerOptions, | ||||||
|   IDEDefs, CompilerOptions, ComponentReg, EnvironmentOpts, DialogProcs, |   ComponentReg, UnitResources, EnvironmentOpts, DialogProcs, PackageDefs, | ||||||
|   PackageDefs, AddToPackageDlg, PkgVirtualUnitEditor, |   AddToPackageDlg, PkgVirtualUnitEditor, MissingPkgFilesDlg, PackageSystem, | ||||||
|   MissingPkgFilesDlg, PackageSystem, CleanPkgDeps; |   CleanPkgDeps; | ||||||
|    |    | ||||||
| const | const | ||||||
|   PackageEditorMenuRootName = 'PackageEditor'; |   PackageEditorMenuRootName = 'PackageEditor'; | ||||||
| @ -3014,6 +3014,15 @@ end; | |||||||
| 
 | 
 | ||||||
| function TPackageEditorForm.MoveFiles(SrcPkgEdit: TPackageEditorForm; | function TPackageEditorForm.MoveFiles(SrcPkgEdit: TPackageEditorForm; | ||||||
|   PkgFiles: TFPList; TargetDirectory: string): boolean; |   PkgFiles: TFPList; TargetDirectory: string): boolean; | ||||||
|  | 
 | ||||||
|  |   procedure AddResFile(ResFiles: TStringList; ResFile: string); | ||||||
|  |   begin | ||||||
|  |     if not FilenameIsAbsolute(ResFile) then exit; | ||||||
|  |     if IndexInRecentList(ResFiles,rltFile,ResFile)>=0 then exit; | ||||||
|  |     if not FileExistsCached(ResFile) then exit; | ||||||
|  |     ResFiles.Add(ResFile); | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
| var | var | ||||||
|   i: Integer; |   i: Integer; | ||||||
|   PkgFile: TPkgFile; |   PkgFile: TPkgFile; | ||||||
| @ -3025,11 +3034,30 @@ var | |||||||
|   MsgResult: TModalResult; |   MsgResult: TModalResult; | ||||||
|   DeleteOld: Boolean; |   DeleteOld: Boolean; | ||||||
|   ChangedFilenames: TFilenameToStringTree; // old to new file name |   ChangedFilenames: TFilenameToStringTree; // old to new file name | ||||||
|  |   UnitResArr: TUnitResourcefileFormatArr; | ||||||
|  |   j: Integer; | ||||||
|  |   aFilename: String; | ||||||
|  |   UnitFilenameToResFileList: TFilenameToPointerTree; // filename to TStringList | ||||||
|  |   ResFileList: TStringList; | ||||||
| begin | begin | ||||||
|   Result:=false; |   Result:=false; | ||||||
|  | 
 | ||||||
|  |   // ignore non existing files | ||||||
|  |   for i:=PkgFiles.Count-1 downto 0 do begin | ||||||
|  |     PkgFile:=TPkgFile(PkgFiles[i]); | ||||||
|  |     OldFilename:=PkgFile.GetFullFilename; | ||||||
|  |     if not FileExistsCached(OldFilename) then begin | ||||||
|  |       {$IFDEF VerbosePkgEditDrag} | ||||||
|  |       debugln(['TPackageEditorForm.MoveFiles WARNING: file not found: ',OldFilename]); | ||||||
|  |       {$ENDIF} | ||||||
|  |       PkgFiles.Delete(i); | ||||||
|  |     end; | ||||||
|  |   end; | ||||||
|   if PkgFiles.Count=0 then exit; |   if PkgFiles.Count=0 then exit; | ||||||
|  | 
 | ||||||
|   if not FilenameIsAbsolute(TargetDirectory) then exit; |   if not FilenameIsAbsolute(TargetDirectory) then exit; | ||||||
|   TargetDirectory:=AppendPathDelim(TargetDirectory); |   TargetDirectory:=AppendPathDelim(TargetDirectory); | ||||||
|  | 
 | ||||||
|   {$IFDEF VerbosePkgEditDrag} |   {$IFDEF VerbosePkgEditDrag} | ||||||
|   debugln(['TPackageEditorForm.MoveFiles Self=',LazPackage.Filename,' Src=',SrcPkgEdit.LazPackage.Filename,' Dir="',TargetDirectory,'" FileCount=',PkgFiles.Count]); |   debugln(['TPackageEditorForm.MoveFiles Self=',LazPackage.Filename,' Src=',SrcPkgEdit.LazPackage.Filename,' Dir="',TargetDirectory,'" FileCount=',PkgFiles.Count]); | ||||||
|   {$ENDIF} |   {$ENDIF} | ||||||
| @ -3040,14 +3068,19 @@ begin | |||||||
| 
 | 
 | ||||||
|   NewFileToOldPkgFile:=nil; |   NewFileToOldPkgFile:=nil; | ||||||
|   ChangedFilenames:=nil; |   ChangedFilenames:=nil; | ||||||
|  |   UnitFilenameToResFileList:=nil; | ||||||
|   try |   try | ||||||
|     // check files |     // check files | ||||||
|     MoveFileCount:=0; |     MoveFileCount:=0; | ||||||
|     NewFileToOldPkgFile:=TFilenameToPointerTree.Create(false); |     NewFileToOldPkgFile:=TFilenameToPointerTree.Create(false); | ||||||
|     ChangedFilenames:=TFilenameToStringTree.Create(false); |     ChangedFilenames:=TFilenameToStringTree.Create(false); | ||||||
|  |     UnitFilenameToResFileList:=TFilenameToPointerTree.Create(false); | ||||||
|  |     UnitFilenameToResFileList.FreeValues:=true; | ||||||
|  | 
 | ||||||
|     for i:=0 to PkgFiles.Count-1 do begin |     for i:=0 to PkgFiles.Count-1 do begin | ||||||
|       PkgFile:=TPkgFile(PkgFiles[i]); |       PkgFile:=TPkgFile(PkgFiles[i]); | ||||||
|       OldFilename:=PkgFile.GetFullFilename; |       OldFilename:=PkgFile.GetFullFilename; | ||||||
|  |       if not FileExistsCached(OldFilename) then continue; | ||||||
|       NewFilename:=TargetDirectory+ExtractFilename(OldFilename); |       NewFilename:=TargetDirectory+ExtractFilename(OldFilename); | ||||||
| 
 | 
 | ||||||
|       // check if two copied/moved files will get the same new file name |       // check if two copied/moved files will get the same new file name | ||||||
| @ -3064,6 +3097,8 @@ begin | |||||||
|       if CompareFilenames(NewFilename,OldFilename)<>0 then begin |       if CompareFilenames(NewFilename,OldFilename)<>0 then begin | ||||||
|         // file be copied/moved to another directory |         // file be copied/moved to another directory | ||||||
|         inc(MoveFileCount); |         inc(MoveFileCount); | ||||||
|  |         ChangedFilenames[OldFilename]:=NewFilename; | ||||||
|  | 
 | ||||||
|         // check if new position is free |         // check if new position is free | ||||||
|         if FileExistsCached(NewFilename) then begin |         if FileExistsCached(NewFilename) then begin | ||||||
|           IDEMessageDialog('Conflict detected', |           IDEMessageDialog('Conflict detected', | ||||||
| @ -3073,10 +3108,24 @@ begin | |||||||
|           exit; |           exit; | ||||||
|         end; |         end; | ||||||
| 
 | 
 | ||||||
|         ChangedFilenames[OldFilename]:=NewFilename; |         // check resource file | ||||||
|  |         if PkgFile.FileType=pftUnit then begin | ||||||
|  |           ResFileList:=TStringList.Create; | ||||||
|  |           UnitFilenameToResFileList[OldFilename]:=ResFileList; | ||||||
|  |           AddResFile(ResFileList,ChangeFileExt(OldFilename,'.lfm')); | ||||||
|  |           AddResFile(ResFileList,ChangeFileExt(OldFilename,'.dfm')); | ||||||
|  |           AddResFile(ResFileList,ChangeFileExt(OldFilename,'.lrs')); | ||||||
|  |           UnitResArr:=GetUnitResourcefileFormats; | ||||||
|  |           for j:=0 to length(UnitResArr)-1 do begin | ||||||
|  |             aFilename:=UnitResArr[j].GetUnitResourceFilename(OldFilename,true); | ||||||
|  |             AddResFile(ResFileList,aFilename); | ||||||
|  |           end; | ||||||
|  |         end; | ||||||
|  |       end; | ||||||
|  |     end; | ||||||
|  | 
 | ||||||
|  |     // ToDo: remove res files, that are in PkgFiles | ||||||
| 
 | 
 | ||||||
|       end; |  | ||||||
|     end; |  | ||||||
| 
 | 
 | ||||||
|     if (MoveFileCount=0) and (LazPackage=SrcPackage) then begin |     if (MoveFileCount=0) and (LazPackage=SrcPackage) then begin | ||||||
|       // change order in package |       // change order in package | ||||||
| @ -3110,16 +3159,15 @@ begin | |||||||
|     end; |     end; | ||||||
| 
 | 
 | ||||||
|     if DeleteOld then begin |     if DeleteOld then begin | ||||||
|       // close files in source editor |       // close files and res files in source editor | ||||||
| 
 | 
 | ||||||
|     end; |     end; | ||||||
| 
 | 
 | ||||||
|     ShowMessage('Moving files is not yet implemented'); |     ShowMessage('Moving files is not yet implemented'); | ||||||
| 
 | 
 | ||||||
|     // move/copy file |     // if SrcPkg<>SelfPkg: clear output dir of SrcPkg | ||||||
|     // move/copy secondary files (lfm,lrs) |     // move/copy file and res files, Note: some files are res files | ||||||
|     // move/copy TPkgFile, make uses-unit unique |     // move/copy TPkgFile, make uses-unit unique | ||||||
|     // if another pkg: clear output dir of SrcPkg |  | ||||||
|     // clean up unit/inlude path of SrcPkg |     // clean up unit/inlude path of SrcPkg | ||||||
|   finally |   finally | ||||||
|     ChangedFilenames.Free; |     ChangedFilenames.Free; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 mattias
						mattias