فهرست منبع

Removing some unused code

Source commit: 6be26458abcef70a5b7978296a6a3430a7e8fdee
Martin Prikryl 4 هفته پیش
والد
کامیت
b6538ca27f
3فایلهای تغییر یافته به همراه14 افزوده شده و 318 حذف شده
  1. 2 74
      source/packages/filemng/DirView.pas
  2. 4 67
      source/packages/filemng/DriveView.pas
  3. 8 177
      source/packages/filemng/FileOperator.pas

+ 2 - 74
source/packages/filemng/DirView.pas

@@ -128,7 +128,6 @@ type
     FDesktopFolder: IShellFolder;
     FDirOK: Boolean;
     FPath: string;
-    SelectNewFiles: Boolean;
     FHiddenCount: Integer;
     FFilteredCount: Integer;
     FNotRelative: Boolean;
@@ -170,7 +169,6 @@ type
 
     procedure Delete(Item: TListItem); override;
     procedure DDError(ErrorNo: TDDError);
-    function GetCanUndoCopyMove: Boolean; virtual;
     {Shell namespace functions:}
     function GetShellFolder(Dir: string): iShellFolder;
     function GetDirOK: Boolean; override;
@@ -245,17 +243,11 @@ type
     { required, otherwise AV generated, when dragging columns}
     property Columns stored False;
     property ParentFolder: IShellFolder read FParentFolder;
-    {Drag&Drop runtime, readonly properties:}
-    property CanUndoCopyMove: Boolean read GetCanUndoCopyMove;
-    property DDFileOperator: TFileOperator read FFileOperator;
-    {Drag&Drop fileoperation methods:}
-    function UndoCopyMove: Boolean; dynamic;
     {Clipboard fileoperation methods (requires drag&drop enabled):}
     procedure EmptyClipboard; dynamic;
-    function CopyToClipBoard(Focused: Boolean): Boolean; dynamic;
-    function CutToClipBoard(Focused: Boolean): Boolean; dynamic;
+    function CopyToClipBoard(Focused: Boolean): Boolean;
+    function CutToClipBoard(Focused: Boolean): Boolean;
     function PasteFromClipBoard(TargetPath: string = ''): Boolean; override;
-    function DuplicateSelectedFiles: Boolean; dynamic;
     procedure DisplayPropertiesMenu; override;
     procedure DisplayContextMenu(Where: TPoint); override;
 
@@ -570,8 +562,6 @@ begin
   if Result then
   begin
     FileOperator.Execute;
-    if DragDropFilesEx.FileNamesAreMapped then
-      FileOperator.ClearUndo;
   end;
 end;
 
@@ -695,7 +685,6 @@ begin
   FConfirmDelete := True;
   FParentFolder := nil;
   FDesktopFolder := nil;
-  SelectNewFiles := False;
   DragOnDriveIsMove := True;
   FHiddenCount := 0;
   FFilteredCount := 0;
@@ -973,8 +962,6 @@ begin
   if not Self.IsRecycleBin then Item.Caption := SRec.Name;
   if PItem^.FileExt = 'LNK' then Item.OverlayIndex := 1;
 
-  if SelectNewFiles then Item.Selected := True;
-
   Result := Item;
 end; {AddItem}
 
@@ -3284,39 +3271,6 @@ begin
   raise EDragDrop.Create(Format(SDragDropError, [Ord(ErrorNo)]));
 end; {DDError}
 
-function TDirView.GetCanUndoCopyMove: Boolean;
-begin
-  Result := Assigned(FFileOperator) and FFileOperator.CanUndo;
-end; {CanUndoCopyMove}
-
-function TDirView.UndoCopyMove: Boolean;
-var
-  LastTarget: string;
-  LastSource: string;
-begin
-  Result := False;
-  if FFileOperator.CanUndo then
-  begin
-    LastTarget := FFileOperator.LastOperandTo[0];
-    LastSource := FFileOperator.LastOperandFrom[0];
-    if Assigned(FDriveView) then
-      TDriveView(FDriveView).StopAllWatchThreads;
-
-    Result := FFileOperator.UndoExecute;
-
-    if not WatchthreadActive then
-      Reload2;
-
-    if Assigned(FDriveView) then
-    begin
-      var ADriveView := TDriveView(FDriveView);
-      ADriveView.ValidateDirectory(ADriveView.FindNodeToPath(ExtractFilePath(LastTarget)));
-      ADriveView.ValidateDirectory(ADriveView.FindNodeToPath(ExtractFilePath(LastSource)));
-      ADriveView.StartAllWatchThreads;
-    end;
-  end;
-end; {UndoCopyMove}
-
 procedure TDirView.EmptyClipboard;
 var
   Item: TListItem;
