Opkman: Speed up the load of the package tree.

git-svn-id: trunk@62680 -
This commit is contained in:
balazs 2020-02-27 11:30:22 +00:00
parent 42beb70c91
commit ab0b56c0f8
2 changed files with 156 additions and 150 deletions

View File

@ -437,7 +437,8 @@ begin
case AErrTyp of case AErrTyp of
etNone: etNone:
begin begin
SetupMessage(rsMainFrm_rsMessageParsingJSON); if (not Options.LoadJsonLocally) then
SetupMessage(rsMainFrm_rsMessageParsingJSON);
if (SerializablePackages.Count = 0) then if (SerializablePackages.Count = 0) then
begin begin
EnableDisableControls(True); EnableDisableControls(True);

View File

@ -331,164 +331,169 @@ begin
FVST.NodeDataSize := SizeOf(TData); FVST.NodeDataSize := SizeOf(TData);
UniqueID := 0; UniqueID := 0;
//add repository(DataType = 0) //add repository(DataType = 0)
RootNode := FVST.AddChild(nil); FVST.BeginUpdate;
RootData := FVST.GetNodeData(RootNode); try
RootData^.Repository := Options.RemoteRepository[Options.ActiveRepositoryIndex]; RootNode := FVST.AddChild(nil);
RootData^.DataType := 0; RootData := FVST.GetNodeData(RootNode);
for I := 0 to SerializablePackages.Count - 1 do RootData^.Repository := Options.RemoteRepository[Options.ActiveRepositoryIndex];
begin RootData^.DataType := 0;
//add package(DataType = 1) for I := 0 to SerializablePackages.Count - 1 do
Node := FVST.AddChild(RootNode); begin
Node^.CheckType := ctTriStateCheckBox; //add package(DataType = 1)
Data := FVST.GetNodeData(Node); Node := FVST.AddChild(RootNode);
Data^.PID := I; Node^.CheckType := ctTriStateCheckBox;
Data^.PackageName := SerializablePackages.Items[I].Name; Data := FVST.GetNodeData(Node);
Data^.PackageDisplayName := SerializablePackages.Items[I].DisplayName; Data^.PID := I;
Data^.PackageState := SerializablePackages.Items[I].PackageState; Data^.PackageName := SerializablePackages.Items[I].Name;
Data^.InstallState := SerializablePackages.GetPackageInstallState(SerializablePackages.Items[I]); Data^.PackageDisplayName := SerializablePackages.Items[I].DisplayName;
Data^.HasUpdate := SerializablePackages.Items[I].HasUpdate; Data^.PackageState := SerializablePackages.Items[I].PackageState;
Data^.DisableInOPM := SerializablePackages.Items[I].DisableInOPM; Data^.InstallState := SerializablePackages.GetPackageInstallState(SerializablePackages.Items[I]);
Data^.Rating := SerializablePackages.Items[I].Rating; Data^.HasUpdate := SerializablePackages.Items[I].HasUpdate;
Data^.RepositoryDate := SerializablePackages.Items[I].RepositoryDate; Data^.DisableInOPM := SerializablePackages.Items[I].DisableInOPM;
FVST.IsDisabled[Node] := Data^.DisableInOPM; Data^.Rating := SerializablePackages.Items[I].Rating;
Data^.DataType := 1; Data^.RepositoryDate := SerializablePackages.Items[I].RepositoryDate;
for J := 0 to SerializablePackages.Items[I].LazarusPackages.Count - 1 do FVST.IsDisabled[Node] := Data^.DisableInOPM;
begin Data^.DataType := 1;
//add LazarusPackages(DataType = 2) for J := 0 to SerializablePackages.Items[I].LazarusPackages.Count - 1 do
LazarusPkg := TLazarusPackage(SerializablePackages.Items[I].LazarusPackages.Items[J]); begin
//add LazarusPackages(DataType = 2)
LazarusPkg := TLazarusPackage(SerializablePackages.Items[I].LazarusPackages.Items[J]);
ChildNode := FVST.AddChild(Node);
ChildNode^.CheckType := ctTriStateCheckBox;
FVST.IsDisabled[ChildNode] := FVST.IsDisabled[ChildNode^.Parent];
ChildData := FVST.GetNodeData(ChildNode);
ChildData^.PID := I;
ChildData^.PFID := J;
ChildData^.LazarusPackageName := LazarusPkg.Name;
ChildData^.InstalledVersion := LazarusPkg.InstalledFileVersion;
ChildData^.UpdateVersion := LazarusPkg.UpdateVersion;
ChildData^.Version := LazarusPkg.VersionAsString;
ChildData^.PackageState := LazarusPkg.PackageState;
ChildData^.HasUpdate := LazarusPkg.HasUpdate;
ChildData^.DataType := 2;
//add description(DataType = 3)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
if ChildData^.InstalledVersion <> '' then
GrandChildData^.Description := LazarusPkg.InstalledFileDescription
else
GrandChildData^.Description := LazarusPkg.Description;
GrandChildData^.DataType := 3;
Inc(UniqueID);
GrandChildData^.ButtonID := UniqueID;
//add author(DataType = 4)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.Author := LazarusPkg.Author;
GrandChildData^.DataType := 4;
//add lazcompatibility(DataType = 5)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.LazCompatibility := LazarusPkg.LazCompatibility;
GrandChildData^.DataType := 5;
//add fpccompatibility(DataType = 6)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.FPCCompatibility := LazarusPkg.FPCCompatibility;
GrandChildData^.DataType := 6;
//add widgetset(DataType = 7)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.SupportedWidgetSet := LazarusPkg.SupportedWidgetSet;
GrandChildData^.DataType := 7;
//add packagetype(DataType = 8)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.PackageType := LazarusPkg.PackageType;
GrandChildData^.DataType := 8;
//add license(DataType = 9)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
if ChildData^.InstalledVersion <> '' then
GrandChildData^.License := LazarusPkg.InstalledFileLincese
else
GrandChildData^.License := LazarusPkg.License;
GrandChildData^.DataType := 9;
Inc(UniqueID);
GrandChildData^.ButtonID := UniqueID;
//add dependencies(DataType = 10)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.Dependencies := LazarusPkg.DependenciesAsString;
GrandChildData^.DataType := 10;
end;
//add miscellaneous(DataType = 11)
ChildNode := FVST.AddChild(Node); ChildNode := FVST.AddChild(Node);
ChildNode^.CheckType := ctTriStateCheckBox;
FVST.IsDisabled[ChildNode] := FVST.IsDisabled[ChildNode^.Parent]; FVST.IsDisabled[ChildNode] := FVST.IsDisabled[ChildNode^.Parent];
ChildData := FVST.GetNodeData(ChildNode); ChildData := FVST.GetNodeData(ChildNode);
ChildData^.PID := I; ChildData^.DataType := 11;
ChildData^.PFID := J; //add category(DataType = 12)
ChildData^.LazarusPackageName := LazarusPkg.Name;
ChildData^.InstalledVersion := LazarusPkg.InstalledFileVersion;
ChildData^.UpdateVersion := LazarusPkg.UpdateVersion;
ChildData^.Version := LazarusPkg.VersionAsString;
ChildData^.PackageState := LazarusPkg.PackageState;
ChildData^.HasUpdate := LazarusPkg.HasUpdate;
ChildData^.DataType := 2;
//add description(DataType = 3)
GrandChildNode := FVST.AddChild(ChildNode); GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent]; FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode); GrandChildData := FVST.GetNodeData(GrandChildNode);
if ChildData^.InstalledVersion <> '' then GrandChildData^.Category := SerializablePackages.Items[I].Category;
GrandChildData^.Description := LazarusPkg.InstalledFileDescription GrandChildData^.DataType := 12;
else //add Repository Filename(DataType = 13)
GrandChildData^.Description := LazarusPkg.Description; GrandChildNode := FVST.AddChild(ChildNode);
GrandChildData^.DataType := 3; FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileName := SerializablePackages.Items[I].RepositoryFileName;
GrandChildData^.DataType := 13;
//add Repository Filesize(DataType = 14)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileSize := SerializablePackages.Items[I].RepositoryFileSize;
GrandChildData^.DataType := 14;
//add Repository Hash(DataType = 15)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileHash := SerializablePackages.Items[I].RepositoryFileHash;
GrandChildData^.DataType := 15;
//add Repository Date(DataType = 16)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryDate := SerializablePackages.Items[I].RepositoryDate;
GrandChildData^.DataType := 16;
FVST.Expanded[ChildNode] := True;
//add HomePageURL(DataType = 17)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.HomePageURL := SerializablePackages.Items[I].HomePageURL;
GrandChildData^.DataType := 17;
//add DownloadURL(DataType = 18)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.DownloadURL := SerializablePackages.Items[I].DownloadURL;
GrandChildData^.DataType := 18;
//add community description(DataType = 19) - added 2018.08.21
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.CommunityDescription := SerializablePackages.Items[I].CommunityDescription;
GrandChildData^.DataType := 19;
Inc(UniqueID); Inc(UniqueID);
GrandChildData^.ButtonID := UniqueID; GrandChildData^.ButtonID := UniqueID;
//add author(DataType = 4) Data^.CommunityDescription := SerializablePackages.Items[I].CommunityDescription;;
GrandChildNode := FVST.AddChild(ChildNode); end;
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent]; FVST.SortTree(0, laz.VirtualTrees.sdAscending);
GrandChildData := FVST.GetNodeData(GrandChildNode); ExpandEx;
GrandChildData^.Author := LazarusPkg.Author; CollapseEx;
GrandChildData^.DataType := 4; finally
//add lazcompatibility(DataType = 5) FVST.EndUpdate;
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.LazCompatibility := LazarusPkg.LazCompatibility;
GrandChildData^.DataType := 5;
//add fpccompatibility(DataType = 6)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.FPCCompatibility := LazarusPkg.FPCCompatibility;
GrandChildData^.DataType := 6;
//add widgetset(DataType = 7)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.SupportedWidgetSet := LazarusPkg.SupportedWidgetSet;
GrandChildData^.DataType := 7;
//add packagetype(DataType = 8)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.PackageType := LazarusPkg.PackageType;
GrandChildData^.DataType := 8;
//add license(DataType = 9)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
if ChildData^.InstalledVersion <> '' then
GrandChildData^.License := LazarusPkg.InstalledFileLincese
else
GrandChildData^.License := LazarusPkg.License;
GrandChildData^.DataType := 9;
Inc(UniqueID);
GrandChildData^.ButtonID := UniqueID;
//add dependencies(DataType = 10)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.Dependencies := LazarusPkg.DependenciesAsString;
GrandChildData^.DataType := 10;
end;
//add miscellaneous(DataType = 11)
ChildNode := FVST.AddChild(Node);
FVST.IsDisabled[ChildNode] := FVST.IsDisabled[ChildNode^.Parent];
ChildData := FVST.GetNodeData(ChildNode);
ChildData^.DataType := 11;
//add category(DataType = 12)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.Category := SerializablePackages.Items[I].Category;
GrandChildData^.DataType := 12;
//add Repository Filename(DataType = 13)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileName := SerializablePackages.Items[I].RepositoryFileName;
GrandChildData^.DataType := 13;
//add Repository Filesize(DataType = 14)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileSize := SerializablePackages.Items[I].RepositoryFileSize;
GrandChildData^.DataType := 14;
//add Repository Hash(DataType = 15)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryFileHash := SerializablePackages.Items[I].RepositoryFileHash;
GrandChildData^.DataType := 15;
//add Repository Date(DataType = 16)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.RepositoryDate := SerializablePackages.Items[I].RepositoryDate;
GrandChildData^.DataType := 16;
FVST.Expanded[ChildNode] := True;
//add HomePageURL(DataType = 17)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.HomePageURL := SerializablePackages.Items[I].HomePageURL;
GrandChildData^.DataType := 17;
//add DownloadURL(DataType = 18)
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.DownloadURL := SerializablePackages.Items[I].DownloadURL;
GrandChildData^.DataType := 18;
//add community description(DataType = 19) - added 2018.08.21
GrandChildNode := FVST.AddChild(ChildNode);
FVST.IsDisabled[GrandChildNode] := FVST.IsDisabled[GrandChildNode^.Parent];
GrandChildData := FVST.GetNodeData(GrandChildNode);
GrandChildData^.CommunityDescription := SerializablePackages.Items[I].CommunityDescription;
GrandChildData^.DataType := 19;
Inc(UniqueID);
GrandChildData^.ButtonID := UniqueID;
Data^.CommunityDescription := SerializablePackages.Items[I].CommunityDescription;;
end; end;
FVST.SortTree(0, laz.VirtualTrees.sdAscending);
ExpandEx;
CollapseEx;
RootNode := VST.GetFirst; RootNode := VST.GetFirst;
if RootNode <> nil then if RootNode <> nil then
begin begin