mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Reset position of cursor only after loading file list, not every time display file list changes. Bug [0000482].
This commit is contained in:
parent
82725ec92b
commit
a4f6cfc96c
5 changed files with 94 additions and 76 deletions
|
|
@ -58,11 +58,12 @@ type
|
|||
protected
|
||||
procedure CreateDefault(AOwner: TWinControl); override;
|
||||
procedure BeforeMakeFileList; override;
|
||||
procedure AfterMakeFileList; override;
|
||||
procedure ClearAfterDragDrop; override;
|
||||
procedure AfterChangePath; override;
|
||||
procedure DisplayFileListChanged; override;
|
||||
procedure DoMainControlShowHint(FileIndex: PtrInt; X, Y: Integer); override;
|
||||
procedure DoOnResize; override;
|
||||
procedure FileSourceFileListLoaded; override;
|
||||
function GetActiveFileIndex: PtrInt; override;
|
||||
function GetFileIndexFromCursor(X, Y: Integer; out AtFileList: Boolean): PtrInt; override;
|
||||
function GetFileRect(FileIndex: PtrInt): TRect; override;
|
||||
|
|
@ -762,6 +763,23 @@ begin
|
|||
Notify([fvnVisibleFilePropertiesChanged]);
|
||||
end;
|
||||
|
||||
procedure TBriefFileView.DisplayFileListChanged;
|
||||
begin
|
||||
dgPanel.CalculateColRowCount;
|
||||
dgPanel.CalculateColumnWidth;
|
||||
SetFilesDisplayItems;
|
||||
|
||||
if SetActiveFileNow(RequestedActiveFile) then
|
||||
RequestedActiveFile := ''
|
||||
else
|
||||
// Requested file was not found, restore position to last active file.
|
||||
SetActiveFileNow(LastActiveFile);
|
||||
|
||||
Notify([fvnVisibleFilePropertiesChanged]);
|
||||
|
||||
inherited DisplayFileListChanged;
|
||||
end;
|
||||
|
||||
procedure TBriefFileView.CreateDefault(AOwner: TWinControl);
|
||||
begin
|
||||
inherited CreateDefault(AOwner);
|
||||
|
|
@ -787,28 +805,13 @@ begin
|
|||
inherited BeforeMakeFileList;
|
||||
end;
|
||||
|
||||
procedure TBriefFileView.AfterMakeFileList;
|
||||
procedure TBriefFileView.FileSourceFileListLoaded;
|
||||
begin
|
||||
inherited AfterMakeFileList;
|
||||
dgPanel.CalculateColRowCount;
|
||||
dgPanel.CalculateColumnWidth;
|
||||
SetFilesDisplayItems;
|
||||
inherited;
|
||||
|
||||
if SetActiveFileNow(RequestedActiveFile) then
|
||||
RequestedActiveFile := ''
|
||||
else
|
||||
begin
|
||||
// Requested file was not found, restore position to last active file.
|
||||
if not SetActiveFileNow(LastActiveFile) then
|
||||
begin
|
||||
// Or set top position if no LastActiveFile.
|
||||
FUpdatingActiveFile := True;
|
||||
dgPanel.MoveExtend(False, 0, 0);
|
||||
FUpdatingActiveFile := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
Notify([fvnVisibleFilePropertiesChanged]);
|
||||
FUpdatingActiveFile := True;
|
||||
dgPanel.MoveExtend(False, 0, 0);
|
||||
FUpdatingActiveFile := False;
|
||||
end;
|
||||
|
||||
procedure TBriefFileView.ClearAfterDragDrop;
|
||||
|
|
|
|||
|
|
@ -88,10 +88,6 @@ type
|
|||
procedure MakeVisible(iRow: Integer);
|
||||
procedure MakeActiveVisible;
|
||||
|
||||
{en
|
||||
Updates GUI after the display file list has changed.
|
||||
}
|
||||
procedure DisplayFileListHasChanged;
|
||||
{en
|
||||
Format and cache all columns strings.
|
||||
}
|
||||
|
|
@ -134,12 +130,13 @@ type
|
|||
procedure CreateDefault(AOwner: TWinControl); override;
|
||||
|
||||
procedure BeforeMakeFileList; override;
|
||||
procedure AfterMakeFileList; override;
|
||||
procedure ClearAfterDragDrop; override;
|
||||
procedure DisplayFileListChanged; override;
|
||||
procedure DoFileUpdated(AFile: TDisplayFile; UpdatedProperties: TFilePropertiesTypes = []); override;
|
||||
procedure DoHandleKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure DoMainControlShowHint(FileIndex: PtrInt; X, Y: Integer); override;
|
||||
procedure DoUpdateView; override;
|
||||
procedure FileSourceFileListLoaded; override;
|
||||
function GetActiveFileIndex: PtrInt; override;
|
||||
function GetFileIndexFromCursor(X, Y: Integer; out AtFileList: Boolean): PtrInt; override;
|
||||
function GetFileRect(FileIndex: PtrInt): TRect; override;
|
||||
|
|
@ -950,13 +947,16 @@ begin
|
|||
dgPanel.FGridState := gsNormal;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.AfterMakeFileList;
|
||||
procedure TColumnsFileView.FileSourceFileListLoaded;
|
||||
begin
|
||||
inherited;
|
||||
DisplayFileListHasChanged;
|
||||
|
||||
FUpdatingActiveFile := True;
|
||||
dgPanel.Row := 0;
|
||||
FUpdatingActiveFile := False;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.DisplayFileListHasChanged;
|
||||
procedure TColumnsFileView.DisplayFileListChanged;
|
||||
begin
|
||||
// Update grid row count.
|
||||
SetRowCount(FFiles.Count);
|
||||
|
|
@ -966,19 +966,12 @@ begin
|
|||
if SetActiveFileNow(RequestedActiveFile) then
|
||||
RequestedActiveFile := ''
|
||||
else
|
||||
begin
|
||||
// Requested file was not found, restore position to last active file.
|
||||
if not SetActiveFileNow(LastActiveFile) then
|
||||
begin
|
||||
// Or set top position if no LastActiveFile.
|
||||
FUpdatingActiveFile := True;
|
||||
dgPanel.Row := 0;
|
||||
FUpdatingActiveFile := False;
|
||||
end;
|
||||
end;
|
||||
SetActiveFileNow(LastActiveFile);
|
||||
|
||||
Notify([fvnVisibleFilePropertiesChanged]);
|
||||
UpdateInfoPanel;
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileView.MakeColumnsStrings(AFile: TDisplayFile);
|
||||
|
|
|
|||
|
|
@ -98,10 +98,6 @@ type
|
|||
procedure MakeVisible(Node: PVirtualNode);
|
||||
procedure DoSelectionChanged(Node: PVirtualNode); overload;
|
||||
|
||||
{en
|
||||
Updates GUI after the display file list has changed.
|
||||
}
|
||||
procedure DisplayFileListHasChanged;
|
||||
{en
|
||||
Format and cache all columns strings for the file.
|
||||
}
|
||||
|
|
@ -154,8 +150,8 @@ type
|
|||
procedure CreateDefault(AOwner: TWinControl); override;
|
||||
|
||||
procedure BeforeMakeFileList; override;
|
||||
procedure AfterMakeFileList; override;
|
||||
procedure ClearAfterDragDrop; override;
|
||||
procedure DisplayFileListChanged; override;
|
||||
procedure DoFileUpdated(AFile: TDisplayFile; UpdatedProperties: TFilePropertiesTypes = []); override;
|
||||
procedure DoHandleKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure DoMainControlShowHint(FileIndex: PtrInt; X, Y: Integer); override;
|
||||
|
|
@ -345,9 +341,7 @@ begin
|
|||
dgPanel.TreeOptions.AutoOptions := dgPanel.TreeOptions.AutoOptions - [toDisableAutoscrollOnFocus];
|
||||
|
||||
if Assigned(Node) then
|
||||
DoFileIndexChanged(Node^.Index)
|
||||
else
|
||||
LastActiveFile := '';
|
||||
DoFileIndexChanged(Node^.Index);
|
||||
end;
|
||||
|
||||
procedure TColumnsFileViewVTV.dgPanelFocusChanging(Sender: TBaseVirtualTree;
|
||||
|
|
@ -1110,13 +1104,7 @@ begin
|
|||
[tsLeftButtonDown, tsMiddleButtonDown, tsRightButtonDown, tsVCLDragging];
|
||||
end;
|
||||
|
||||
procedure TColumnsFileViewVTV.AfterMakeFileList;
|
||||
begin
|
||||
inherited;
|
||||
DisplayFileListHasChanged;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileViewVTV.DisplayFileListHasChanged;
|
||||
procedure TColumnsFileViewVTV.DisplayFileListChanged;
|
||||
var
|
||||
AFocused: Boolean = False;
|
||||
Node: PVirtualNode;
|
||||
|
|
@ -1168,7 +1156,8 @@ begin
|
|||
end;
|
||||
|
||||
Notify([fvnVisibleFilePropertiesChanged]);
|
||||
UpdateInfoPanel;
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TColumnsFileViewVTV.MakeColumnsStrings(AFile: TDisplayFile);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ type
|
|||
fvrqMakeDisplayFileList); // Filtered file list needs to be created
|
||||
TFileViewRequests = set of TFileViewRequest;
|
||||
TFileViewNotification = (fvnDisplayFileListChanged, // Filtered file list was created (filter changed, show/hide hidden files option changed, etc.)
|
||||
fvnFileSourceFileListChanged, // File list was loaded from FileSource
|
||||
fvnFileSourceFileListLoaded, // File list was loaded from FileSource
|
||||
fvnFileSourceFileListUpdated, // File list was updated (files added, removed or updated)
|
||||
fvnSelectionChanged, // Files were selected/deselected
|
||||
fvnVisibleFilePropertiesChanged); // Different files or their properties are now visible
|
||||
TFileViewNotifications = set of TFileViewNotification;
|
||||
|
|
@ -197,8 +198,21 @@ type
|
|||
const UserData: Pointer);
|
||||
procedure CancelLastPathChange;
|
||||
procedure ClearFiles;
|
||||
{en
|
||||
Called when display file list (filtered list) has changed.
|
||||
}
|
||||
procedure DisplayFileListChanged; virtual;
|
||||
procedure EndUpdate;
|
||||
procedure EnsureDisplayProperties; virtual; abstract;
|
||||
{en
|
||||
Called after file list has been retrieved from file source.
|
||||
Runs from GUI thread.
|
||||
}
|
||||
procedure FileSourceFileListLoaded; virtual;
|
||||
{en
|
||||
Called when files were added, removed or updated in the filesource file list.
|
||||
}
|
||||
procedure FileSourceFileListUpdated; virtual;
|
||||
function GetCurrentPath: String; virtual;
|
||||
procedure SetCurrentPath(NewPath: String); virtual;
|
||||
function GetActiveDisplayFile: TDisplayFile; virtual; abstract;
|
||||
|
|
@ -219,11 +233,6 @@ type
|
|||
}
|
||||
procedure SetActiveFile(const aFile: TFile); virtual; overload;
|
||||
|
||||
{en
|
||||
Executed after file list has been retrieved.
|
||||
Runs from GUI thread.
|
||||
}
|
||||
procedure AfterMakeFileList; virtual;
|
||||
{en
|
||||
Executed before file list has been retrieved.
|
||||
Runs from GUI thread.
|
||||
|
|
@ -705,7 +714,7 @@ begin
|
|||
if Assigned(Self.FAllDisplayFiles) then
|
||||
begin
|
||||
AFileView.FAllDisplayFiles := Self.FAllDisplayFiles.Clone(True);
|
||||
AFileView.Notify([fvnFileSourceFileListChanged]);
|
||||
AFileView.Notify([fvnFileSourceFileListLoaded]);
|
||||
AFileView.Request([fvrqHashFileList]);
|
||||
end;
|
||||
|
||||
|
|
@ -839,6 +848,11 @@ begin
|
|||
Result := AColor;
|
||||
end;
|
||||
|
||||
procedure TFileView.DisplayFileListChanged;
|
||||
begin
|
||||
// Empty.
|
||||
end;
|
||||
|
||||
procedure TFileView.DoActiveChanged;
|
||||
begin
|
||||
// Empty.
|
||||
|
|
@ -905,6 +919,16 @@ begin
|
|||
Result := Assigned(FAllDisplayFiles);
|
||||
end;
|
||||
|
||||
procedure TFileView.FileSourceFileListLoaded;
|
||||
begin
|
||||
FLoadingFileListLongTimer.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TFileView.FileSourceFileListUpdated;
|
||||
begin
|
||||
// Empty.
|
||||
end;
|
||||
|
||||
procedure TFileView.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
|
|
@ -972,10 +996,10 @@ begin
|
|||
begin
|
||||
InsertFile(ADisplayFile, FFiles, NewFilesPosition);
|
||||
VisualizeFileUpdate(ADisplayFile);
|
||||
Notify([fvnFileSourceFileListChanged, fvnDisplayFileListChanged]);
|
||||
Notify([fvnFileSourceFileListUpdated, fvnDisplayFileListChanged]);
|
||||
end
|
||||
else
|
||||
Notify([fvnFileSourceFileListChanged]);
|
||||
Notify([fvnFileSourceFileListUpdated]);
|
||||
end
|
||||
else
|
||||
UpdateFile(FileName, APath, NewFilesPosition, UpdatedFilesPosition);
|
||||
|
|
@ -998,7 +1022,7 @@ begin
|
|||
FAllDisplayFiles.Remove(ADisplayFile);
|
||||
if Assigned(FRecentlyUpdatedFiles) then
|
||||
FRecentlyUpdatedFiles.Remove(ADisplayFile);
|
||||
Notify([fvnFileSourceFileListChanged, fvnDisplayFileListChanged]);
|
||||
Notify([fvnFileSourceFileListUpdated, fvnDisplayFileListChanged]);
|
||||
end;
|
||||
|
||||
procedure TFileView.RenameFile(const NewFileName, OldFileName, APath: String; NewFilesPosition: TNewFilesPosition; UpdatedFilesPosition: TUpdatedFilesPosition);
|
||||
|
|
@ -1022,7 +1046,7 @@ begin
|
|||
ADisplayFile.DisplayStrings.Clear;
|
||||
ResortFile(ADisplayFile, FAllDisplayFiles);
|
||||
|
||||
ANotifications := [fvnFileSourceFileListChanged];
|
||||
ANotifications := [fvnFileSourceFileListUpdated];
|
||||
case ApplyFilter(ADisplayFile, NewFilesPosition) of
|
||||
fvaprInserted, fvaprRemoved:
|
||||
Include(ANotifications, fvnDisplayFileListChanged);
|
||||
|
|
@ -1141,7 +1165,7 @@ begin
|
|||
end;
|
||||
ADisplayFile.DisplayStrings.Clear;
|
||||
|
||||
ANotifications := [fvnFileSourceFileListChanged];
|
||||
ANotifications := [fvnFileSourceFileListUpdated];
|
||||
case ApplyFilter(ADisplayFile, NewFilesPosition) of
|
||||
fvaprInserted, fvaprRemoved:
|
||||
Include(ANotifications, fvnDisplayFileListChanged);
|
||||
|
|
@ -1783,11 +1807,6 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TFileView.AfterMakeFileList;
|
||||
begin
|
||||
FLoadingFileListLongTimer.Enabled := False;
|
||||
end;
|
||||
|
||||
function TFileView.ApplyFilter(ADisplayFile: TDisplayFile; NewFilesPosition: TNewFilesPosition): TFileViewApplyFilterResult;
|
||||
var
|
||||
bFilterOut: Boolean;
|
||||
|
|
@ -2661,15 +2680,22 @@ begin
|
|||
try
|
||||
while FNotifications <> [] do
|
||||
begin
|
||||
if fvnFileSourceFileListChanged in FNotifications then
|
||||
if fvnFileSourceFileListLoaded in FNotifications then
|
||||
begin
|
||||
FNotifications := FNotifications - [fvnFileSourceFileListChanged];
|
||||
FNotifications := FNotifications - [fvnFileSourceFileListLoaded];
|
||||
FileSourceFileListLoaded;
|
||||
DoOnFileListChanged;
|
||||
end
|
||||
else if fvnFileSourceFileListUpdated in FNotifications then
|
||||
begin
|
||||
FNotifications := FNotifications - [fvnFileSourceFileListUpdated];
|
||||
FileSourceFileListUpdated;
|
||||
DoOnFileListChanged;
|
||||
end
|
||||
else if fvnDisplayFileListChanged in FNotifications then
|
||||
begin
|
||||
FNotifications := FNotifications - [fvnDisplayFileListChanged];
|
||||
AfterMakeFileList;
|
||||
DisplayFileListChanged;
|
||||
StartRecentlyUpdatedTimerIfNeeded;
|
||||
end
|
||||
else if fvnVisibleFilePropertiesChanged in FNotifications then
|
||||
|
|
@ -2767,7 +2793,7 @@ begin
|
|||
else
|
||||
ClearPendingFilesChanges;
|
||||
Request(ARequests);
|
||||
Notify([fvnFileSourceFileListChanged, fvnDisplayFileListChanged]);
|
||||
Notify([fvnFileSourceFileListLoaded, fvnDisplayFileListChanged]);
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ type
|
|||
|
||||
procedure AfterChangePath; override;
|
||||
procedure CreateDefault(AOwner: TWinControl); override;
|
||||
procedure DisplayFileListChanged; override;
|
||||
procedure DoActiveChanged; override;
|
||||
procedure DoSelectionChanged; override;
|
||||
procedure DoUpdateView; override;
|
||||
|
|
@ -108,6 +109,12 @@ begin
|
|||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TFileViewWithPanels.DisplayFileListChanged;
|
||||
begin
|
||||
inherited DisplayFileListChanged;
|
||||
UpdateInfoPanel;
|
||||
end;
|
||||
|
||||
procedure TFileViewWithPanels.DoActiveChanged;
|
||||
begin
|
||||
inherited DoActiveChanged;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue