ADD: The ability to unpack in the parent directory with drag-and-drop. Issue [0000322].

This commit is contained in:
cobines 2012-05-05 13:13:34 +00:00
commit e7eb0a4826
3 changed files with 95 additions and 60 deletions

View file

@ -276,6 +276,7 @@ type
property Active: Boolean read FActive write SetActive;
property FilePropertiesNeeded: TFilePropertiesTypes read FFilePropertiesNeeded write FFilePropertiesNeeded;
property History: TFileViewHistory read FHistory;
property LastActiveFile: String read FLastActiveFile write FLastActiveFile;
property RequestedActiveFile: String read FRequestedActiveFile write FRequestedActiveFile;
property SortingForSorter: TFileSortings read GetSortingForSorter;
@ -472,6 +473,7 @@ type
DropIntoDirectories: Boolean;
SourcePanel: TFileView;
TargetPanel: TFileView;
TargetFileSource: IFileSource;
TargetPath: String;
constructor Create(var aFiles: TFiles;
@ -480,6 +482,7 @@ type
aDropIntoDirectories: Boolean;
aSourcePanel: TFileView;
aTargetPanel: TFileView;
aTargetFileSource: IFileSource;
aTargetPath: String);
destructor Destroy; override;
@ -2899,6 +2902,7 @@ constructor TDropParams.Create(
aDropIntoDirectories: Boolean;
aSourcePanel: TFileView;
aTargetPanel: TFileView;
aTargetFileSource: IFileSource;
aTargetPath: String);
begin
Files := aFiles;
@ -2908,6 +2912,7 @@ begin
DropIntoDirectories := aDropIntoDirectories;
SourcePanel := aSourcePanel;
TargetPanel := aTargetPanel;
TargetFileSource := aTargetFileSource;
TargetPath := aTargetPath;
end;

View file

@ -200,6 +200,7 @@ var
ClientDropPoint: TPoint;
FileIndex: PtrInt;
AtFileList: Boolean;
FileSourceIndex, PathIndex: Integer;
begin
try
with DropParams do
@ -216,13 +217,36 @@ begin
begin
AFile := FFiles[FileIndex];
// If dropped into a directory modify destination path accordingly.
// If dropped into a directory modify destination path and file source accordingly.
if Assigned(AFile) and
(AFile.FSFile.IsDirectory or AFile.FSFile.IsLinkToDirectory) then
begin
if AFile.FSFile.Name = '..' then
// remove the last subdirectory in the path
TargetPath := TargetPanel.FileSource.GetParentDir(TargetPath)
begin
if TargetFileSource.IsPathAtRoot(CurrentPath) then
begin
// Change to previous file source and last path.
FileSourceIndex := History.CurrentFileSourceIndex - 1;
if FileSourceIndex < 0 then
TargetFileSource := nil // No parent file sources.
else
begin
PathIndex := History.PathsCount[FileSourceIndex] - 1;
if PathIndex < 0 then
TargetFileSource := nil // No paths.
else
begin
TargetFileSource := FileSources[FileSourceIndex];
TargetPath := History.Path[FileSourceIndex, PathIndex];
end;
end;
end
else
begin
// Remove the last subdirectory in the path.
TargetPath := TargetFileSource.GetParentDir(TargetPath);
end;
end
else
TargetPath := TargetPath + AFile.FSFile.Name + DirectorySeparator;
end;
@ -315,8 +339,8 @@ begin
SourcePanel.FMainControlLastMouseButton),
MainControl.ClientToScreen(Classes.Point(X, Y)),
True,
SourcePanel,
Self, Self.CurrentPath);
SourcePanel, Self,
Self.FileSource, Self.CurrentPath);
frmMain.DropFiles(DropParams);
SetDropFileIndex(-1);
@ -830,7 +854,7 @@ begin
try
DropParams := TDropParams.Create(
AFiles, DropEffect, ScreenPoint, True,
nil, Self, Self.CurrentPath);
nil, Self, Self.FileSource, Self.CurrentPath);
frmMain.DropFiles(DropParams);
except