@@ -3424,32 +3378,6 @@ begin
     (FDriveType <> DRIVE_REMOVABLE);
 end;
 
-function TDirView.DuplicateSelectedFiles: Boolean;
-begin
-  Result := False;
-  if SelCount > 0 then
-  begin
-    Result := CopyToClipBoard(False);
-    if Result then
-      try
-        SelectNewFiles := True;
-        Selected := nil;
-        Result := PasteFromClipBoard();
-      finally
-        SelectNewFiles := False;
-        if Assigned(Selected) then
-        begin
-          ItemFocused := Selected;
-          Selected.MakeVisible(False);
-          if SelCount = 1 then
-            Selected.EditCaption;
-        end;
-      end;
-
-  end;
-  EmptyClipBoard;
-end; {DuplicateFiles}
-
 function TDirView.NewColProperties: TCustomListViewColProperties;
 begin
   Result := TDirViewColProperties.Create(Self);

+ 4 - 67
source/packages/filemng/DriveView.pas

@@ -252,7 +252,6 @@ type
     procedure RebuildTree; override;
 
     procedure SetLastPathCut(Path: string);
-    function GetCanUndoCopyMove: Boolean; virtual;
     procedure CreateWnd; override;
     procedure DestroyWnd; override;
     procedure Edit(const Item: TTVItem); override;
@@ -276,6 +275,10 @@ type
     function DragCompleteFileList: Boolean; override;
     function DDExecute: TDragResult; override;
 
+    function CanPasteFromClipBoard: Boolean;
+    function PasteFromClipBoard(TargetPath: string = ''): Boolean;
+    procedure PerformDragDropFileOperation(Node: TTreeNode; Effect: Integer); override;
+
   public
     property Images;
     property StateImages;
@@ -284,18 +287,8 @@ type
 
     property DragImageList: TDragImageList read FDragImageList;
 
-    property CanUndoCopyMove: Boolean read GetCanUndoCopyMove;
-    property DDFileOperator: TFileOperator read FFileOperator;
     property LastPathCut: string read FLastPathCut write SetLastPathCut;
-
-    function UndoCopyMove: Boolean; dynamic;
     procedure EmptyClipboard; dynamic;
-    function CopyToClipBoard(Node: TTreeNode): Boolean; dynamic;
-    function CutToClipBoard(Node: TTreeNode): Boolean; dynamic;
-    function CanPasteFromClipBoard: Boolean; dynamic;
-    function PasteFromClipBoard(TargetPath: string = ''): Boolean; dynamic;
-    procedure PerformDragDropFileOperation(Node: TTreeNode; Effect: Integer); override;
-
     {Drive handling:}
     function GetDriveStatus(Drive: string): TDriveStatus;
     function GetDriveTypetoNode(Node: TTreeNode): Integer;  {Returns DRIVE_CDROM etc..}
@@ -2904,39 +2897,6 @@ begin
   end;
 end; {PerformDragDropFileOperation}
 
