Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-10

[PATCH] FCL-DB: Extend TLookupList so it can be used as picklist source

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alexander Klenin

Attached patch does two things:
1) Makes TLookupList.FList protected instead of private
2) Adds new TLookupList methods to access all values and to find key by value

These are required to implement picklist editor for lookup fields in DBGrid component of Lazarus, see:
http://bugs.freepascal.org/view.php?id=12347
http://wiki.lazarus.freepascal.org/Lazarus_0.9.26_todo (where this feature was once targeted for 0.9.26, but postponed) and a recent thread in Lazarus mailing list.

Note that although the code is rather straightforward and was copied almost directly
from the patch in the bug report above, it was only compile-tested. This is because the existing db test suite (fcl-db\tests) gives many failures, so I hestitate to add more tests until those are resolved.

Alexander S. Klenin Insight Experts Ltd.

Reply by email

Joost van der Sluis
to Alexander Klenin

Op woensdag 15-10-2008 om 02:32 uur [tijdzone +1100], schreef Alexander Klenin:

Attached patch does two things: 1) Makes TLookupList.FList protected instead of private

Maybe it's a better idea to add a protected property for this? Or is that not possible?

2) Adds new TLookupList methods to access all values and to find key by value

Thanks, committed. Although I've refactored a little bit so that it uses the same style as the surrounding code.

And maybe next time, open a bug report with the patch, so it won't be forgotten. ;)

Joost.

Reply by email

Alexander Klenin
to Joost van der Sluis
Joost van der Sluis wrote 5 lines
> Attached patch does two things: > 1) Makes TLookupList.FList protected instead of private Maybe it's a better idea to add a protected property for this? Or is that not possible?

Actually, with other parts of this patch accepted FList may even remain private, since the procedures I added are exactly what Lazarus (currently) needs. However, they will only be available after fpc 2.4 is out, which is IIUC still at least half a year away.
So to avoid such issues in the future I think 'protected' is appropriate safeguard.

As for the property -- sure, it can be used, but I do not see any essential difference
in this case. So whatever you prefer.

And maybe next time, open a bug report with the patch, so it won't be forgotten. ;)

Actually, from my recent experience, the best course of action is to use both mailing list and Mantis at once ;-)

Alexander S. Klenin Insight Experts Ltd.

Reply by email