JsonModel/XmlModel vs nested ListModels
-
Hello!
I have a deliberation, i have a nested json response that takes a very important place in my logic, thus it needs to be fully CRUDed plus some extra stuff, question is what model should i use?currently i am using a dynamiclly created
QAbstractListModel
with corresponding roles for each layer of the response andListView
's
where eachListView
posses the model for the nextListView
layer.
something like:ListView{id: rootListView model: rootModel delegate: Rectangle{ Text{text: model.someRootModelData} ListView{id: 2ndLayerListView model: 2ndLayerModel delegate: Rectangle{ Text{text: model.2ndLayerData} } } }
This approach drawback's are:
- lots of models - waist of resources.
- harder to customize each model functionality
- harder to update models outside the views e.g from another json response
- I will need to keep track of how many models do i have and when to delete or create new models.
Advantages are:
1.if a certain level is changed if i emit
layoutChanged
not all of my views need to be updated.
2. easier to maintain at the QmlLevel as i fetch data very trivially (model.somthing)
3. In the long run will be easier to fetch more data from my server.
4. CRUD is easyAnother approach i thought of is to use somthing like
JsonListModel
orXmlModel though
i have no experience with them
and i thought that if i have everything in one model iflayoutChanged
is emitted this will cause everything to update which is not necessarily needed plus i think CRUD will be harder .