mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 00:22:56 +02:00
IdeIntf: Optimize function IsInteresting used by OI. Convert APropNameFilter to uppercase only once. Don't use Unicode for prop names.
git-svn-id: trunk@52093 -
This commit is contained in:
parent
faa105a248
commit
f0030ec7cd
@ -6839,12 +6839,16 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ClassTypeInfo(Value: TClass): PTypeInfo;
|
function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||||
begin
|
begin
|
||||||
Result := PTypeInfo(Value.ClassInfo);
|
Result := PTypeInfo(Value.ClassInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ContainsTextUpper(const AText, AUpperSubText: string): Boolean;
|
||||||
|
begin
|
||||||
|
Result := Pos(AUpperSubText, UpperCase(AText)) > 0;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure EditCollection(AComponent: TComponent; ACollection: TCollection; APropertyName: String);
|
procedure EditCollection(AComponent: TComponent; ACollection: TCollection; APropertyName: String);
|
||||||
begin
|
begin
|
||||||
TCollectionPropertyEditor.ShowCollectionEditor(ACollection, AComponent, APropertyName);
|
TCollectionPropertyEditor.ShowCollectionEditor(ACollection, AComponent, APropertyName);
|
||||||
@ -6855,9 +6859,10 @@ function IsInteresting(AEditor: TPropertyEditor; const AFilter: TTypeKinds;
|
|||||||
|
|
||||||
var
|
var
|
||||||
visited: TFPList;
|
visited: TFPList;
|
||||||
|
UpperPropName: String;
|
||||||
|
|
||||||
// check set element names against AFilter
|
// check set element names against AFilter
|
||||||
function IsPropInSet( const ATypeInfo: PTypeInfo; ANameFilter : String ) : Boolean;
|
function IsPropInSet( const ATypeInfo: PTypeInfo; AUpperNameFilter : String ) : Boolean;
|
||||||
var
|
var
|
||||||
TypeInfo: PTypeInfo;
|
TypeInfo: PTypeInfo;
|
||||||
TypeData: PTypeData;
|
TypeData: PTypeData;
|
||||||
@ -6875,14 +6880,14 @@ var
|
|||||||
|
|
||||||
for i:= TypeData^.MinValue to TypeData^.MaxValue do
|
for i:= TypeData^.MinValue to TypeData^.MaxValue do
|
||||||
begin
|
begin
|
||||||
Result := AnsiContainsText( GetEnumName(TypeInfo, i), ANameFilter );
|
Result := ContainsTextUpper( GetEnumName(TypeInfo, i), AUpperNameFilter );
|
||||||
if Result then
|
if Result then
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check class has property name
|
// check class has property name
|
||||||
function IsPropInClass( const ATypeInfo: PTypeInfo; ANameFilter : String ) : Boolean;
|
function IsPropInClass( const ATypeInfo: PTypeInfo; AUpperNameFilter : String ) : Boolean;
|
||||||
var
|
var
|
||||||
propInfo: PPropInfo;
|
propInfo: PPropInfo;
|
||||||
propList: PPropList;
|
propList: PPropList;
|
||||||
@ -6896,17 +6901,17 @@ var
|
|||||||
//if encounter a Set check its elements name.
|
//if encounter a Set check its elements name.
|
||||||
if (propInfo^.PropType^.Kind = tkSet) then
|
if (propInfo^.PropType^.Kind = tkSet) then
|
||||||
begin
|
begin
|
||||||
Result := IsPropInSet( propInfo^.PropType, ANameFilter );
|
Result := IsPropInSet( propInfo^.PropType, AUpperNameFilter );
|
||||||
if Result then break;
|
if Result then break;
|
||||||
end;
|
end;
|
||||||
// check properties of subclass recursively
|
// check properties of subclass recursively
|
||||||
if (propInfo^.PropType^.Kind = tkClass) then
|
if (propInfo^.PropType^.Kind = tkClass) then
|
||||||
begin
|
begin
|
||||||
Result := IsPropInClass( propInfo^.PropType, ANameFilter );
|
Result := IsPropInClass( propInfo^.PropType, AUpperNameFilter );
|
||||||
if Result then break;
|
if Result then break;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := AnsiContainsText( propInfo^.Name, ANameFilter );
|
Result := ContainsTextUpper( propInfo^.Name, AUpperNameFilter );
|
||||||
if result then break;
|
if result then break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -6928,17 +6933,17 @@ var
|
|||||||
Result := ti^.Kind <> tkClass;
|
Result := ti^.Kind <> tkClass;
|
||||||
if Result then
|
if Result then
|
||||||
begin
|
begin
|
||||||
if (APropNameFilter = '') or AForceShow then
|
if (UpperPropName = '') or AForceShow then
|
||||||
exit;
|
exit;
|
||||||
// Check if check Set has element.
|
// Check if check Set has element.
|
||||||
if (ti^.Kind = tkSet) and (A.ClassType <> TSetElementPropertyEditor) then
|
if (ti^.Kind = tkSet) and (A.ClassType <> TSetElementPropertyEditor) then
|
||||||
begin
|
begin
|
||||||
Result := AnsiContainsText(A.GetName, APropNameFilter)
|
Result := ContainsTextUpper(A.GetName, UpperPropName)
|
||||||
or IsPropInSet(A.GetPropType, APropNameFilter);
|
or IsPropInSet(A.GetPropType, UpperPropName);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// Check single Props
|
// Check single Props
|
||||||
Result := AnsiContainsText(A.GetName, APropNameFilter);
|
Result := ContainsTextUpper(A.GetName, UpperPropName);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6954,12 +6959,12 @@ var
|
|||||||
if Result then
|
if Result then
|
||||||
begin
|
begin
|
||||||
// if no SubProperties check against filter name
|
// if no SubProperties check against filter name
|
||||||
if (APropNameFilter <> '') then
|
if (UpperPropName <> '') then
|
||||||
if (paSubProperties in A.GetAttributes) then
|
if (paSubProperties in A.GetAttributes) then
|
||||||
Result := AnsiContainsText(A.GetName, APropNameFilter)
|
Result := ContainsTextUpper(A.GetName, UpperPropName)
|
||||||
or IsPropInClass(A.GetPropType, APropNameFilter)
|
or IsPropInClass(A.GetPropType, UpperPropName)
|
||||||
else
|
else
|
||||||
Result := AnsiContainsText(A.GetName, APropNameFilter );
|
Result := ContainsTextUpper(A.GetName, UpperPropName );
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -6989,7 +6994,7 @@ var
|
|||||||
ed.SetPropEntry(0, obj, propList^[i]);
|
ed.SetPropEntry(0, obj, propList^[i]);
|
||||||
ed.Initialize;
|
ed.Initialize;
|
||||||
// filter TClassPropertyEditor name recursively
|
// filter TClassPropertyEditor name recursively
|
||||||
Rec(ed, AnsiContainsText(A.GetName,APropNameFilter) );
|
Rec(ed, ContainsTextUpper(A.GetName, UpperPropName) );
|
||||||
finally
|
finally
|
||||||
ed.Free;
|
ed.Free;
|
||||||
end;
|
end;
|
||||||
@ -7004,6 +7009,7 @@ var
|
|||||||
begin
|
begin
|
||||||
visited := TFPList.Create;
|
visited := TFPList.Create;
|
||||||
try
|
try
|
||||||
|
UpperPropName := Uppercase(APropNameFilter);
|
||||||
//DebugLn('IsInteresting -> ', AEditor.GetPropInfo^.Name, ': ', AEditor.GetPropInfo^.PropType^.Name);
|
//DebugLn('IsInteresting -> ', AEditor.GetPropInfo^.Name, ': ', AEditor.GetPropInfo^.PropType^.Name);
|
||||||
Rec(AEditor);
|
Rec(AEditor);
|
||||||
//DebugLn('IsInteresting <- ', BoolToStr(Result, true));
|
//DebugLn('IsInteresting <- ', BoolToStr(Result, true));
|
||||||
|
Loading…
Reference in New Issue
Block a user