UPD: Don't clear files before loading file list, disable most of user input while loading file list. Fixes issue [0000282]: Blinking of file list panel while browsing FTP.

This commit is contained in:
cobines 2012-05-12 20:06:10 +00:00
commit 69bfe5f075
6 changed files with 236 additions and 78 deletions

View file

@ -279,19 +279,31 @@ end;
function TBriefDrawGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result:= inherited DoMouseWheelDown(Shift, MousePos);
Result:= Perform(LM_HSCROLL, SB_PAGERIGHT, 0) = 0;
if not BriefView.IsLoadingFileList then
begin
Result:= inherited DoMouseWheelDown(Shift, MousePos);
Result:= Perform(LM_HSCROLL, SB_PAGERIGHT, 0) = 0;
end
else
Result := True; // Handled
end;
function TBriefDrawGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result:= inherited DoMouseWheelUp(Shift, MousePos);
Result:= Perform(LM_HSCROLL, SB_PAGELEFT, 0) = 0;
if not BriefView.IsLoadingFileList then
begin
Result:= inherited DoMouseWheelUp(Shift, MousePos);
Result:= Perform(LM_HSCROLL, SB_PAGELEFT, 0) = 0;
end
else
Result := True; // Handled
end;
procedure TBriefDrawGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
if BriefView.IsLoadingFileList then Exit;
{$IF DECLARED(lcl_fullversion) and (lcl_fullversion >= 093100)}
// Don't scroll partially visible cells on mouse click
Options:= Options + [goDontScrollPartCell];
@ -343,6 +355,8 @@ var
BackgroundClick: Boolean;
Point: TPoint;
begin
if BriefView.IsLoadingFileList then Exit;
{$IF DECLARED(lcl_fullversion) and (lcl_fullversion >= 093100)}
// Don't scroll partially visible cells on mouse click
Options:= Options - [goDontScrollPartCell];
@ -396,6 +410,12 @@ var
FileIndex: Integer;
ACol, ARow: Integer;
begin
if BriefView.IsLoadingFileList then
begin
BriefView.HandleKeyDownWhenLoading(Key, Shift);
Exit;
end;
SavedKey := Key;
// Set RangeSelecting before cursor is moved.
BriefView.FRangeSelecting :=
@ -785,8 +805,16 @@ begin
if SetActiveFileNow(RequestedActiveFile) then
RequestedActiveFile := ''
else
begin
// Requested file was not found, restore position to last active file.
SetActiveFileNow(LastActiveFile);
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]);
end;
@ -801,11 +829,14 @@ end;
procedure TBriefFileView.AfterChangePath;
begin
FUpdatingActiveFile := True;
dgPanel.MoveExtend(False, 0, 0);
FUpdatingActiveFile := False;
inherited AfterChangePath;
if not IsLoadingFileList then
begin
FUpdatingActiveFile := True;
dgPanel.MoveExtend(False, 0, 0);
FUpdatingActiveFile := False;
end;
end;
function TBriefFileView.GetActiveFileIndex: PtrInt;
@ -903,9 +934,12 @@ procedure TBriefFileView.AddFileSource(aFileSource: IFileSource; aPath: String);
begin
inherited AddFileSource(aFileSource, aPath);
FUpdatingActiveFile := True;
dgPanel.MoveExtend(False, 0, 0);
FUpdatingActiveFile := False;
if not IsLoadingFileList then
begin
FUpdatingActiveFile := True;
dgPanel.MoveExtend(False, 0, 0);
FUpdatingActiveFile := False;
end;
end;
procedure TBriefFileView.LoadConfiguration(AConfig: TXmlConfig; ANode: TXmlNode);
@ -950,8 +984,6 @@ procedure TBriefFileView.SetSorting(const NewSortings: TFileSortings);
begin
inherited SetSorting(NewSortings);
TabHeader.UpdateSorting(NewSortings);
SortAllDisplayFiles;
ReDisplayFileList;
end;
constructor TBriefFileView.Create(AOwner: TWinControl;

View file

@ -210,8 +210,6 @@ procedure TColumnsFileView.SetSorting(const NewSortings: TFileSortings);
begin
inherited SetSorting(NewSortings);
SetColumnsSortDirections;
SortAllDisplayFiles;
ReDisplayFileList;
end;
procedure TColumnsFileView.LoadConfiguration(Section: String; TabIndex: Integer);
@ -355,14 +353,17 @@ var
I: Integer;
begin
Handled:= True;
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEUP, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEUP, 0);
else
Handled:= False;
if not IsLoadingFileList then
begin
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEUP, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEUP, 0);
else
Handled:= False;
end;
end;
end;
@ -372,14 +373,17 @@ var
I: Integer;
begin
Handled:= True;
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEDOWN, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEDOWN, 0);
else
Handled:= False;
if not IsLoadingFileList then
begin
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEDOWN, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEDOWN, 0);
else
Handled:= False;
end;
end;
end;
@ -414,11 +418,14 @@ end;
procedure TColumnsFileView.AfterChangePath;
begin
FUpdatingActiveFile := True;
dgPanel.Row := 0;
FUpdatingActiveFile := False;
inherited AfterChangePath;
if not IsLoadingFileList then
begin
FUpdatingActiveFile := True;
dgPanel.Row := 0;
FUpdatingActiveFile := False;
end;
end;
procedure TColumnsFileView.ShowRenameFileEdit(aFile: TFile);
@ -935,9 +942,12 @@ procedure TColumnsFileView.AddFileSource(aFileSource: IFileSource; aPath: String
begin
inherited AddFileSource(aFileSource, aPath);
FUpdatingActiveFile := True;
dgPanel.Row := 0;
FUpdatingActiveFile := False;
if not IsLoadingFileList then
begin
FUpdatingActiveFile := True;
dgPanel.Row := 0;
FUpdatingActiveFile := False;
end;
end;
procedure TColumnsFileView.BeforeMakeFileList;
@ -980,8 +990,16 @@ begin
if SetActiveFileNow(RequestedActiveFile) then
RequestedActiveFile := ''
else
begin
// Requested file was not found, restore position to last active file.
SetActiveFileNow(LastActiveFile);
if not SetActiveFileNow(LastActiveFile) then
begin
// Or set top position if no LastActiveFile.
FUpdatingActiveFile := True;
dgPanel.Row := 0;
FUpdatingActiveFile := False;
end;
end;
Notify([fvnVisibleFilePropertiesChanged]);
UpdateInfoPanel;
@ -1183,7 +1201,8 @@ procedure TColumnsFileView.cm_RenameOnly(const Params: array of string);
var
aFile: TFile;
begin
if (fsoSetFileProperty in FileSource.GetOperationsTypes) then
if not IsLoadingFileList and
(fsoSetFileProperty in FileSource.GetOperationsTypes) then
begin
aFile:= CloneActiveFile;
if Assigned(aFile) then
@ -1595,7 +1614,8 @@ begin
if gdFixed in aState then
begin
DrawFixed // Draw column headers
DrawFixed; // Draw column headers
DrawCellGrid(aCol,aRow,aRect,aState);
end
else if ColumnsView.FFiles.Count > 0 then
begin
@ -1610,10 +1630,15 @@ begin
DrawIconCell // Draw icon in the first column
else
DrawOtherCell;
end;
DrawCellGrid(aCol,aRow,aRect,aState);
DrawLines;
DrawCellGrid(aCol,aRow,aRect,aState);
DrawLines;
end
else
begin
Canvas.Brush.Color := Self.Color;
Canvas.FillRect(aRect);
end;
end;
procedure TDrawGridEx.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
@ -1624,6 +1649,7 @@ var
MI: TMenuItem;
Background: Boolean;
begin
if ColumnsView.IsLoadingFileList then Exit;
{$IFDEF LCLGTK2}
// Workaround for two doubleclicks being sent on GTK.
// MouseUp event is sent just after doubleclick, so if we drop
@ -1701,6 +1727,7 @@ end;
procedure TDrawGridEx.MouseDown(Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
begin
if ColumnsView.IsLoadingFileList then Exit;
{$IFDEF LCLGTK2}
// Workaround for two doubleclicks being sent on GTK.
// MouseDown event is sent just before doubleclick, so if we drop
@ -1821,6 +1848,12 @@ procedure TDrawGridEx.KeyDown(var Key: Word; Shift: TShiftState);
var
SavedKey: Word;
begin
if ColumnsView.IsLoadingFileList then
begin
ColumnsView.HandleKeyDownWhenLoading(Key, Shift);
Exit;
end;
SavedKey := Key;
// Set RangeSelecting before cursor is moved.
ColumnsView.FRangeSelecting :=

View file

@ -227,8 +227,6 @@ procedure TColumnsFileViewVTV.SetSorting(const NewSortings: TFileSortings);
begin
inherited SetSorting(NewSortings);
SetColumnsSortDirections;
SortAllDisplayFiles;
ReDisplayFileList;
end;
procedure TColumnsFileViewVTV.LoadConfiguration(Section: String; TabIndex: Integer);
@ -532,14 +530,17 @@ var
I: Integer;
begin
Handled:= True;
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEUP, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEUP, 0);
else
Handled:= False;
if not IsLoadingFileList then
begin
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEUP, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEUP, 0);
else
Handled:= False;
end;
end;
end;
@ -549,14 +550,17 @@ var
I: Integer;
begin
Handled:= True;
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEDOWN, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEDOWN, 0);
else
Handled:= False;
if not IsLoadingFileList then
begin
case gScrollMode of
smLineByLine:
for I:= 1 to gWheelScrollLines do
dgPanel.Perform(LM_VSCROLL, SB_LINEDOWN, 0);
smPageByPage:
dgPanel.Perform(LM_VSCROLL, SB_PAGEDOWN, 0);
else
Handled:= False;
end;
end;
end;
@ -1148,6 +1152,7 @@ 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
@ -1183,6 +1188,7 @@ begin
// to the right edge of the column. So, we scroll back here.
// dgPanel.OffsetX := 0;
end;
end;
Notify([fvnVisibleFilePropertiesChanged]);
UpdateInfoPanel;
@ -1400,7 +1406,8 @@ procedure TColumnsFileViewVTV.cm_RenameOnly(const Params: array of string);
var
aFile: TFile;
begin
if (fsoSetFileProperty in FileSource.GetOperationsTypes) then
if not IsLoadingFileList and
(fsoSetFileProperty in FileSource.GetOperationsTypes) then
begin
aFile:= CloneActiveFile;
if Assigned(aFile) then
@ -1612,6 +1619,13 @@ var
begin
Shift := KeyDataToShiftState(Message.KeyData);
SavedKey := Message.CharCode;
if ColumnsView.IsLoadingFileList then
begin
ColumnsView.HandleKeyDownWhenLoading(Message.CharCode, Shift);
Exit;
end;
// Set RangeSelecting before cursor is moved.
ColumnsView.FRangeSelecting :=
(ssShift in Shift) and
@ -1989,6 +2003,8 @@ var
BackgroundClick: Boolean;
Point: TPoint;
begin
if ColumnsView.IsLoadingFileList then Exit;
{$IFDEF LCLGTK2}
// Workaround for two doubleclicks being sent on GTK.
// MouseUp event is sent just after doubleclick, so if we drop
@ -2027,6 +2043,8 @@ end;
procedure TColumnsDrawTree.MouseDown(Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
begin
if ColumnsView.IsLoadingFileList then Exit;
{$IFDEF LCLGTK2}
// Workaround for two doubleclicks being sent on GTK.
// MouseDown event is sent just before doubleclick, so if we drop

View file

@ -189,6 +189,7 @@ type
procedure CalculateSpace(var AFileList: TFVWorkerFileList);
procedure CalculateSpaceOnUpdate(const UpdatedFile: TDisplayFile;
const UserData: Pointer);
procedure ClearFiles;
procedure EndUpdate;
procedure EnsureDisplayProperties; virtual; abstract;
function GetCurrentPath: String; virtual;
@ -196,6 +197,7 @@ type
function GetActiveDisplayFile: TDisplayFile; virtual; abstract;
function GetWorkersThread: TFunctionThread;
procedure InvertFileSelection(AFile: TDisplayFile; bNotify: Boolean = True);
function IsLoadingFileList: Boolean; inline;
function IsVisibleToUser: Boolean;
procedure Notify(NewNotifications: TFileViewNotifications);
procedure PropertiesRetrieverOnUpdate(const UpdatedFile: TDisplayFile;
@ -227,12 +229,17 @@ type
function DimColor(AColor: TColor): TColor;
procedure DoFileUpdated(AFile: TDisplayFile; UpdatedProperties: TFilePropertiesTypes = []); virtual;
procedure DoHandleKeyDown(var Key: Word; Shift: TShiftState); virtual;
{en
Handles keys when file list is being loaded.
}
procedure DoHandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState); virtual;
procedure DoSelectionChanged; virtual;
procedure DoUpdateView; virtual;
{en
Returns current work type in progress.
}
function GetCurrentWorkType: TFileViewWorkType;
procedure HandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState);
function IsActiveItemValid: Boolean;
function IsReferenceValid(aFile: TDisplayFile): Boolean;
{en
@ -854,6 +861,17 @@ begin
end;
end;
procedure TFileView.DoHandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState);
begin
case Key of
VK_BACK:
begin
ChangePathToParent(True);
Key := 0;
end;
end;
end;
function TFileView.FileListLoaded: Boolean;
begin
Result := Assigned(FAllDisplayFiles);
@ -877,6 +895,19 @@ begin
HashFileList;
end;
procedure TFileView.ClearFiles;
begin
if Assigned(FAllDisplayFiles) then
begin
ClearRecentlyUpdatedFiles;
ClearPendingFilesChanges;
FFiles.Clear;
FAllDisplayFiles.Clear; // Clear references to files from the source.
HashFileList;
Notify([fvnDisplayFileListChanged]);
end;
end;
function TFileView.GetNotebookPage: TCustomPage;
begin
if Parent is TCustomPage then
@ -1214,6 +1245,8 @@ var
AFileList: TFVWorkerFileList;
AFile: TDisplayFile;
begin
if IsLoadingFileList then Exit;
AFileList := TFVWorkerFileList.Create;
try
for i := 0 to FFiles.Count - 1 do
@ -1591,6 +1624,11 @@ end;
procedure TFileView.SetSorting(const NewSortings: TFileSortings);
begin
FSortings := CloneSortings(NewSortings);
if not IsLoadingFileList then
begin
SortAllDisplayFiles;
ReDisplayFileList;
end;
end;
procedure TFileView.SortAllDisplayFiles;
@ -1652,15 +1690,7 @@ begin
if gListFilesInThread then
begin
// Clear files.
if Assigned(FAllDisplayFiles) then
begin
ClearRecentlyUpdatedFiles;
FFiles.Clear;
FAllDisplayFiles.Clear; // Clear references to files from the source.
HashFileList;
end;
ClearRecentlyUpdatedFiles;
BeforeMakeFileList;
AThread.QueueFunction(@Worker.StartParam);
end
@ -1750,7 +1780,7 @@ procedure TFileView.ChooseFile(const AFile: TDisplayFile; FolderMode: Boolean =
var
FSFile: TFile;
begin
if Assigned(AFile) then
if Assigned(AFile) and not IsLoadingFileList then
begin
FSFile := AFile.FSFile.Clone;
try
@ -1900,6 +1930,11 @@ begin
Result := False;
end;
function TFileView.IsLoadingFileList: Boolean;
begin
Result := GetCurrentWorkType = fvwtCreate;
end;
function TFileView.Reload(const PathsToReload: TPathsArray = nil): Boolean;
var
i: Integer;
@ -2723,6 +2758,13 @@ begin
end;
end;
procedure TFileView.HandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState);
begin
// Only allow some keys and always zero Key (handled).
DoHandleKeyDownWhenLoading(Key, Shift);
Key := 0;
end;
procedure TFileView.ReloadEvent(const aFileSource: IFileSource; const ReloadedPaths: TPathsArray);
begin
// Reload file view but only if the file source is currently viewed

