Recent

Author Topic: Suggestion on TExtendedStringList  (Read 3428 times)

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Suggestion on TExtendedStringList
« on: October 14, 2020, 02:25:26 pm »
Just trying to re-inject this non-performing discussion at a more suitable place. Due to minor flaws of TExtendedStringList I'd like to make the following suggestion to the maintainers of LazUtils and StdCtrls:

- rewrite TExtendedStringList to a new class TRecordStringList that corrects some minor flaws - for instance a CheckIndex as first line of CreateRecord so that no memory is allocated for an index that might not exist - and at the same time introducing a new ancestor class TCustomRecordStringList that can be used to descend lists that for example might look like this:

Code: Pascal  [Select][+][-]
  1.   TCheckList = class(TCustomRecordStringList)
  2.   private
  3.     function GetCheckMode(Index: Integer): TCheckMode;
  4.     function GetCheckState(Index: Integer): TCheckState;
  5.     procedure SetCheckMode(Index: Integer; AValue: TCheckMode);
  6.     procedure SetCheckState(Index: Integer; AValue: TCheckState);
  7.   public
  8.     constructor Create; reintroduce;
  9.     property CheckMode[Index: Integer]: TCheckMode read GetCheckMode write SetCheckMode;
  10.     property CheckState[Index: Integer]: TCheckState read GetCheckState write SetCheckState;
  11.   end;
  12.  

without confusing the user with the record properties or methods and without having to create a TObject descendant for those indexed properties.

- add RecordStrings to LazUtils and replace TExtendedStringList within TCustomListBox with TRecordStringList. TRecordStringList just exposes all properties needed to deal with 'unknown' records like in TCustomListBox.

- leave ExtendedStrings in LazUtils in case there is code out there that relies on the current layout of TExtendedStringList, but eventually mark it as deprecated

I'm including recordstrings.pas and a recordstrings.diff created with rev 64001 so that these proposed changes can be tested with trunk.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Re: Suggestion on TExtendedStringList
« Reply #1 on: October 16, 2020, 04:46:06 pm »
New zip-file with updated recordstrings.diff created with rev64027 due to changes in LazUtils.lpk and .pas.
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

 

TinyPortal © 2005-2018