src/model.cpp

changeset 1113
5f3139c802bf
parent 1100
9b2797729c82
child 1117
efcb47c64a72
equal deleted inserted replaced
1112:d1d8be74275b 1113:5f3139c802bf
19 #include "model.h" 19 #include "model.h"
20 #include "ldObject.h" 20 #include "ldObject.h"
21 #include "documentmanager.h" 21 #include "documentmanager.h"
22 22
23 Model::Model(DocumentManager* manager) : 23 Model::Model(DocumentManager* manager) :
24 QObject {manager},
24 _manager {manager} {} 25 _manager {manager} {}
25 26
26 Model::~Model() 27 Model::~Model()
27 { 28 {
28 for (int i = 0; i < countof(_objects); ++i) 29 for (int i = 0; i < countof(_objects); ++i)
63 64
64 // TODO: check that the object isn't in the vector once there's a cheap way to do so! 65 // TODO: check that the object isn't in the vector once there's a cheap way to do so!
65 _objects.insert(position, object); 66 _objects.insert(position, object);
66 _needsTriangleRecount = true; 67 _needsTriangleRecount = true;
67 object->setDocument(this); 68 object->setDocument(this);
69 emit objectAdded(object);
68 } 70 }
69 71
70 /* 72 /*
71 * Swaps one object with another, assuming they both are in this model. 73 * Swaps one object with another, assuming they both are in this model.
72 */ 74 */
246 * Drops an object from the model at the provided position. The caller must immediately put the result value object into a new model. 248 * Drops an object from the model at the provided position. The caller must immediately put the result value object into a new model.
247 */ 249 */
248 LDObject* Model::withdrawAt(int position) 250 LDObject* Model::withdrawAt(int position)
249 { 251 {
250 LDObject* object = _objects[position]; 252 LDObject* object = _objects[position];
253 emit aboutToRemoveObject(object);
251 _objects.removeAt(position); 254 _objects.removeAt(position);
252 _needsTriangleRecount = true; 255 _needsTriangleRecount = true;
253 return object; 256 return object;
254 } 257 }
255 258

mercurial