-function TDriveView.GetCanUndoCopyMove: Boolean;
-begin
-  Result := Assigned(FFileOperator) and FFileOperator.CanUndo;
-end; {CanUndoCopyMove}
-
-function TDriveView.UndoCopyMove: Boolean;
-var
-  LastTarget: string;
-  LastSource: string;
-begin
-  Result := False;
-  if FFileOperator.CanUndo then
-  begin
-    Lasttarget := FFileOperator.LastOperandTo[0];
-    LastSource := FFileOperator.LastOperandFrom[0];
-    StopAllWatchThreads;
-    Result := FFileOperator.UndoExecute;
-
-    ValidateDirectory(FindNodeToPath(ExtractFilePath(LastTarget)));
-    ValidateDirectory(FindNodeToPath(ExtractFilePath(LastSource)));
-    StartAllWatchThreads;
-
-    if Assigned(FDirView) then
-      with FDirView do
-        if not WatchThreadActive then
-        begin
-          if (IncludeTrailingBackslash(ExtractFilePath(LastTarget)) = IncludeTrailingBackslash(Path)) or
-             (IncludeTrailingBackslash(ExtractFilePath(LastSource)) = IncludeTrailingBackslash(Path)) then
-            Reload2;
-        end;
-      end;
-end; {UndoCopyMove}
-
 {Clipboard operations:}
 procedure TDriveView.SetLastPathCut(Path: string);
 var
@@ -2972,29 +2932,6 @@ begin
   end;
 end; {EmptyClipBoard}
 
-function TDriveView.CopyToClipBoard(Node: TTreeNode): Boolean;
-begin
-  Result := Assigned(Selected);
-  if Result then
-  begin
-    EmptyClipBoard;
-    ClearDragFileList(FDragDropFilesEx.FileList);
-    AddToDragFileList(FDragDropFilesEx.FileList, Selected);
-    Result := FDragDropFilesEx.CopyToClipBoard;
-    LastClipBoardOperation := cboCopy;
-  end;
-end; {CopyToClipBoard}
-
-function TDriveView.CutToClipBoard(Node: TTreeNode): Boolean;
-begin
-  Result := Assigned(Node) and Assigned(Node.Parent) and CopyToClipBoard(Node);
-  if Result then
-  begin
-    LastPathCut := NodePathName(Node);
-    LastClipBoardOperation := cboCut;
-  end;
-end; {CutToClipBoard}
-
 function TDriveView.CanPasteFromClipBoard: Boolean;
 begin
   Result := False;

+ 8 - 177
source/packages/filemng/FileOperator.pas

@@ -66,21 +66,10 @@ unit FileOperator;
 |   Title: String to use as the title for a progress dialog box.               |
 |          This member is used only if Options includes fofSimpleProgress.     |
 |                                                                              |
-|   OperationAborted: Value that receives True if the user aborted any file    |
-|          operations before they were completed or FALSE otherwise.           |
-|                                                                              |
-|   LastOperandFrom        Stringlist of last performed value of Operandfrom.  |
-|                                                                              |
-|   LastOperandTo          Stringlist of last performed value of OperandTo.    |
-|                                                                              |
-|   LastOperation          Value of last performed operation.                  |
-|                                                                              |
 |   WantMappingHandle      After execution should a file mapping be returned.  |
 |                          Works only, when option foMultiDestFiles used.      |
 |                          Note: don't know, how to use this.                  |
 |                                                                              |
-|   NameMappings           Pointer to namemappings, if property wantmapping-   |
-|                          handle set.                                         |
 +------------------------------------------------------------------------------+
 | Methods:                                                                     |
 |                                                                              |
@@ -88,17 +77,6 @@ unit FileOperator;
 |     Performs the copy, move, rename, or delete operation.                    |
 |     Returns zero if successful or nonzero value if an error occurs.          |
 |                                                                              |
-|   Function UndoExecute : Boolean;                                            |
-|     Reverses the last copy, move or rename operation.                        |
-|     Note: works currently only, if only a single OperandTo is used. This     |
-|     OperandTo must be the target directory.                                  |
-|                                                                              |
-|   Function CanUndo : Boolean;                                                |
-|     Returns TRUE, if undo of last operation is possible.                     |
-|                                                                              |
-|   Procedure ClearUndo;                                                       |
-|     Clears the preserved undo informations. After that, CanUndo allways      |
-|     returns false.                                                           |
 +------------------------------------------------------------------------------+
 | Events:                                                                      |
 +------------------------------------------------------------------------------+
@@ -120,18 +98,14 @@ Type
   TFileOperationFlags = set of TFileOperationFlag;
 
 {==============================================================}
