mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:50:06 +02:00
ideintf: TRecordPropertyEditor: use all registered editors
This commit is contained in:
parent
700bf810cc
commit
32baef49e0
@ -1367,6 +1367,7 @@ procedure GetPersistentProperties(AItem: TPersistent;
|
||||
AEditorFilterFunc: TPropertyEditorFilterFunc);
|
||||
|
||||
function GetEditorClass(PropInfo: PPropInfo; Obj: TPersistent): TPropertyEditorClass;
|
||||
function GetEditorClass(PropName: shortstring; Info: PTypeInfo; Obj: TPersistent): TPropertyEditorClass;
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@ -2147,7 +2148,6 @@ end;
|
||||
constructor TRecordPropertyEditor.Create(Hook: TPropertyEditorHook; APropCount: Integer);
|
||||
begin
|
||||
inherited Create(Hook, APropCount);
|
||||
writeln('TRecordPropertyEditor.Create ');
|
||||
end;
|
||||
|
||||
destructor TRecordPropertyEditor.Destroy;
|
||||
@ -2179,16 +2179,15 @@ var
|
||||
Instance: TPersistent;
|
||||
FieldList: PExtendedFieldInfoTable;
|
||||
Field: PExtendedVmtFieldEntry;
|
||||
EdClass: TPropertyEditorClass;
|
||||
{$ENDIF}
|
||||
begin
|
||||
writeln('TRecordPropertyEditor.GetProperties START');
|
||||
{$IFDEF HasExtRtti}
|
||||
Instance:=FPropList^[0].Instance;
|
||||
PropInfo:=GetPropInfo;
|
||||
if PropInfo=nil then
|
||||
exit;
|
||||
|
||||
writeln('TRecordPropertyEditor.GetProperties aPropInfo^.Name=',GetPropInfo^.Name);
|
||||
aTypeData:=GetTypeData(PropInfo^.PropType);
|
||||
|
||||
FieldCnt:=GetFieldList(PropInfo^.PropType,FieldList,[vcPublic,vcPublished]);
|
||||
@ -2209,20 +2208,18 @@ begin
|
||||
Field:=FieldList^[i];
|
||||
FieldTypeInfo:=Field^.FieldType^;
|
||||
|
||||
// todo filter editors
|
||||
|
||||
case FieldTypeInfo^.Kind of
|
||||
tkInteger:
|
||||
begin
|
||||
Editor:=TIntegerPropertyEditor.Create(PropertyHook,1);
|
||||
EdClass:=GetEditorClass('',FieldTypeInfo,nil);
|
||||
Editor := EdClass.Create(PropertyHook,1);
|
||||
Editor.SetRecordFieldEntry(0, PByte(FRecordData)+Field^.FieldOffset, Field^.Name, FieldTypeInfo);
|
||||
Editor.Initialize;
|
||||
|
||||
if ((PropCount > 1) and not (paMultiSelect in Editor.GetAttributes))
|
||||
or not Editor.ValueAvailable
|
||||
then begin
|
||||
Editor.Free;
|
||||
end else begin
|
||||
Proc(Editor);
|
||||
end;
|
||||
else
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2242,7 +2239,6 @@ end;
|
||||
procedure TRecordPropertyEditor.Initialize;
|
||||
var
|
||||
PropInfo: PPropInfo;
|
||||
aTypeData: PTypeData;
|
||||
begin
|
||||
inherited Initialize;
|
||||
|
||||
@ -2250,9 +2246,6 @@ begin
|
||||
if PropInfo=nil then
|
||||
exit;
|
||||
|
||||
writeln('TRecordPropertyEditor.Initialize aPropInfo^.Name=',GetPropInfo^.Name);
|
||||
aTypeData:=GetTypeData(PropInfo^.PropType);
|
||||
|
||||
// check read and write access
|
||||
FReadAccess:=(PropInfo^.PropProcs) and 3;
|
||||
FCanReadFields:=FReadAccess in [ptField{,ptStatic,ptVirtual}];
|
||||
@ -2811,8 +2804,6 @@ end;
|
||||
|
||||
function GetEditorClass(PropInfo:PPropInfo; Obj:TPersistent): TPropertyEditorClass;
|
||||
var
|
||||
PropType:PTypeInfo;
|
||||
P,C:PPropertyClassRec;
|
||||
I: Integer;
|
||||
begin
|
||||
Result := nil;
|
||||
@ -2824,32 +2815,42 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if Result=nil then begin
|
||||
PropType:=PropInfo^.PropType;
|
||||
Result:=GetEditorClass(PropInfo^.Name,PropInfo^.PropType,Obj);
|
||||
end;
|
||||
|
||||
function GetEditorClass(PropName: shortstring; Info: PTypeInfo; Obj: TPersistent
|
||||
): TPropertyEditorClass;
|
||||
var
|
||||
P, C: PPropertyClassRec;
|
||||
I: Integer;
|
||||
TypeData: PTypeData;
|
||||
begin
|
||||
Result := nil;
|
||||
I:=0;
|
||||
C:=nil;
|
||||
TypeData:=GetTypeData(Info);
|
||||
while I < PropertyClassList.Count do begin
|
||||
P:=PropertyClassList[I];
|
||||
|
||||
if ((P^.PropertyType=PropType) or
|
||||
((P^.PropertyType^.Kind=PropType^.Kind) and
|
||||
(P^.PropertyType^.Name=PropType^.Name)
|
||||
if ((P^.PropertyType=Info) or
|
||||
((P^.PropertyType^.Kind=Info^.Kind) and
|
||||
(P^.PropertyType^.Name=Info^.Name)
|
||||
)
|
||||
) or
|
||||
( (PropType^.Kind=tkClass) and
|
||||
( (Info^.Kind=tkClass) and
|
||||
(P^.PropertyType^.Kind=tkClass) and
|
||||
GetTypeData(PropType)^.ClassType.InheritsFrom(
|
||||
TypeData^.ClassType.InheritsFrom(
|
||||
GetTypeData(P^.PropertyType)^.ClassType)
|
||||
)
|
||||
then
|
||||
if ((P^.PersistentClass=nil) or ((Obj<>nil) and (Obj.InheritsFrom(P^.PersistentClass))))
|
||||
and ((P^.PropertyName='') or (CompareText(PropInfo^.Name,P^.PropertyName)=0))
|
||||
and ((P^.PropertyName='') or (CompareText(P^.PropertyName,PropName)=0))
|
||||
then
|
||||
if (C=nil) or // see if P is better match than C
|
||||
((C^.PersistentClass=nil) and (P^.PersistentClass<>nil)) or
|
||||
((C^.PropertyName='') and (P^.PropertyName<>''))
|
||||
or // P's proptype match is exact,but C's does not
|
||||
((C^.PropertyType<>PropType) and (P^.PropertyType=PropType))
|
||||
((C^.PropertyType<>Info) and (P^.PropertyType=Info))
|
||||
or // P's proptype is more specific than C's proptype
|
||||
((P^.PropertyType<>C^.PropertyType) and
|
||||
(P^.PropertyType^.Kind=tkClass) and
|
||||
@ -2867,14 +2868,13 @@ begin
|
||||
if C<>nil then
|
||||
Result:=C^.EditorClass
|
||||
else begin
|
||||
if (PropType^.Kind<>tkClass)
|
||||
or (GetTypeData(PropType)^.ClassType.InheritsFrom(TPersistent))
|
||||
or (GetTypeData(PropType)^.PropCount > 0) then
|
||||
Result:=PropClassMap[PropType^.Kind]
|
||||
if (Info^.Kind<>tkClass)
|
||||
or (TypeData^.ClassType.InheritsFrom(TPersistent))
|
||||
or (TypeData^.PropCount > 0) then
|
||||
Result:=PropClassMap[Info^.Kind]
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
end;
|
||||
if (Result<>nil) and Result.InheritsFrom(THiddenPropertyEditor) then
|
||||
Result:=nil;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user