View file

@ -167,6 +167,8 @@ var
Rect: TRect;
Point: TPoint;
begin
if IsLoadingFileList then Exit;
Rect := GetFileRect(GetActiveFileIndex);
Point.X := Rect.Left + ((Rect.Right - Rect.Left) div 2);
Point.Y := Rect.Top + ((Rect.Bottom - Rect.Top) div 2);
@ -309,6 +311,7 @@ var
FileIndex : PtrInt;
AtFileList: Boolean;
begin
if IsLoadingFileList then Exit;
{$IFDEF LCLGTK2}
// Workaround for two doubleclicks being sent on GTK.
if TooManyDoubleClicks then Exit;
@ -476,6 +479,8 @@ procedure TFileViewWithMainCtrl.MainControlKeyDown(Sender: TObject; var Key: Wor
var
ScreenPoint: TPoint;
begin
if IsLoadingFileList then Exit;
case Key of
VK_APPS:
@ -533,6 +538,8 @@ begin
end;
end;
if IsLoadingFileList then Exit;
if IsFileIndexInRange(FileIndex) then
begin
AFile := FFiles[FileIndex];
@ -722,6 +729,8 @@ end;
procedure TFileViewWithMainCtrl.MainControlMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if IsLoadingFileList then Exit;
FStartDrag := False;
FRangeSelecting := False;
@ -764,6 +773,8 @@ end;
procedure TFileViewWithMainCtrl.MainControlUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
begin
if IsLoadingFileList then Exit;
// check if ShiftState is equal to quick search / filter modes
if quickSearch.CheckSearchOrFilter(UTF8Key) then
Exit;

View file

@ -64,6 +64,7 @@ type
procedure CreateDefault(AOwner: TWinControl); override;
procedure DoFileIndexChanged(NewFileIndex: PtrInt);
procedure DoHandleKeyDown(var Key: Word; Shift: TShiftState); override;
procedure DoHandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState); override;
procedure DoSelectionChanged; override;
procedure DoSelectionChanged(FileIndex: PtrInt);
procedure EnsureDisplayProperties; override;
@ -148,24 +149,26 @@ end;
procedure TOrderedFileView.cm_GoToFirstFile(const Params: array of string);
begin
if not IsEmpty then
if not (IsEmpty or IsLoadingFileList) then
SetActiveFile(0);
end;
procedure TOrderedFileView.cm_GoToLastFile(const Params: array of string);
begin
if not IsEmpty then
if not (IsEmpty or IsLoadingFileList) then
SetActiveFile(FFiles.Count - 1);
end;
procedure TOrderedFileView.cm_QuickFilter(const Params: array of string);
begin
quickSearch.Execute(qsFilter, Params);
if not IsLoadingFileList then
quickSearch.Execute(qsFilter, Params);
end;
procedure TOrderedFileView.cm_QuickSearch(const Params: array of string);
begin
quickSearch.Execute(qsSearch, Params);
if not IsLoadingFileList then
quickSearch.Execute(qsSearch, Params);
end;
procedure TOrderedFileView.CreateDefault(AOwner: TWinControl);
@ -264,6 +267,25 @@ begin
inherited DoHandleKeyDown(Key, Shift);
end;
procedure TOrderedFileView.DoHandleKeyDownWhenLoading(var Key: Word; Shift: TShiftState);
var
bClear: Boolean;
begin
case Key of
VK_ESCAPE:
if GetCurrentWorkType <> fvwtNone then
begin
bClear := IsLoadingFileList;
StopWorkers;
if bClear then
ClearFiles;
Key := 0;
end;
end;
inherited DoHandleKeyDownWhenLoading(Key, Shift);
end;
procedure TOrderedFileView.DoSelectionChanged;
begin
inherited DoSelectionChanged;