Recent

Author Topic: Interesting discovery with TListView with OwnerData checked and Adding items.  (Read 1489 times)

jamie

  • Hero Member
  • *****
  • Posts: 6225
 If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.
 
  Older IDE's, it puts the IDE into a loop and you need to hard exit.
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1105
If you have OwnerData checked and then use the IDE to add items, upon completion of the editor, you get a nice Index of bounds with the trunk.
 
  Older IDE's, it puts the IDE into a loop and you need to hard exit.

Interesting.

So, in essence, the property editor should not be displayed at all when OwnerData is enabled?
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

jamie

  • Hero Member
  • *****
  • Posts: 6225
I would say so.

Not just that, the items should be deleted if one checks the ownerdata too.

The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1105
I would say so.

Not just that, the items should be deleted if one checks the ownerdata too.

SetOwnerData already does that. It frees the Items list are creates the TOwnerDataListItems container used instead.

I made a patch (for 3.99) to catch the circumstance you described, if you'd like to try it out...

Code: Diff  [Select][+][-]
  1. diff --git a/components/ideintf/listviewpropedit.pp b/components/ideintf/listviewpropedit.pp
  2. index 0fc4ca719d..73ba02c024 100644
  3. --- a/components/ideintf/listviewpropedit.pp
  4. +++ b/components/ideintf/listviewpropedit.pp
  5. @@ -92,6 +92,13 @@ function EditListView(AListView: TListView): Boolean;
  6.  var
  7.    ListViewEditorDlg: TListViewItemsEditorForm;
  8.  begin
  9. +  if AListView.OwnerData then
  10. +  begin
  11. +    Beep;
  12. +    Application.MessageBox(PChar(sccsLvEdtMsgOwnerData), PChar(sccsLvEdt));
  13. +    Result := False;
  14. +    Exit;
  15. +  end;
  16.    ListViewEditorDlg := TListViewItemsEditorForm.Create(Application);
  17.    try
  18.      ListViewEditorDlg.LoadFromList(AListView);
  19. diff --git a/components/ideintf/objinspstrconsts.pas b/components/ideintf/objinspstrconsts.pas
  20. index 27366703fb..17099884ca 100644
  21. --- a/components/ideintf/objinspstrconsts.pas
  22. +++ b/components/ideintf/objinspstrconsts.pas
  23. @@ -134,6 +134,7 @@ resourcestring
  24.    sccsLvEdtLabelImageIndex = 'Image Index:';
  25.    sccsLvEdtLabelStateIndex = 'State Index:';
  26.    sccsLvEdtItem            = 'Item';
  27. +  sccsLvEdtMsgOwnerData    = 'Cannot edit list items at design-time when OwnerData is enabled. Use Items.Count and OnData at run-time instead.';
  28.  
  29.    // Image editor strings
  30.    oisImageListComponentEditor = 'I&mageList Editor ...';
  31.  
  32.  

The Beep and Application.MessageBox calls are debatable, but they did not introduce any new dependencies in the unit.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 12013
I don't like the Beep. Is a Beep used within the IDE anywhere else? And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something?

jamie

  • Hero Member
  • *****
  • Posts: 6225
I am not sure if the ondata event is even working?
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1105
I don't like the Beep. Is a Beep used within the IDE anywhere else?

Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior.

And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something?

No, you're not missing anything. I just took the path of least resistance.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

dsiders

  • Hero Member
  • *****
  • Posts: 1105
I am not sure if the ondata event is even working?

If it's not, then how are you getting values for from the virtual data container?
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 12013
I am not sure if the ondata event is even working?
Here's a demo with 1,000,000 items in a virtual listview.

wp

  • Hero Member
  • *****
  • Posts: 12013
I don't like the Beep. Is a Beep used within the IDE anywhere else?

Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior.

And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something?

No, you're not missing anything. I just took the path of least resistance.
OK when I commit it?

dsiders

  • Hero Member
  • *****
  • Posts: 1105
I don't like the Beep. Is a Beep used within the IDE anywhere else?

Not in the IDE specifically, but in LCL bring-to-front flash-and-beep behavior.

And I'd also replace the Application.MessageBox by MessageDlg even it if makes the unit depend on the Dialogs unit. But Dialogs is used already by PropEdits. So, this should not make a difference. Or am I missing something?

No, you're not missing anything. I just took the path of least resistance.
OK when I commit it?

Here's the modified version.

Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 12013
Committed (https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/5621ec7af3f8d08bf514edb72defc0045ab3ee26), will be backported to Laz/Fixes and the next bug-fix release v3.4

 

TinyPortal © 2005-2018