TurboPack / MustangpeakEasyListview

TurboPack MustangpeakEasyListview is part of VirtualShellTools for the Listview but can be used for a TListview Replacement that is faster and more customizable.
Other
37 stars 22 forks source link

TeasyItem.Checktype per item not working #16

Open hvdm opened 1 year ago

hvdm commented 1 year ago

When using checkboxes and want to remove the checkbox of one item it doesn't remove or change it.

Example using (simpleproject):

procedure TForm1.AddItems(Count: Integer); var i: Integer; Item: TEasyItem; begin // Add items to the listview. Actually the items are added to the first // group. This group is created automatically when the first item is added. LV.BeginUpdate; try for i := 0 to Count - 1 do begin Item := LV.Items.Add; Item.Caption := 'Item ' + IntToStr(i); // this is the same as Item.Captions[0] Item.Captions[1] := 'Detail ' + IntToStr(i); Item.ImageIndex := i mod LV.ImagesSmall.Count; Item.Details[0] := 0; // Use Report Column 0 for the first Tile View Detail Item.Details[1] := 1; // Use Report Column 1 for the second Tile View Detail

  **if I = 4 then
    Item.CheckType := ectNoneWithSpace
  else
    Item.CheckType := ectBox;**

end;

finally LV.EndUpdate; end; end;

hvdm commented 1 year ago

it seems that the TEasyItem.CheckType set's the PaintInfo.CheckType which does change the items for all the items in the listview. This means that when you change it on one item it changes them for all.

It looks like there is no implementation for the TEasyItem.Checktype at all.

Any change that this functionality could be added, no idea how to remove it with a workarround

romankassebaum commented 1 year ago

On a first glace you can set the PaintInfo of the TEasyItem. If it is not set, then the PaintInfo if the LV is used.

function TEasyCollectionItem.GetPaintInfo: TEasyPaintInfoBasic;
begin
  if Assigned(FPaintInfo) then
    Result := FPaintInfo
  else
    Result := LocalPaintInfo
end;
...
function TEasyItem.LocalPaintInfo: TEasyPaintInfoBasic;
begin
  Result := OwnerListview.PaintInfoItem
end;
...
procedure TEasyCollectionItem.SetCheckType(Value: TEasyCheckType);
begin
  if Value <> CheckType then
  begin
    PaintInfo.CheckType := Value;
    Invalidate(False)
  end
end;
hvdm commented 1 year ago

I made a copy of the simple demo and modified it a bit.

`function CheckTypeToStr (aCheckType : TEasyCheckType) : string; begin case aCheckType of ectNone : result := 'ectNone'; ectNoneWithSpace : result := 'ectNoneWithSpace'; ectBox : result := 'ectBox'; ectRadio : result := 'ectRadio'; end; end;

procedure TForm1.FormCreate(Sender: TObject); begin FillStringsWithEasyListStyles(cbViews.Items); cbViews.ItemIndex := Ord(LV.View);

AddColumns(2); LV.Header.Visible := True;

cbViews.ItemIndex := cbViews.Items.IndexOf('Details'); LV.View := TEasyListStyle(cbViews.ItemIndex);

AddItems(25); RadioGroup1Click(Sender); end;

procedure TForm1.RadioGroup1Click(Sender: TObject); begin LV.PaintInfoItem.CheckType := (TEasyCheckType(RadioGroup1.ItemIndex)); lblRadioGroup.Caption := 'Changing PaintInfoItem.CheckType: ' + CheckTypeToStr(LV.PaintInfoItem.CheckType); end;

procedure TForm1.cbViewsChange(Sender: TObject); begin // Synchronize list style combobox with listview list style. LV.View := TEasyListStyle(cbViews.ItemIndex); end;

procedure TForm1.AddColumns(Count: Integer); var Column: TEasyColumn; i: Integer; begin for i := 0 to Count - 1 do begin Column := LV.Header.Columns.Add; Column.Caption := 'Column ' + IntToStr(i); Column.ImageIndex := i; Column.Width := 150; end; end;

procedure TForm1.AddItems(Count: Integer); var i: Integer; Item: TEasyItem; begin // Add items to the listview. Actually the items are added to the first // group. This group is created automatically when the first item is added. LV.BeginUpdate; try for i := 0 to Count - 1 do begin Item := LV.Items.Add; Item.Caption := 'Item ' + IntToStr(i); // this is the same as Item.Captions[0] Item.Captions[1] := 'Detail ' + IntToStr(i); Item.ImageIndex := i mod LV.ImagesSmall.Count; Item.Details[0] := 0; // Use Report Column 0 for the first Tile View Detail Item.Details[1] := 1; // Use Report Column 1 for the second Tile View Detail end; finally LV.EndUpdate; end; end;

procedure TForm1.Button1Click(Sender: TObject); begin LV.Items[3].CheckType := ectNoneWithSpace; lblRadioGroup.Caption := 'Button click PaintInfoItem.CheckType: ' + CheckTypeToStr(LV.PaintInfoItem.CheckType); lblItem.Caption := 'Button click Item[3].CheckType: ' + CheckTypeToStr(LV.Items[3].CheckType); end;`

When I change the 3rd item in the list, ALL entries change because LV.PaintInfoItem.CheckType is set by LV.Items[3].CheckType