mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 21:59:14 +02:00
lhelp - loading toc and index is now lightning fast. It is loaded before showing the desired page.
git-svn-id: trunk@26983 -
This commit is contained in:
parent
147aafd3c7
commit
a58662c257
@ -56,6 +56,7 @@ type
|
|||||||
fHistoryIndex: Integer;
|
fHistoryIndex: Integer;
|
||||||
fStopTimer: Boolean;
|
fStopTimer: Boolean;
|
||||||
fFillingToc: Boolean;
|
fFillingToc: Boolean;
|
||||||
|
fFillingIndex: Boolean;
|
||||||
fActiveChmTitle: String;
|
fActiveChmTitle: String;
|
||||||
FLoadingSearchURL: Boolean; // use this to try to highlight search terms
|
FLoadingSearchURL: Boolean; // use this to try to highlight search terms
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ type
|
|||||||
procedure NewChmOpened(ChmFileList: TChmFileList; Index: Integer);
|
procedure NewChmOpened(ChmFileList: TChmFileList; Index: Integer);
|
||||||
procedure LoadingHTMLStream(var AStream: TStream);
|
procedure LoadingHTMLStream(var AStream: TStream);
|
||||||
|
|
||||||
|
procedure QueueFillToc(AChm: TChmReader);
|
||||||
procedure FillTOC(Data: PtrInt);
|
procedure FillTOC(Data: PtrInt);
|
||||||
procedure IpHtmlPanelDocumentOpen(Sender: TObject);
|
procedure IpHtmlPanelDocumentOpen(Sender: TObject);
|
||||||
procedure IpHtmlPanelHotChange(Sender: TObject);
|
procedure IpHtmlPanelHotChange(Sender: TObject);
|
||||||
@ -324,8 +326,14 @@ var
|
|||||||
NewUrl: String;
|
NewUrl: String;
|
||||||
FilteredURL: String;
|
FilteredURL: String;
|
||||||
fPos: Integer;
|
fPos: Integer;
|
||||||
|
StartTime: TDateTime;
|
||||||
|
EndTime: TDateTime;
|
||||||
|
Time: String;
|
||||||
begin
|
begin
|
||||||
if (fChms = nil) and (AChm = nil) then exit;
|
if (fChms = nil) and (AChm = nil) then exit;
|
||||||
|
fStatusBar.SimpleText :='Loading: '+Uri;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
StartTime := Now;
|
||||||
|
|
||||||
fPos := Pos('#', Uri);
|
fPos := Pos('#', Uri);
|
||||||
if fPos > 0 then
|
if fPos > 0 then
|
||||||
@ -350,6 +358,10 @@ begin
|
|||||||
TIpChmDataProvider(fHtml.DataProvider).CurrentPath := ExtractFileDir(URI)+'/';
|
TIpChmDataProvider(fHtml.DataProvider).CurrentPath := ExtractFileDir(URI)+'/';
|
||||||
|
|
||||||
AddHistory(Uri);
|
AddHistory(Uri);
|
||||||
|
EndTime := Now;
|
||||||
|
|
||||||
|
Time := INtToStr(DateTimeToTimeStamp(EndTime).Time - DateTimeToTimeStamp(StartTime).Time);
|
||||||
|
fStatusBar.SimpleText :='Loaded: '+Uri+' in '+ Time+'ms';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -363,7 +375,6 @@ procedure TChmContentProvider.NewChmOpened(ChmFileList: TChmFileList;
|
|||||||
Index: Integer);
|
Index: Integer);
|
||||||
begin
|
begin
|
||||||
if Index = 0 then begin
|
if Index = 0 then begin
|
||||||
fContentsTree.Items.Clear;
|
|
||||||
if fContext > -1 then begin
|
if fContext > -1 then begin
|
||||||
DoLoadContext(fContext);
|
DoLoadContext(fContext);
|
||||||
fContext := -1;
|
fContext := -1;
|
||||||
@ -377,7 +388,7 @@ begin
|
|||||||
|
|
||||||
// Fill the table of contents.
|
// Fill the table of contents.
|
||||||
if Index <> 0 then
|
if Index <> 0 then
|
||||||
Application.QueueAsyncCall(@FillToc, PtrInt(ChmFileList.Chm[Index]));
|
QueueFillToc(ChmFileList.Chm[Index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChmContentProvider.LoadingHTMLStream(var AStream: TStream);
|
procedure TChmContentProvider.LoadingHTMLStream(var AStream: TStream);
|
||||||
@ -426,6 +437,15 @@ begin
|
|||||||
AStream.Position := 0;
|
AStream.Position := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChmContentProvider.QueueFillToc(AChm: TChmReader);
|
||||||
|
begin
|
||||||
|
fContentsTree.Visible := False;
|
||||||
|
fContentsPanel.Caption := 'Table of Contents Loading. Please Wait...';
|
||||||
|
fStatusBar.SimpleText:= 'Table of Contents Loading...';
|
||||||
|
Application.ProcessMessages;
|
||||||
|
Application.QueueAsyncCall(@FillToc, PtrInt(AChm));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChmContentProvider.FillTOC(Data: PtrInt);
|
procedure TChmContentProvider.FillTOC(Data: PtrInt);
|
||||||
var
|
var
|
||||||
fChm: TChmReader;
|
fChm: TChmReader;
|
||||||
@ -434,15 +454,13 @@ var
|
|||||||
SM: TChmSiteMap;
|
SM: TChmSiteMap;
|
||||||
HasSearchIndex: Boolean = False;
|
HasSearchIndex: Boolean = False;
|
||||||
begin
|
begin
|
||||||
if fFillingToc = True then begin
|
if fFillingToc or fFillingIndex then begin
|
||||||
Application.QueueAsyncCall(@FillToc, Data);
|
Application.QueueAsyncCall(@FillToc, Data);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
fFillingToc := True;
|
fFillingToc := True;
|
||||||
fContentsTree.Visible := False;
|
|
||||||
fContentsTree.BeginUpdate;
|
fContentsTree.BeginUpdate;
|
||||||
fContentsPanel.Caption := 'Table of Contents Loading. Please Wait...';
|
|
||||||
Application.ProcessMessages;
|
|
||||||
fChm := TChmReader(Data);
|
fChm := TChmReader(Data);
|
||||||
{$IFDEF CHM_DEBUG_TIME}
|
{$IFDEF CHM_DEBUG_TIME}
|
||||||
writeln('Start: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
writeln('Start: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
@ -455,6 +473,7 @@ begin
|
|||||||
SM := fChm.GetTOCSitemap;
|
SM := fChm.GetTOCSitemap;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SM := nil;
|
SM := nil;
|
||||||
|
fFillingIndex := True;
|
||||||
Stream := TMemoryStream(fchm.GetObject(fChm.TOCFile));
|
Stream := TMemoryStream(fchm.GetObject(fChm.TOCFile));
|
||||||
if Stream <> nil then begin
|
if Stream <> nil then begin
|
||||||
SM := TChmSiteMap.Create(stTOC);
|
SM := TChmSiteMap.Create(stTOC);
|
||||||
@ -466,7 +485,6 @@ begin
|
|||||||
{$IFDEF CHM_DEBUG_TIME}
|
{$IFDEF CHM_DEBUG_TIME}
|
||||||
writeln('Stream read: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
writeln('Stream read: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
with TContentsFiller.Create(fContentsTree, SM, @fStopTimer, fChm) do begin
|
with TContentsFiller.Create(fContentsTree, SM, @fStopTimer, fChm) do begin
|
||||||
DoFill(ParentNode);
|
DoFill(ParentNode);
|
||||||
Free;
|
Free;
|
||||||
@ -475,7 +493,15 @@ begin
|
|||||||
if (fContentsTree.Selected = nil) and (fHistory.Count > 0) then
|
if (fContentsTree.Selected = nil) and (fHistory.Count > 0) then
|
||||||
SelectTreeItemFromURL(fHistory.Strings[fHistoryIndex]);
|
SelectTreeItemFromURL(fHistory.Strings[fHistoryIndex]);
|
||||||
end;
|
end;
|
||||||
|
if ParentNode.Index = 0 then ParentNode.Expanded := True;
|
||||||
|
fFillingToc := False;
|
||||||
|
fContentsTree.EndUpdate;
|
||||||
|
fContentsTree.Visible := True;
|
||||||
|
fContentsPanel.Caption := '';
|
||||||
fContentsTab.TabVisible := fContentsTree.Items.Count > 1;
|
fContentsTab.TabVisible := fContentsTree.Items.Count > 1;
|
||||||
|
Application.ProcessMessages;
|
||||||
|
fFillingIndex := True;
|
||||||
|
|
||||||
|
|
||||||
// we fill the index here too but only for the main file
|
// we fill the index here too but only for the main file
|
||||||
if fChms.IndexOfObject(fChm) < 1 then
|
if fChms.IndexOfObject(fChm) < 1 then
|
||||||
@ -492,25 +518,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if SM <> nil then begin
|
if SM <> nil then begin
|
||||||
|
fStatusBar.SimpleText:= 'Index Loading...';
|
||||||
|
Application.ProcessMessages;
|
||||||
with TContentsFiller.Create(fIndexView, SM, @fStopTimer, fChm) do begin
|
with TContentsFiller.Create(fIndexView, SM, @fStopTimer, fChm) do begin
|
||||||
DoFill(nil);
|
DoFill(nil);
|
||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
SM.Free;
|
SM.Free;
|
||||||
fIndexView.FullExpand;
|
fIndexView.FullExpand;
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
fIndexTab.TabVisible := fIndexView.Items.Count > 0;
|
|
||||||
if ParentNode.Index = 0 then ParentNode.Expanded := True;
|
|
||||||
|
|
||||||
fContentsTree.EndUpdate;
|
end;
|
||||||
fContentsTree.Visible := True;
|
end;
|
||||||
fContentsPanel.Caption := '';
|
end;
|
||||||
|
fFillingIndex := False;
|
||||||
|
fIndexTab.TabVisible := fIndexView.Items.Count > 0;
|
||||||
|
|
||||||
|
fStatusBar.SimpleText:= '';
|
||||||
|
|
||||||
{$IFDEF CHM_DEBUG_TIME}
|
{$IFDEF CHM_DEBUG_TIME}
|
||||||
writeln('Eind: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
writeln('Eind: ',FormatDateTime('hh:nn:ss.zzz', Now));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
fFillingToc := False;
|
|
||||||
|
|
||||||
|
|
||||||
{$IFDEF CHM_SEARCH}
|
{$IFDEF CHM_SEARCH}
|
||||||
i := 0;
|
i := 0;
|
||||||
@ -973,17 +1002,18 @@ begin
|
|||||||
else
|
else
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
if LoadTOC and (FileIndex = 0) then
|
||||||
|
begin
|
||||||
|
QueueFillToc(fChms.Chm[FileIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
if fURL <> '' then
|
if fURL <> '' then
|
||||||
DoLoadUri(MakeURI(fURL, fChms.Chm[FileIndex]))
|
DoLoadUri(MakeURI(fURL, fChms.Chm[FileIndex]))
|
||||||
else
|
else
|
||||||
DoLoadUri(MakeURI(fChms.Chm[FileIndex].DefaultPage, fChms.Chm[FileIndex]));
|
DoLoadUri(MakeURI(fChms.Chm[FileIndex].DefaultPage, fChms.Chm[FileIndex]));
|
||||||
Result := True;
|
Result := True;
|
||||||
|
|
||||||
if LoadTOC and (FileIndex = 0) then
|
|
||||||
begin
|
|
||||||
Application.ProcessMessages;
|
|
||||||
Application.QueueAsyncCall(@FillToc, PtrInt(fChms.Chm[FileIndex]));
|
|
||||||
end;
|
|
||||||
fChms.OnOpenNewFile := @NewChmOpened;
|
fChms.OnOpenNewFile := @NewChmOpened;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
Inc(fBranchCount);
|
Inc(fBranchCount);
|
||||||
|
|
||||||
if fBranchCount mod 400 = 0 then
|
if fBranchCount mod 200 = 0 then
|
||||||
Application.ProcessMessages;
|
Application.ProcessMessages;
|
||||||
|
|
||||||
for X := 0 to AItem.Children.Count-1 do
|
for X := 0 to AItem.Children.Count-1 do
|
||||||
|
Loading…
Reference in New Issue
Block a user