[odb-users] How to make a "lazy" QList?

Rene Jensen rene at catatonic.dk
Fri Nov 2 12:30:20 EDT 2012


On Fri, Nov 2, 2012 at 2:42 PM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Rene,
>
> Rene Jensen <rene at catatonic.dk> writes:
>
> > Have you given any further thoughts to this? Automatic loading and saving
> > of lists of objects is increasingly becoming a pain.
>
> Yes, I think it is generally a good idea, perhaps also combined with
> change tracking.
>
  ... <snip> ...
> In fact, with virtual data members you can create a thin wrapper class
> for this. Here is an example:
>


>
> ...
>
> p.name_ = "John Doe";
>
> db.update (person_name (p));
>
> In a sesne, this is like a view but it works for updating. Pretty cool,
> actually; virtual data members are a very powerful feature.
>


You are probably on to something here. I will try to go on with this and
see how much work it entails.

When driving home, I further considered your original suggestion using
sections. The _real_ problem is not solved yet, which is the lack of fine
grained update control over collections. If the penalty of adding a member
to a QList already holding 2000 elements is that 2001 sql inserts are being
executed, then there is no trick to do it fast.
I'm pretty sure that you have given this problem a huge amount of thought.
I remember reading either in the docs or on the mailing list about the
problem too and the lack of sensible solutions.

Presented like that, I see that the problem also touches on a the lack of a
standard "signal-emitting" Qt collection or similar in std: Something that
would react when you inserted or removed a single element.
Much like Django's RelatedManager functioning as a collection:
https://docs.djangoproject.com/en/1.4/ref/models/relations/

Best regards,
Rene Jensen


More information about the odb-users mailing list