mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Isolating TDriveView from TDirView to allow it to be translated to C++ independently
Can be undone, once both are translated Source commit: ce0c1de6685e5ef69fd3599aef7c609ff9e15175
This commit is contained in:
@@ -850,6 +850,12 @@ TTreeNode * __fastcall TCustomUnixDriveView::FindNodeToPath(UnicodeString Path)
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
TTreeNode * __fastcall TCustomUnixDriveView::TryFindNodeToPath(UnicodeString)
|
||||
{
|
||||
DebugFail();
|
||||
return nullptr;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
TTreeNode * __fastcall TCustomUnixDriveView::FindPathNode(UnicodeString Path)
|
||||
{
|
||||
TTreeNode * Result = NULL;
|
||||
@@ -881,6 +887,12 @@ void __fastcall TCustomUnixDriveView::ValidateDirectoryEx(TTreeNode * /*Node*/,
|
||||
// nothing
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TCustomUnixDriveView::ValidateCurrentDirectoryIfNotMonitoring()
|
||||
{
|
||||
DebugFail();
|
||||
// noop
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TCustomUnixDriveView::RebuildTree()
|
||||
{
|
||||
TTreeNode * First = Items->GetFirstNode();
|
||||
|
||||
@@ -60,7 +60,8 @@ protected:
|
||||
virtual bool __fastcall DragCompleteFileList();
|
||||
virtual TDropEffectSet __fastcall DDSourceEffects();
|
||||
|
||||
TTreeNode * __fastcall FindNodeToPath(UnicodeString Path);
|
||||
virtual TTreeNode * __fastcall FindNodeToPath(UnicodeString Path);
|
||||
virtual TTreeNode * __fastcall TryFindNodeToPath(UnicodeString Path);
|
||||
virtual UnicodeString __fastcall NodePath(TTreeNode * Node);
|
||||
virtual bool __fastcall NodeIsRecycleBin(TTreeNode * Node);
|
||||
virtual bool __fastcall NodePathExists(TTreeNode * Node);
|
||||
@@ -73,6 +74,7 @@ protected:
|
||||
|
||||
virtual void __fastcall ValidateDirectoryEx(TTreeNode * Node,
|
||||
TRecursiveScan Recurse, bool NewDirs);
|
||||
virtual void __fastcall ValidateCurrentDirectoryIfNotMonitoring();
|
||||
void LoadNodeState(TTreeNode * Node, const UnicodeString & Path);
|
||||
|
||||
virtual void __fastcall RebuildTree();
|
||||
|
||||
@@ -134,7 +134,6 @@ type
|
||||
function DDSourceEffects: TDropEffectSet; virtual; abstract;
|
||||
|
||||
function NodePath(Node: TTreeNode): string; virtual; abstract;
|
||||
function NodeIsRecycleBin(Node: TTreeNode): Boolean; virtual;
|
||||
function NodePathExists(Node: TTreeNode): Boolean; virtual;
|
||||
function NodeColor(Node: TTreeNode): TColor; virtual; abstract;
|
||||
function NodeCanDrag(Node: TTreeNode): Boolean; virtual;
|
||||
@@ -170,6 +169,17 @@ type
|
||||
CallBackFunc: TCallBackFunc; Recurse: TRecursiveScan;
|
||||
ScanStartNode: TScanStartNode; Data: Pointer): Boolean;
|
||||
function NodePathName(Node: TTreeNode): string; virtual; abstract;
|
||||
function NodeIsRecycleBin(Node: TTreeNode): Boolean; virtual;
|
||||
|
||||
function FindNodeToPath(Path: string): TTreeNode; virtual; abstract;
|
||||
function TryFindNodeToPath(Path: string): TTreeNode; virtual;
|
||||
procedure ValidateCurrentDirectoryIfNotMonitoring; virtual;
|
||||
procedure StartWatchThread; virtual;
|
||||
procedure StopWatchThread; virtual;
|
||||
procedure SuspendChangeTimer; virtual;
|
||||
procedure ResumeChangeTimer; virtual;
|
||||
procedure EmptyClipboardIfCut; virtual;
|
||||
procedure DirHasNoChildren(Path: string); virtual;
|
||||
|
||||
property DragDropFilesEx: TCustomizableDragDropFilesEx read FDragDropFilesEx;
|
||||
property UseSystemContextMenu: Boolean read FUseSystemContextMenu
|
||||
@@ -1280,4 +1290,45 @@ begin
|
||||
DoBusy(-1);
|
||||
end;
|
||||
|
||||
function TCustomDriveView.TryFindNodeToPath(Path: string): TTreeNode;
|
||||
begin
|
||||
Assert(False);
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.ValidateCurrentDirectoryIfNotMonitoring;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.StartWatchThread;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.StopWatchThread;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.SuspendChangeTimer;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.ResumeChangeTimer;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.EmptyClipboardIfCut;
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
procedure TCustomDriveView.DirHasNoChildren(Path: string);
|
||||
begin
|
||||
Assert(False);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -386,7 +386,7 @@ procedure CheckCanOpenDirectory(Path: string);
|
||||
implementation
|
||||
|
||||
uses
|
||||
DriveView, OperationWithTimeout,
|
||||
OperationWithTimeout,
|
||||
PIDL, Forms, Dialogs,
|
||||
ComObj,
|
||||
ActiveX, ImgList,
|
||||
@@ -1239,7 +1239,6 @@ var
|
||||
DosError: Integer;
|
||||
DirsCount: Integer;
|
||||
SelTreeNode: TTreeNode;
|
||||
Node: TTreeNode;
|
||||
Drive: string;
|
||||
begin
|
||||
FHiddenCount := 0;
|
||||
@@ -1263,11 +1262,11 @@ begin
|
||||
if DirOK then
|
||||
begin
|
||||
if Assigned(FDriveView) then
|
||||
SelTreeNode := TDriveView(FDriveView).FindNodeToPath(FPath)
|
||||
SelTreeNode := FDriveView.FindNodeToPath(FPath)
|
||||
else SelTreeNode := nil;
|
||||
|
||||
if Assigned(FDriveView) and Assigned(SelTreeNode) then
|
||||
FIsRecycleBin := TNodeData(SelTreeNode.Data).IsRecycleBin
|
||||
FIsRecycleBin := FDriveView.NodeIsRecycleBin(SelTreeNode)
|
||||
else
|
||||
FIsRecycleBin :=
|
||||
(Uppercase(Copy(FPath, 2, 10)) = ':\RECYCLED') or
|
||||
@@ -1322,18 +1321,9 @@ begin
|
||||
SysUtils.FindClose(SRec);
|
||||
|
||||
// Update TDriveView's subdir indicator:
|
||||
if Assigned(FDriveView) and (FDriveType = DRIVE_REMOTE) then
|
||||
if Assigned(FDriveView) and (FDriveType = DRIVE_REMOTE) and (DirsCount = 0) then
|
||||
begin
|
||||
Node := TDriveView(FDriveView).FindNodeToPath(PathName);
|
||||
if Assigned(Node) and Assigned(Node.Data) and
|
||||
not TNodeData(Node.Data).Scanned then
|
||||
begin
|
||||
if DirsCount = 0 then
|
||||
begin
|
||||
Node.HasChildren := False;
|
||||
TNodeData(Node.Data).Scanned := True;
|
||||
end;
|
||||
end;
|
||||
FDriveView.DirHasNoChildren(PathName);
|
||||
end;
|
||||
end; // not isRecycleBin
|
||||
end
|
||||
@@ -1568,7 +1558,7 @@ begin
|
||||
|
||||
if Assigned(FDriveView) then
|
||||
begin
|
||||
TDriveView(FDriveView).ValidateCurrentDirectoryIfNotMonitoring;
|
||||
FDriveView.ValidateCurrentDirectoryIfNotMonitoring;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -2075,7 +2065,7 @@ begin
|
||||
if WatchForChanges then StopWatchThread;
|
||||
|
||||
if Assigned(FDriveView) then
|
||||
TDriveView(FDriveView).StopWatchThread;
|
||||
FDriveView.StopWatchThread;
|
||||
|
||||
StopIconUpdateThread;
|
||||
try
|
||||
@@ -2107,7 +2097,7 @@ begin
|
||||
begin
|
||||
if Assigned(DriveView.Selected) then
|
||||
DriveView.ValidateDirectory(DriveView.Selected);
|
||||
TDriveView(FDriveView).StartWatchThread;
|
||||
FDriveView.StartWatchThread;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -2879,7 +2869,7 @@ begin
|
||||
|
||||
StopWatchThread;
|
||||
if IsDirectory and Assigned(FDriveView) then
|
||||
TDriveView(FDriveView).StopWatchThread;
|
||||
FDriveView.StopWatchThread;
|
||||
|
||||
FFileOperator.Flags := FileOperatorDefaultFlags + [foNoConfirmation];
|
||||
FFileOperator.Operation := foRename;
|
||||
@@ -2935,7 +2925,7 @@ begin
|
||||
if FWatchForChanges and (not WatchThreadActive) then
|
||||
StartWatchThread;
|
||||
if Assigned(FDriveView) then
|
||||
TDriveView(FDriveView).StartWatchThread;
|
||||
FDriveView.StartWatchThread;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -3033,7 +3023,7 @@ begin
|
||||
// This typically happens when right-dragging from remote to local panel,
|
||||
// what causes temp directory being created+deleted.
|
||||
// This is HACK, we should implement some uniform watch disabling/enabling
|
||||
TDriveView(FDriveView).SuspendChangeTimer;
|
||||
FDriveView.SuspendChangeTimer;
|
||||
end;
|
||||
|
||||
inherited;
|
||||
@@ -3049,7 +3039,7 @@ begin
|
||||
|
||||
if Assigned(FDriveView) then
|
||||
begin
|
||||
TDriveView(FDriveView).ResumeChangeTimer;
|
||||
FDriveView.ResumeChangeTimer;
|
||||
end;
|
||||
|
||||
inherited;
|
||||
@@ -3173,7 +3163,7 @@ begin
|
||||
StopWatchThread;
|
||||
|
||||
if Assigned(DriveView) then
|
||||
TDriveView(DriveView).StopWatchThread;
|
||||
DriveView.StopWatchThread;
|
||||
|
||||
if (DropSourceControl <> Self) and
|
||||
(DropSourceControl is TDirView) then
|
||||
@@ -3214,15 +3204,14 @@ begin
|
||||
|
||||
if Assigned(FDriveView) and SourceIsDirectory then
|
||||
begin
|
||||
var ADriveView := TDriveView(FDriveView);
|
||||
try
|
||||
ADriveView.ValidateDirectory(ADriveView.FindNodeToPath(TargetPath));
|
||||
FDriveView.ValidateDirectory(FDriveView.FindNodeToPath(TargetPath));
|
||||
except
|
||||
end;
|
||||
|
||||
if (Effect = DROPEFFECT_MOVE) or IsRecycleBin then
|
||||
try
|
||||
Node := ADriveView.TryFindNodeToPath(SourcePath);
|
||||
Node := FDriveView.TryFindNodeToPath(SourcePath);
|
||||
// If the path is not even in the tree, do not bother.
|
||||
// This is particularly for dragging from remote folder, when the source path in %TEMP% and
|
||||
// calling ValidateDirectory would load whole TEMP (and typically also "C:\Users")
|
||||
@@ -3230,7 +3219,7 @@ begin
|
||||
begin
|
||||
if Assigned(Node.Parent) then
|
||||
Node := Node.Parent;
|
||||
ADriveView.ValidateDirectory(Node);
|
||||
FDriveView.ValidateDirectory(Node);
|
||||
end;
|
||||
except
|
||||
end;
|
||||
@@ -3239,7 +3228,7 @@ begin
|
||||
FFileOperator.OperandFrom.Clear;
|
||||
FFileOperator.OperandTo.Clear;
|
||||
if Assigned(FDriveView) then
|
||||
TDriveView(FDriveView).StartWatchThread;
|
||||
FDriveView.StartWatchThread;
|
||||
Sleep(0);
|
||||
WatchForChanges := OldWatchForChanges;
|
||||
if (DropSourceControl <> Self) and (DropSourceControl is TDirView) then
|
||||
@@ -3274,10 +3263,9 @@ begin
|
||||
end;
|
||||
FAnyCut := False;
|
||||
end;
|
||||
if Assigned(FDriveView) and
|
||||
(TDriveView(FDriveView).LastPathCut <> '') then // prevent recursion
|
||||
if Assigned(FDriveView) then
|
||||
begin
|
||||
TDriveView(FDriveView).EmptyClipboard;
|
||||
FDriveView.EmptyClipboardIfCut;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@@ -257,7 +257,6 @@ type
|
||||
procedure SetCustomDirView(Value: TCustomDirView); override;
|
||||
|
||||
function NodePath(Node: TTreeNode): string; override;
|
||||
function NodeIsRecycleBin(Node: TTreeNode): Boolean; override;
|
||||
function NodePathExists(Node: TTreeNode): Boolean; override;
|
||||
function NodeColor(Node: TTreeNode): TColor; override;
|
||||
function FindPathNode(Path: string): TTreeNode; override;
|
||||
@@ -282,8 +281,8 @@ type
|
||||
|
||||
property DragImageList: TDragImageList read FDragImageList;
|
||||
|
||||
property LastPathCut: string read FLastPathCut;
|
||||
procedure EmptyClipboard; dynamic;
|
||||
procedure EmptyClipboardIfCut; override;
|
||||
// Drive handling:
|
||||
function GetDriveStatus(Drive: string): TDriveStatus;
|
||||
function GetDriveTypetoNode(Node: TTreeNode): Integer; // Returns DRIVE_CDROM etc..
|
||||
@@ -294,12 +293,14 @@ type
|
||||
|
||||
// Node handling:
|
||||
procedure SetImageIndex(Node: TTreeNode); virtual;
|
||||
function FindNodeToPath(Path: string): TTreeNode;
|
||||
function TryFindNodeToPath(Path: string): TTreeNode;
|
||||
function FindNodeToPath(Path: string): TTreeNode; override;
|
||||
function TryFindNodeToPath(Path: string): TTreeNode; override;
|
||||
function RootNode(Node: TTreeNode): TTreeNode;
|
||||
function GetDirName(Node: TTreeNode): string;
|
||||
function GetDisplayName(Node: TTreeNode): string;
|
||||
function NodePathName(Node: TTreeNode): string; override;
|
||||
function NodeIsRecycleBin(Node: TTreeNode): Boolean; override;
|
||||
procedure DirHasNoChildren(Path: string); override;
|
||||
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@@ -310,13 +311,13 @@ type
|
||||
procedure DisplayPropertiesMenu(Node: TTreeNode); override;
|
||||
|
||||
// Watchthread handling:
|
||||
procedure StartWatchThread;
|
||||
procedure StopWatchThread;
|
||||
procedure SuspendChangeTimer;
|
||||
procedure ResumeChangeTimer;
|
||||
procedure StartWatchThread; override;
|
||||
procedure StopWatchThread; override;
|
||||
procedure SuspendChangeTimer; override;
|
||||
procedure ResumeChangeTimer; override;
|
||||
procedure StartAllWatchThreads;
|
||||
procedure StopAllWatchThreads;
|
||||
procedure ValidateCurrentDirectoryIfNotMonitoring;
|
||||
procedure ValidateCurrentDirectoryIfNotMonitoring; override;
|
||||
|
||||
(* Modified Events: *)
|
||||
procedure GetImageIndex(Node: TTreeNode); override;
|
||||
@@ -2925,6 +2926,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDriveView.EmptyClipboardIfCut;
|
||||
begin
|
||||
// interface for TDirView - prevent recursion
|
||||
if FLastPathCut <> '' then
|
||||
begin
|
||||
EmptyClipboard;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDriveView.CanPasteFromClipBoard: Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
@@ -2965,4 +2975,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDriveView.DirHasNoChildren(Path: string);
|
||||
begin
|
||||
var Node := FindNodeToPath(Path);
|
||||
if Assigned(Node) and Assigned(Node.Data) and (not TNodeData(Node.Data).Scanned) then
|
||||
begin
|
||||
Node.HasChildren := False;
|
||||
TNodeData(Node.Data).Scanned := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user