115 object->getPolygons(polygons_out, context); |
115 object->getPolygons(polygons_out, context); |
116 } |
116 } |
117 |
117 |
118 void Model::append(ModelObjectPointer&& object) |
118 void Model::append(ModelObjectPointer&& object) |
119 { |
119 { |
|
120 const int position = static_cast<int>(this->body.size()); |
|
121 emit beginInsertRows({}, position, position); |
120 this->body.push_back(std::move(object)); |
122 this->body.push_back(std::move(object)); |
|
123 emit endInsertRows(); |
|
124 } |
|
125 |
|
126 void Model::remove(int position) |
|
127 { |
|
128 if (position >= 0 and position < signed_cast(this->body.size())) |
|
129 { |
|
130 emit beginRemoveRows({}, position, position); |
|
131 this->body.erase(std::begin(this->body) + position); |
|
132 emit endRemoveRows(); |
|
133 } |
121 } |
134 } |
122 |
135 |
123 ldraw::Object* Model::objectAt(const QModelIndex& index) |
136 ldraw::Object* Model::objectAt(const QModelIndex& index) |
124 { |
137 { |
125 return this->body[unsigned_cast(index.row())].get(); |
138 return this->body[unsigned_cast(index.row())].get(); |