View Issue Details

IDProjectCategoryView StatusLast Update
0038137LazarusLCLpublic2021-07-04 19:04
Reporterhan Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
PlatformLinuxOSLubuntu 
Summary0038137: Widget QT5, Tlistview forgets to move the row check-marks when sorting on a column.
DescriptionIn GTK2 when Tlistview is used with check-marks the checkmark are fixed to the rows when sorting. In widget QT5 the check marks are forgotten. They don't move.

See attached screenshot
Steps To ReproduceUse attached example code.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetQT5
Attached Files

Relationships

related to 0039121 resolvedDmitry Boyarintsev Widget Cocoa, Tlistview forgets to move the row check-marks when sorting on a column. 

Activities

han

2020-11-27 10:36

reporter  

QT5 listview problem.png (50,568 bytes)   
QT5 listview problem.png (50,568 bytes)   
listview and qt5.zip (100,641 bytes)

han

2020-11-27 10:42

reporter   ~0127206

Small correction in screen shot
QT5 listview problem-2.png (51,596 bytes)   
QT5 listview problem-2.png (51,596 bytes)   

Zeljan Rikalo

2021-04-04 15:00

developer   ~0130080

Please attach example project.

han

2021-05-04 13:41

reporter   ~0130751

The example project was already attached. Here is the link again:

https://bugs.freepascal.org/file_download.php?file_id=34168&type=bug

Han

han

2021-06-08 19:52

reporter   ~0131205

Is there a solution or fix in sight?

Zeljan Rikalo

2021-06-12 09:15

developer   ~0131272

Fix, but when I find some spare time for this issue.

han

2021-07-01 09:51

reporter   ~0131583

Last edited: 2021-07-01 11:11

View 2 revisions

The fix for QT5 has for me no priority anymore. But the same problem occurs with the widget Cocoa in the Mac. This has priority for me but I assume the problem is fully related. I have created a new bug report for widget Cocoa. See:
https://bugs.freepascal.org/view.php?id=39121

Juha Manninen

2021-07-03 10:43

developer   ~0131617

Adding this:

 class function TQtWSCustomListView.RestoreItemCheckedAfterSort(const ALV: TCustomListView): Boolean;
 begin
   Result:=True;
 end;

to unit QtWSComCtrls does not help. The problem is elsewhere.

CudaText man

2021-07-03 16:55

reporter   ~0131631

The fix is almost done in https://bugs.freepascal.org/view.php?id=39121 ,
reuse its code.

Dmitry Boyarintsev

2021-07-04 06:56

developer   ~0131646

@Juha
there's one more thing that needs to happen - all items should be reset to unchecked at SetSort() method.
I'm attaching the patch. It does compile for me but I don't have Qt5 configured
qtwscomctrls.diff (1,470 bytes)   
Index: qtwscomctrls.pp
===================================================================
--- qtwscomctrls.pp	(revision 65358)
+++ qtwscomctrls.pp	(working copy)
@@ -202,6 +202,10 @@
 
     class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); virtual;
     *)
+    // if returns true, then LCL will call SetItemChecked after calling SetSort
+    // for every item previously checked. Only widgetsets that don't support native sort
+    // AND/OR that don't support native checkboxes should have this method return true
+    class function RestoreItemCheckedAfterSort(const ALV: TCustomListView): Boolean; override;
   end;
 
   { TQtWSListView }
@@ -2068,12 +2072,7 @@
       QtTreeWidget.setItemText(Item, 0, WStr, AlignmentToQtAlignmentMap[AList.Column[0].Alignment]);
       QtTreeWidget.setItemData(Item, 0, AItem);
       if AList.Checkboxes then
-      begin
-        if AItem.Checked then
-          QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
-        else
-          QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
-      end;
+        QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
 
       if ImgListRes.Valid and (ImgListRes.Count > 0) and
         ((AItem.ImageIndex >= 0) and (AItem.ImageIndex < ImgListRes.Count)) then
@@ -2492,4 +2491,10 @@
   end;
 end;
 
