IdeIntf: Optimize drawing ComponentTree in OI. RebuildComponentNodes was called many times.

git-svn-id: trunk@52210 -
This commit is contained in:
juha 2016-04-18 11:05:08 +00:00
parent bb389f40bf
commit 775b31bcdd
2 changed files with 27 additions and 11 deletions

View File

@ -44,6 +44,7 @@ type
function GetSelection: TPersistentSelectionList;
procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook);
procedure SetSelection(const NewSelection: TPersistentSelectionList);
procedure UpdateSelected;
protected
procedure DoSelectionChanged; override;
function GetImageFor(APersistent: TPersistent):integer;
@ -253,6 +254,8 @@ end;
{ TComponentTreeView }
procedure TComponentTreeView.SetSelection(const NewSelection: TPersistentSelectionList);
var
IsNewLookupRoot: Boolean;
begin
if (PropertyEditorHook = nil) then
begin
@ -268,9 +271,14 @@ begin
UpdateComponentNodesValues;
Exit;
end;
FComponentList.LookupRoot := PropertyEditorHook.LookupRoot;
IsNewLookupRoot := FComponentList.LookupRoot <> PropertyEditorHook.LookupRoot;
if IsNewLookupRoot then
FComponentList.LookupRoot := PropertyEditorHook.LookupRoot;
FComponentList.Selection.Assign(NewSelection);
RebuildComponentNodes;
if IsNewLookupRoot then
RebuildComponentNodes
else
UpdateSelected;
end;
procedure TComponentTreeView.DoSelectionChanged;
@ -670,13 +678,10 @@ var
end;
var
OldExpanded: TTreeNodeExpandedState;
RootNode: TTreeNode;
Candidate: TComponentCandidate;
begin
BeginUpdate;
// save old expanded state and clear
OldExpanded:=TTreeNodeExpandedState.Create(Self);
Items.Clear;
RootObject := nil;
@ -715,10 +720,6 @@ begin
RootNode.Expand(true);
end;
// restore old expanded state
OldExpanded.Apply(Self);
OldExpanded.Free;
MakeSelectionVisible;
EndUpdate;
end;
@ -740,6 +741,23 @@ begin
UpdateComponentNode(Items.GetFirstNode);
end;
procedure TComponentTreeView.UpdateSelected;
procedure UpdateComponentNode(ANode: TTreeNode);
var
APersistent: TPersistent;
begin
if ANode = nil then Exit;
APersistent := TPersistent(ANode.Data);
ANode.MultiSelected := Selection.IndexOf(APersistent) >= 0;
UpdateComponentNode(ANode.GetFirstChild);
UpdateComponentNode(ANode.GetNextSibling);
end;
begin
UpdateComponentNode(Items.GetFirstNode);
end;
function TComponentTreeView.CreateNodeCaption(APersistent: TPersistent;
DefaultName: string): string;

View File

@ -4398,8 +4398,6 @@ begin
//,' ',FPropertyEditorHook<>nil,' ',FPropertyEditorHook.LookupRoot<>nil);
if FUpdatingAvailComboBox then exit;
FUpdatingAvailComboBox:=true;
Assert(Assigned(ComponentTree), 'TObjectInspectorDlg.FillPersistentComboBox: ComponentTree=nil');
ComponentTree.RebuildComponentNodes; // if ComponentTree<>nil then
NewList:=TStringList.Create;
try
if (FPropertyEditorHook<>nil)