View file

@ -1306,6 +1306,7 @@ begin
GetDropEffectByKeyAndMouse(GetKeyShiftState, mbLeft),
Point, False,
nil, TargetFileView,
TargetFileView.FileSource,
TargetFileView.CurrentPath);
DropFiles(DropParams);
@ -1360,71 +1361,76 @@ begin
try
with DropParams do
begin
case Operation of
if Assigned(TargetFileSource) then
begin
case Operation of
ddoMove:
if GetDragDropType = ddtInternal then
begin
if Self.MoveFiles(SourcePanel.FileSource,
TargetPanel.FileSource,
Files, TargetPath,
gShowDialogOnDragDrop) then
ddoMove:
if GetDragDropType = ddtInternal then
begin
SourcePanel.MarkFiles(False);
end;
end
else
begin
Self.MoveFiles(TFileSystemFileSource.GetFileSource,
TargetPanel.FileSource,
Files, TargetPath,
gShowDialogOnDragDrop);
end;
ddoCopy:
if GetDragDropType = ddtInternal then
begin
if Self.CopyFiles(SourcePanel.FileSource,
TargetPanel.FileSource,
Files, TargetPath,
gShowDialogOnDragDrop) then
begin
SourcePanel.MarkFiles(False);
end;
end
else
begin
Self.CopyFiles(TFileSystemFileSource.GetFileSource,
TargetPanel.FileSource,
Files, TargetPath,
gShowDialogOnDragDrop);
end;
ddoSymLink, ddoHardLink:
begin
// Only for filesystem.
if ((GetDragDropType = ddtExternal) or
(SourcePanel.FileSource.IsClass(TFileSystemFileSource)))
and (TargetPanel.FileSource.IsClass(TFileSystemFileSource)) then
begin
// TODO: process multiple files
SourceFileName := Files.Items[0].FullPath;
TargetFileName := TargetPath + ExtractFileName(SourceFileName);
if ((Operation = ddoSymLink) and
ShowSymLinkForm(SourceFileName, TargetFileName, TargetPath))
or ((Operation = ddoHardLink) and
ShowHardLinkForm(SourceFileName, TargetFileName, TargetPath))
then
TargetPanel.Reload;
if Self.MoveFiles(SourcePanel.FileSource,
TargetFileSource,
Files, TargetPath,
gShowDialogOnDragDrop) then
begin
SourcePanel.MarkFiles(False);
end;
end
else
begin
msgWarning(rsMsgErrNotSupported);
Self.MoveFiles(TFileSystemFileSource.GetFileSource,
TargetFileSource,
Files, TargetPath,
gShowDialogOnDragDrop);
end;
end;
end;
ddoCopy:
if GetDragDropType = ddtInternal then
begin
if Self.CopyFiles(SourcePanel.FileSource,
TargetFileSource,
Files, TargetPath,
gShowDialogOnDragDrop) then
begin
SourcePanel.MarkFiles(False);
end;
end
else
begin
Self.CopyFiles(TFileSystemFileSource.GetFileSource,
TargetFileSource,
Files, TargetPath,
gShowDialogOnDragDrop);
end;
ddoSymLink, ddoHardLink:
begin
// Only for filesystem.
if ((GetDragDropType = ddtExternal) or
(SourcePanel.FileSource.IsClass(TFileSystemFileSource)))
and (TargetFileSource.IsClass(TFileSystemFileSource)) then
begin
// TODO: process multiple files
SourceFileName := Files.Items[0].FullPath;
TargetFileName := TargetPath + ExtractFileName(SourceFileName);
if ((Operation = ddoSymLink) and
ShowSymLinkForm(SourceFileName, TargetFileName, TargetPath))
or ((Operation = ddoHardLink) and
ShowHardLinkForm(SourceFileName, TargetFileName, TargetPath))
then
TargetFileSource.Reload(TargetPath);
end
else
begin
msgWarning(rsMsgErrNotSupported);
end;
end;
end;
end
else
msgWarning(rsMsgErrNotSupported);
end;
finally