+class function TQtWSCustomListView.RestoreItemCheckedAfterSort(
+  const ALV: TCustomListView): Boolean;
+begin
+  Result:=true;
+end;
+
 end.
qtwscomctrls.diff (1,470 bytes)   

Juha Manninen

2021-07-04 11:35

developer   ~0131653

The patch does not work. The CheckBoxes now stay unchecked.
Strangely I saw some random checked boxex at some point but I cannot reproduce it.

Dmitry Boyarintsev

2021-07-04 19:04

developer   ~0131679

how about the second version of the patch?
qtwscomctrls2.diff (1,455 bytes)   
Index: qtwscomctrls.pp
===================================================================
--- qtwscomctrls.pp	(revision 65358)
+++ qtwscomctrls.pp	(working copy)
@@ -202,6 +202,10 @@
 
     class procedure SetViewOrigin(const ALV: TCustomListView; const AValue: TPoint); virtual;
     *)
+    // if returns true, then LCL will call SetItemChecked after calling SetSort
+    // for every item previously checked. Only widgetsets that don't support native sort
+    // AND/OR that don't support native checkboxes should have this method return true
+    class function RestoreItemCheckedAfterSort(const ALV: TCustomListView): Boolean; override;
   end;
 
   { TQtWSListView }
@@ -2068,12 +2072,7 @@
       QtTreeWidget.setItemText(Item, 0, WStr, AlignmentToQtAlignmentMap[AList.Column[0].Alignment]);
       QtTreeWidget.setItemData(Item, 0, AItem);
       if AList.Checkboxes then
-      begin
-        if AItem.Checked then
-          QTreeWidgetItem_setCheckState(Item, 0, QtChecked)
-        else
-          QTreeWidgetItem_setCheckState(Item, 0, QtUnChecked);
-      end;
+        QtTreeWidget.ItemChecked[I] := false;
 
       if ImgListRes.Valid and (ImgListRes.Count > 0) and
         ((AItem.ImageIndex >= 0) and (AItem.ImageIndex < ImgListRes.Count)) then
@@ -2492,4 +2491,10 @@
   end;
 end;
 
+class function TQtWSCustomListView.RestoreItemCheckedAfterSort(
+  const ALV: TCustomListView): Boolean;
+begin
+  Result:=true;
+end;
+
 end.
qtwscomctrls2.diff (1,455 bytes)   

Issue History

Date Modified Username Field Change
2020-11-27 10:36 han New Issue
2020-11-27 10:36 han File Added: QT5 listview problem.png
2020-11-27 10:36 han File Added: listview and qt5.zip
2020-11-27 10:42 han Note Added: 0127206
2020-11-27 10:42 han File Added: QT5 listview problem-2.png
2020-11-29 10:41 Zeljan Rikalo Assigned To => Zeljan Rikalo
2020-11-29 10:41 Zeljan Rikalo Status new => assigned
2021-04-04 15:00 Zeljan Rikalo Status assigned => feedback
2021-04-04 15:00 Zeljan Rikalo LazTarget => -
2021-04-04 15:00 Zeljan Rikalo Note Added: 0130080
2021-05-04 13:41 han Note Added: 0130751
2021-05-04 13:41 han Status feedback => assigned
2021-06-08 19:52 han Note Added: 0131205
2021-06-12 09:15 Zeljan Rikalo Note Added: 0131272
2021-07-01 09:51 han Note Added: 0131583
2021-07-01 11:11 han Note Edited: 0131583 View Revisions
2021-07-03 01:01 Dmitry Boyarintsev Relationship added related to 0039121
2021-07-03 10:43 Juha Manninen Note Added: 0131617
2021-07-03 16:55 CudaText man Note Added: 0131631
2021-07-04 06:56 Dmitry Boyarintsev Note Added: 0131646
2021-07-04 06:56 Dmitry Boyarintsev File Added: qtwscomctrls.diff
2021-07-04 11:35 Juha Manninen Note Added: 0131653
2021-07-04 19:04 Dmitry Boyarintsev Note Added: 0131679
2021-07-04 19:04 Dmitry Boyarintsev File Added: qtwscomctrls2.diff