src/model.cpp

changeset 76
7c4a63a02632
parent 73
97df974b5ed5
child 86
4bec0525ef1b
equal deleted inserted replaced
75:204dc77e5654 76:7c4a63a02632
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();

mercurial