-  TFileOperator = class( TComponent )
+  TFileOperator = class
 {==============================================================}
   private
 {==============================================================}
     FData          : TShFileOpStruct;
     FFrom          : TStringList;
     FTo            : TStringList;
-    FLastFrom      : TStringList;
-    FLastTo        : TStringList;
-    FLastOperation : TFileOperation;
-    fLastFlags     : TFileOperationFlags;
-    fCanUndo       : Boolean;
+    fOwner         : TWinControl;
     Procedure SetOperation( Value :TFileOperation );
     Function  GetOperation :TFileOperation;
     Function  GetWantMappingHandle :Boolean;
@@ -140,32 +114,16 @@ Type
     Function  GetFlags :TFileOperationFlags;
     Function  GetOperFlag( F :Cardinal ) :Boolean;
     Procedure SetOperFlag( F :Cardinal; V :Boolean );
-    Procedure ReadData( Reader :TReader );
-    Procedure WriteData( Writer :TWriter );
-    Procedure SwapStringList(Var FromL, ToL : TStringList);
-    Function  GetOperationAborted: Bool;
-
-{==============================================================}
-  protected
-{==============================================================}
-    Procedure DefineProperties( Filer :TFiler ); override;
 
 {==============================================================}
   public
 {==============================================================}
-    Property OperationAborted : Bool        Read GetOperationAborted;
     Property OperandFrom      : TStringList Read fFrom Write fFrom;
     Property OperandTo        : TStringList Read FTo   Write fTo;
-    Property CanUndo          : Boolean     Read fCanUndo;
-    Property LastOperation    : TFileOperation Read fLastOperation;
-    Property LastOperandFrom  : TStringList Read fLastFrom;
-    Property LastOperandTo    : TStringList Read fLastTo;
 
-    Constructor Create(aOwner :TComponent); Override;
+    Constructor Create(Owner: TWinControl);
     Destructor  Destroy; override;
     Function    Execute          : Boolean;
-    Function    UndoExecute      : Boolean;
-    Procedure   ClearUndo;
 {==============================================================}
   published
 {==============================================================}
@@ -177,8 +135,6 @@ Type
 const
   FileOperatorDefaultFlags = [foAllowUndo, foNoConfirmMkDir];
 
-procedure Register;
-
 {==============================================================}
 implementation
 {==============================================================}
@@ -268,33 +224,12 @@ begin
 end;
 
 
-procedure TFileOperator.DefineProperties( Filer :TFiler );
-begin
- Inherited DefineProperties( Filer );
- Filer.DefineProperty( 'data', ReadData, WriteData, true );
-end;
-
-
-procedure TFileOperator.ReadData( Reader :TReader );
-begin
-  Reader.Read( FData, SizeOf( FData ) );
-end;
-
-
-procedure TFileOperator.WriteData( Writer :TWriter );
-begin
-  writer.write( FData, SizeOf( FData ) );
-end;
-
-
-Constructor TFileOperator.Create(aOwner :TComponent);
+Constructor TFileOperator.Create(Owner: TWinControl);
 begin
- inherited Create(aOwner);
+ inherited Create;
  fFrom     := TStringList.Create;
  fTo       := TStringList.Create;
- fLastFrom := TStringList.Create;
- fLastTo   := TStringList.Create;
- fCanUndo  := False;
+ fOwner    := Owner;
  FData.fFlags := 0;
  Flags := FileOperatorDefaultFlags;
 end; {Create}
@@ -325,8 +260,8 @@ begin {Execute}
   STo   := ConvertOperand(FTo);
   FData.pFrom := PChar( SFrom );
   FData.pTo := PChar( STo );
-  IF (Owner is TWinControl) And TWinControl(Owner).HandleAllocated Then
-    FData.Wnd := GetParentForm(TWinControl(Owner)).Handle
+  IF Assigned(fOwner) and fOwner.HandleAllocated Then
+    FData.Wnd := fOwner.Handle
   Else
     FData.Wnd := Application.Handle;
 
@@ -344,23 +279,6 @@ begin {Execute}
       Else
       Result := ShFileOperation( FData ) = 0;
     Finally
