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

2014-12-03 Thread François K .
Hi,
 
> 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.

That's exactly what I'm doing right now (a Tasks app + just load the minimum 
amount of data required for the list + load the full Task properties when 
entering the "DetailsView").


> 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 ?

Isn't that what you suggested in your previous answer (when I was trying to get 
notifiable properties) ?
I'm confused (and also sorry, because I really guess it's a very trivial issue 
:( )

 
> 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.

Ok, I'll keep that in mind, thanks :)

Thanks again...

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

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

2014-12-03 Thread sfietkonstantin
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." 
À: "Sailfish OS Developers" 
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-unsubscr...@lists.sailfishos.org
___
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

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

2014-12-03 Thread François K .
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-unsubscr...@lists.sailfishos.org

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

2014-12-02 Thread François K .
Hi,

@Lucien : thanks again for your help. I'm starting to owe you a lot :)

- Mail original -
 
> 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":
> 
> DetailItem {
> label: qsTr("MyProp")
> value: model.myProp
> }

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(...).


Is there a preferred 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-unsubscr...@lists.sailfishos.org

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

2014-12-02 Thread sfietkonstantin
Hi François,

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":

DetailItem {
label: qsTr("MyProp")
value: model.myProp
}

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.)

Regards,
Lucien

- Mail original -
De: "François K." 
À: "Sailfish OS Developers" 
Envoyé: Mardi 2 Décembre 2014 10:31:46
Objet: [SailfishDevel] Wrap data in Item to get notifiable properties ?

Hi,

I'm writing a small app for SailfishOS in JS + QML (I don't know C++ so please 
don't tell me to do this in C++).

I'm getting data from LocalStorage and hence get a Javascript Object with its 
own properties. Let's call it myObj.
Then I bind some field in a view to these properties :

DetailItem {
label: qsTr("MyProp")
value: myObj.myProp
}

Now, if I update myObj.myProp, the value of the DetailItem doesn't get updated.
For what I understand, this is normal because the properties of my Javascript 
Object (myObj) aren't notifiable and thus, QML doesn't know it has been updated.

To fix this, I wonder if it's OK to wrap my JS object into a QML Item. This 
would give me notifiables properties and would certainly allow me to get 
working bindings.

What do you think about this ? Is it OK ?

Thanks a lot for your help,

Best wishes,

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

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

2014-12-02 Thread François K .
Hi,

I'm writing a small app for SailfishOS in JS + QML (I don't know C++ so please 
don't tell me to do this in C++).

I'm getting data from LocalStorage and hence get a Javascript Object with its 
own properties. Let's call it myObj.
Then I bind some field in a view to these properties :

DetailItem {
label: qsTr("MyProp")
value: myObj.myProp
}

Now, if I update myObj.myProp, the value of the DetailItem doesn't get updated.
For what I understand, this is normal because the properties of my Javascript 
Object (myObj) aren't notifiable and thus, QML doesn't know it has been updated.

To fix this, I wonder if it's OK to wrap my JS object into a QML Item. This 
would give me notifiables properties and would certainly allow me to get 
working bindings.

What do you think about this ? Is it OK ?

Thanks a lot for your help,

Best wishes,

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