Recent

Author Topic: Listview and selected items  (Read 8966 times)

d7_2_laz

  • Hero Member
  • *****
  • Posts: 637
Re: Listview and selected items
« Reply #30 on: April 03, 2022, 04:37:31 pm »
After two days of heavy usage of the change as part my own working environment i'd like to share my recent impressions (on win 10 x64).
I applied the patch as above (TCustomListView.GetSelection as of reply #24). Having reverted 4d722455 as well as 082d0514.
Upto now i encountered none(!) side effects. Nobody can exclude that there might exist some in different usage scenarios, of course. But i didn't notice any yet.

Moreover a couple of flaws and compromises disappeared that i did know about but never communicated due minor importance, compared with the main issues.
For instance, now i can have a context menu on the last element of a long list immediately, and not with delay (that was already known, but more or less priced in for to have at least a fast initial population).
So, the patch keeps the benefit of 4d722455 and does even more. Some previously needed complementary workarounds on app level might be removed later.
At least for Windows with this change the "Selected" behaviour imo is back to work great again.
Lazarus 4.0  FPC 3.2.2 Win10 64bit

wp

  • Hero Member
  • *****
  • Posts: 12864
Re: Listview and selected items
« Reply #31 on: April 04, 2022, 12:21:45 am »
I committed a version to Laz-main which uses the ListView_GetNextItem macro for Windows and a list with all selected items for the other widgetsets so that iteration over all list items is no longer necessary. The code now is included in the widgetset infrastructure of the LCL. For Windows the performance should be as discussed in this thread, and on Linux etc, it - well - should not be worse than before (the problem here is that gtk2 seems to iterate over all items even in virtual mode, and this causes a dramatic slowdown when "many items are selected).

Since I cannot test anything else than win32 and gtk2 widgetsets at the moment, user tests would be welcome. Here is the test project that I used.
« Last Edit: April 04, 2022, 12:39:56 am by wp »

dsiders

  • Hero Member
  • *****
  • Posts: 1431
Re: Listview and selected items
« Reply #32 on: April 04, 2022, 08:43:26 am »
I committed a version to Laz-main which uses the ListView_GetNextItem macro for Windows and a list with all selected items for the other widgetsets so that iteration over all list items is no longer necessary. The code now is included in the widgetset infrastructure of the LCL. For Windows the performance should be as discussed in this thread, and on Linux etc, it - well - should not be worse than before (the problem here is that gtk2 seems to iterate over all items even in virtual mode, and this causes a dramatic slowdown when "many items are selected).

Since I cannot test anything else than win32 and gtk2 widgetsets at the moment, user tests would be welcome. Here is the test project that I used.

I used a TStringList instead of TMemo for the logging output when processing the multi-selected items. This reduced the time for all 1,000,000 items from 853 seconds to 43 seconds on my ancient laptop.

Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

d7_2_laz

  • Hero Member
  • *****
  • Posts: 637
Re: Listview and selected items
« Reply #33 on: April 04, 2022, 11:11:56 am »
As i saw that now a couple of base files are involved in the commit, i cloned the "main" repository to Windows (can test Windows only) and focused on a re-test of test projects as mentioned earlier here.

For to give a fast feedback: my first impression (will go more close into them later) is:
indeed, basically it appears to work as fine as the prototype patch (as of reply #24)  on Windows, regarding the functionality.

Re-tested with my application: the same: bbasically fine!
Just for interest i did a speed test comparison of both versions (protobype vs. the committed patch) / Windows:
- large folder (windows\system32) approx. 94 ms -> both
- very large folder (windows\WinSxS) approx. 500 ms -> both
I'm so much  impressed about this change so far!
Very interested to see what others are saying / other platforms.

Besides: issue #39325 (see reply #29) will not be affected
[EDIT: -->   this issue will be solved by the latest change this morning, commit 9aa8b52b ]
« Last Edit: April 04, 2022, 02:13:13 pm by d7_2_laz »
Lazarus 4.0  FPC 3.2.2 Win10 64bit

Arend041

  • New Member
  • *
  • Posts: 24
Re: Listview and selected items
« Reply #34 on: April 07, 2022, 08:16:24 pm »
When I run in Laz 2.20 program listview_virtualMode_multiselect_prob_Keyup_Shift_2 with Checkboxes checked I get a fatal error with a reference to TCustomListView DoItemChecked when selecting by mouse and ctrl key.

wp

  • Hero Member
  • *****
  • Posts: 12864
Re: Listview and selected items
« Reply #35 on: April 07, 2022, 10:37:17 pm »
As far as I know, it is not possible to display checkboxes in a listview operating in virtual mode. If you have to, you should add checkbox images to the StateImages of the listview and select the image index of the checked and unchecked images when checking or unchecking an item. (https://stackoverflow.com/questions/7899185/using-checkbox-in-virtual-mode-listview, https://forum.lazarus.freepascal.org/index.php?topic=43603.0).

 

TinyPortal © 2005-2018