-      IF GetOperFlag(FOF_ALLOWUNDO) And
-         Not GetOperFlag(FOF_MULTIDESTFILES) And
-         Not GetOperFlag(FOF_RENAMEONCOLLISION) And
-        (Operation <> foDelete) Then
-      Begin
-        SwapStringList(fLastFrom, fFrom);
-        SwapStringList(fLastTo,   fTo);
-        fLastFlags := Flags;
-        fCanUndo   := True;
-        fLastOperation := Operation;
-      End
-      Else
-      Begin
-        FLastFrom.Clear;
-        FLastTo.Clear;
-        fCanUndo := False;
-      End;
       FFrom.Clear;
       FTo.Clear;
     End;
@@ -376,96 +294,9 @@ begin
   FFrom.Free;
   IF Assigned(FTo) Then
   FTo.Free;
-  IF Assigned(FLastFrom) Then
-  FLastFrom.Free;
-  IF Assigned(FLastTo) Then
-  FLastTo.Free;
   IF Assigned(FData.hNameMappings) Then
   shFreeNameMappings(THandle(FData.hNameMappings));
   inherited Destroy;
 end; {Destroy}
 
-
-
-Procedure TFileOperator.SwapStringList(Var FromL, ToL : TStringList);
-Var StrL  : TStringList;
-Begin
-    StrL  := FromL;
-    FromL := ToL;
-    ToL   := StrL;
-End; {SwapStringList}
-
-Function  TFileOperator.GetOperationAborted: Bool;
-Begin
-  Result := FData.fAnyOperationsAborted;
-End;
-
-Function TFileOperator.UndoExecute : Boolean;
-Var SaveFlags : TFileOperationFlags;
-    SaveOperation : TFileOperation;
-    i             : Integer;
-
-Begin
-  Result := False;
-  IF Not fCanUndo Or
-     (fLastFrom.Count = 0) Or
-     (FLastTo.Count  <> 1) Then
-  Exit;
-
-  SaveFlags := Flags;
-  SaveOperation := Operation;
-  Flags := fLastFlags;
-  Case SaveOperation OF
-    foCopy  : IF fLastTo.Count = 1 Then
-              Begin
-                 Operation := foDelete;
-                 Flags := Flags - [foAllowUndo] + [foNoConfirmation];
-                 OperandFrom.Clear;
-                 For i := 0 To fLastFrom.Count - 1 Do
-                   OperandFrom.Add(IncludeTrailingPathDelimiter(fLastTo[0]) + ExtractFilename(fLastFrom[i]));
-                 Result := Execute;
-              End;
-    foMove  : IF fLastTo.Count = 1 Then
-              Begin
-                 Operation := foMove;
-                 Flags := Flags + [foAllowUndo, foNoConfirmation];
-                 OperandFrom.Clear;
-                 OperandTo.Clear;
-                 OperandTo.Add(ExtractFilePath(fLastFrom[0]));
-                 For i := 0 To fLastFrom.Count - 1 Do
-                   OperandFrom.Add(IncludeTrailingPathDelimiter(fLastTo[0]) + ExtractFilename(fLastFrom[i]));
-                 Result := Execute;
-              End;
-
-    foRename: IF (FLastFrom.Count = 1) And (FLastTo.Count = 1) Then
-              Begin
-                Operation := foRename;
-                Flags := Flags + [foAllowUndo, foNoConfirmation];
-                OperandFrom.Clear;
-                OperandTo.Clear;
-                OperandFrom.Add(fLastTo[0]);
-                OperandTo.Add(fLastFrom[0]);
-                Result := Execute;
-              End;
-  End; {Case}
-
-  Flags := SaveFlags;
-  Operation := SaveOperation;
-End; {UndoExecute}
-
-
-Procedure TFileOperator.ClearUndo;
-Begin
-  fCanUndo := False;
-  fLastFrom.Clear;
-  fLastTo.Clear;
-End; {ClearUndo}
-
-
-procedure Register;
-begin
-  {MP}RegisterComponents( {'Tools'}'DriveDir', [ TFileOperator ] );
-end;
-
-
 end.