Layer tree model

Cyrille Berger cberger at cberger.net
Fri Mar 23 11:21:37 CET 2007


> * Keep the hierarchy administration inside KisGroupLayer and KisLayer.
> Access only through KisImage. Keep the external KisLayerModel updated from
> KisLayer.
That's the way to go.

> * Make KisLayerModel leading. Give KisImage and all layers a pointer to the
> KisLayerModel instance and make them use the model to find their peers. All
> layer inserts and removals go through KisModel, with perhaps a facade on
> KisImage.
I don't think the layer nor the image needs to know about the model.

> * Make KisImage a QAbstractItemModel. Make KisImage do all administration.
> A group layer becomes little more than a KisLayer that has no paint device
> of its own, just a projection.
That would be plain ugly, trust me :) That's how I first understood Qt4's 
model/view, and this cluter the API and the class for no good.

In my understanding of model/view in Qt4, you store your data using the 
structure you want (there KisImage/KisGroupLayer/KisLayer/...) and then you 
write a Model which will do the interface between your data and the view 
which wants to show your data.

So you have (hope it will be readable) :
+--------+            +--------+            +-------+
 | Data   |   <---> | Model |  <---->  |  View |
+--------+            +--------+            +-------+

Everything is and should be seperated.

In each QModelIndex you have a pointer to a KisLayer in the internalPointer(); 
And inside the model you do ugly (void*) to (KisLayer*) casting to access the 
data.

At least it's how I understand it based on my own experimentations.

-- 
Cyrille Berger


More information about the kimageshop mailing list