mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Refresh a file list after file rename in the flat view mode (issue #1322)
This commit is contained in:
parent
76a5f8025b
commit
4265a6089b
2 changed files with 20 additions and 7 deletions
|
|
@ -241,6 +241,7 @@ type
|
|||
}
|
||||
procedure CreateDefault(AOwner: TWinControl); virtual;
|
||||
|
||||
procedure PushRenameEvent(AFile: TFile; const NewFileName: String);
|
||||
procedure AddWorker(const Worker: TFileViewWorker; SetEvents: Boolean = True);
|
||||
procedure BeginUpdate;
|
||||
procedure CalculateSpace(AFile: TDisplayFile);
|
||||
|
|
@ -1083,6 +1084,7 @@ begin
|
|||
AFile.Name := FileName;
|
||||
try
|
||||
FileSource.RetrieveProperties(AFile, FilePropertiesNeeded, GetVariantFileProperties);
|
||||
if FFlatView and AFile.IsDirectory then raise EFileSourceException.Create(EmptyStr);
|
||||
except
|
||||
on EFileSourceException do
|
||||
begin
|
||||
|
|
@ -1396,6 +1398,11 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TFileView.PushRenameEvent(AFile: TFile; const NewFileName: String);
|
||||
begin
|
||||
Self.RenameFile(NewFileName, AFile.Name, AFile.Path, gNewFilesPosition, gUpdatedFilesPosition);
|
||||
end;
|
||||
|
||||
procedure TFileView.AddWorker(const Worker: TFileViewWorker; SetEvents: Boolean = True);
|
||||
begin
|
||||
FFileViewWorkers.Add(Worker);
|
||||
|
|
|
|||
|
|
@ -342,25 +342,31 @@ end;
|
|||
procedure TFileViewWithMainCtrl.edtRenameOnKeyRETURN(Sender: TObject);
|
||||
var
|
||||
NewFileName: String;
|
||||
OldFileNameAbsolute: String;
|
||||
OldFileName: String;
|
||||
begin
|
||||
NewFileName := edtRename.Text;
|
||||
OldFileNameAbsolute := edtRename.Hint;
|
||||
NewFileName := edtRename.Text;
|
||||
OldFileName := ExtractFileName(edtRename.Hint);
|
||||
|
||||
try
|
||||
case RenameFile(FileSource, FRenameFile, NewFileName, True) of
|
||||
case uFileSourceUtil.RenameFile(FileSource, FRenameFile, NewFileName, True) of
|
||||
sfprSuccess:
|
||||
begin
|
||||
edtRename.Visible:=False;
|
||||
// FRenameFile is nil when a file list
|
||||
// already updated by the real 'rename' event
|
||||
if FlatView and Assigned(FRenameFile) then
|
||||
begin
|
||||
PushRenameEvent(FRenameFile, NewFileName);
|
||||
end;
|
||||
edtRename.Visible:= False;
|
||||
SetActiveFile(CurrentPath + NewFileName);
|
||||
SetFocus;
|
||||
end;
|
||||
sfprError:
|
||||
msgError(Format(rsMsgErrRename, [ExtractFileName(OldFileNameAbsolute), NewFileName]));
|
||||
msgError(Format(rsMsgErrRename, [OldFileName, NewFileName]));
|
||||
end;
|
||||
except
|
||||
on e: EInvalidFileProperty do
|
||||
msgError(Format(rsMsgErrRename + ':' + LineEnding + '%s (%s)', [ExtractFileName(OldFileNameAbsolute), NewFileName, rsMsgInvalidFileName, e.Message]));
|
||||
msgError(Format(rsMsgErrRename + ':' + LineEnding + '%s (%s)', [OldFileName, NewFileName, rsMsgInvalidFileName, e.Message]));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue