Recent

Author Topic: SOLVED: How can I extend TOIPropertyEditor with support for database properties?  (Read 1047 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Sometime ago I was having a problem editing fonts in the TOIPropertyEditor which I was able to fix in https://forum.lazarus.freepascal.org/index.php?topic=66076.0.

Now I notice that at runtime some properties are not available. For instance if I want to set the Dataset property of Datasources at runtime they are not listed in the drop down which should list the datasets.
The dropdown simply displays (none).
 
There must be some code that checks for the existence of the desired components on the form then adds them for selection of the drop down.

Any ideas?

Strangely enough I think I have dealt with this issue before, but that may have been with Delphi components.
« Last Edit: October 18, 2024, 04:16:10 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Re: How can I extend TOIPropertyEditor with support for database properties?
« Reply #1 on: October 15, 2024, 02:18:03 pm »
After doing some more searching it seems that I have to add the capabilities of ideintfs/dbpropedits.pas to it.

When I fixed the last problem https://forum.lazarus.freepascal.org/index.php/topic,66076.0.html I had to extend the program with more TTypeKinds after adding the necessary units.

Are there some additional TTypeKinds related to the  ideintfs/dbpropedits.pas to the project?

PS. Does the initialization section of an included unit execute automatically, or does it require some initialization withing the including unit?
Lazarus 3.0/FPC 3.2.2

mattias

  • Administrator
  • Full Member
  • *
  • Posts: 206
    • http://www.lazarus.freepascal.org
Re: How can I extend TOIPropertyEditor with support for database properties?
« Reply #2 on: October 16, 2024, 08:42:12 am »
The initialization section is called automatically.
Usually it is enough to use a unit to get the property editors.

About missing Datasources:
Maybe you forgot to set ThePropertyEditorHook.LookupRoot, or your DataSources are not owned by the LookupRoot. Please provide some code.

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Re: How can I extend TOIPropertyEditor with support for database properties?
« Reply #3 on: October 16, 2024, 11:33:42 am »
The initialization section is called automatically.
Usually it is enough to use a unit to get the property editors.

About missing Datasources:
Maybe you forgot to set ThePropertyEditorHook.LookupRoot, or your DataSources are not owned by the LookupRoot. Please provide some code.

Hi Mattias

I have adapted the original oiexample with data components to see how it can be extended to support them.

I have not included DBPropEdits.pas or any other extra initialization to in order to see how it must all be done from scratch.

Thanks.
« Last Edit: October 16, 2024, 08:55:38 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
Re: How can I extend TOIPropertyEditor with support for database properties?
« Reply #4 on: October 18, 2024, 12:53:15 pm »
The initialization section is called automatically.
Usually it is enough to use a unit to get the property editors.

About missing Datasources:
Maybe you forgot to set ThePropertyEditorHook.LookupRoot, or your DataSources are not owned by the LookupRoot. Please provide some code.

What I can see now is that there is no property editor registered for TDataSource or specific component types.

The only thing  can think of is that there must be a generic property editor for component values that  looks for all instances of the component on the form and presents one of them for selection and something like that is not registered for components, ie something that filters for the specific component type.
Lazarus 3.0/FPC 3.2.2

vfclists

  • Hero Member
  • *****
  • Posts: 1147
    • HowTos Considered Harmful?
After considering mattias's response I changed the LookupRoot in SetObjectInspectorRoot(AComponent: TComponent) to the form itself.

The code example uses the component as the LookupRoot and that apparently causes the TComponentPropertyEditor to components owned by the LookupRoot.

That works for objects of the form itself not for the components because they don't own themselves.
Lazarus 3.0/FPC 3.2.2

 

TinyPortal © 2005-2018