[SailfishDevel] Wrap data in Item to get notifiable properties ?

sfietkonstantin at free.fr sfietkonstantin at free.fr
Wed Dec 3 11:19:35 UTC 2014


Hi François,

It is a good practice to load the minimal amount of data in a ListModel. I don't know which app you are developing, but for an example TODO list app, the main page would only load (from a storage, like a database), only the title and id of the TODO entries. Clicking on an entry will trigger the load of the full TODO entry from the database, based on the id.

Usual application goes from less detailed to more detailed information (all TODO entries -> one TODO entry, all friends -> one friend's wall -> one post etc.), so I wonder why you have to modify the ListModel when you pushed the page ? 

If you want to modify the model nevertheless, I think that the best way would be to provide a signal in your sub-page, that is emitted and caught in the main page in order to call model.set. This is better than passing the model, as the sub-page and page are more separated.

Regards,
Lucien

----- Mail original -----
De: "François K." <daitheflu at free.fr>
À: "Sailfish OS Developers" <devel at lists.sailfishos.org>
Envoyé: Mercredi 3 Décembre 2014 12:05:37
Objet: Re: [SailfishDevel] Wrap data in Item to get notifiable properties ?

Hi,

Sorry to bump this, but I think my last mail formatting was misleading.
It actually contained another question :

> The best way to do this is to use QML ListModel. Instead of loading
> the properties in a JS object, you can load them as model properties
> (via
> http://qt-project.org/doc/qt-5/qml-qtqml-models-listmodel.html#set-method).
> Accessing the properties would be done via "model":

I see. Since I already have a ListModel for the previous view (basically, a list), I'm now wondering if I'd best :

  1. Load everything in the ListModel and just go on with it (but what about memory consumption if the ListModel is big ?) ;

or :

  2. Load the minimum amount of data in the ListModel for the ListView, and when I enter the DetailsView, load the additional data and modify the ListModel via set(...) or setProperty(...).


Or is there a (third) better way ?


> If you don't want to use a ListModel, prefer using QtObject instead
> of Item. QtObject provides a non-graphical component to store
> properties, unlike Item that implies having a "box" (x, y, width,
> height, anchors etc.)

Oh yes, sure ! How could I miss that one ? :(
I think I'll try to stick with the ListModel, it'll probably solve another issue :)


Best regards,

-- 
François
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org


More information about the Devel mailing list