Saving issue fixed

Deleting any entity from the scene kept it in the list that is being iterated when streaming the data to xml file while saving the contents of a scene. Though the entity was not present on the scene, we could find it saved. Exceptions.. 😛

The saving is and must be done corresponding to the entities present at the given time of saving the file. The items() function was the solution. It has been used previously but after moving to QGraphicsItemGroup, it was lost. This function returns the list of items present in a scene. We considered it to be applicable only for QGraphicsItem despite the fact that it is a function of QGraphicsScene which had nothing to do with the type of entities present in the scene. A sigh!

items().contains() made it fixed.

Selection in action

Though saving for all entities has been done yesterday but no ids were assigned to any of the saved entities. Continuing it, we have assigned a unique id(duh 😉 ) to each entity in the scene. Pre-increment came into action.

Then we started with selection and moving of entities. It worked decently for point but lost its expected behavior with other entities. Considering line say, it is constructed using two points and a path joining them. If the mouse click was on path say, or any of the one points, voila only the path or the point selected moved and the remaining part of the entity did not bother to accompany. And we laughed!

Learnt another element of Qt namely QGraphicsItemGroup. We created groups for each of the entities. Added the entities’ different parts to this group and then this group was added to the scene just like single QGraphicsItem was done. Got the selection accomplished. The issue of overlapping entities is also solved to an acceptable level according to me but not Gurjot. 😀 We are trying to minimize the bounding rectangle for the entities, considering shape() to be of some convenience.