--- a/src/model.cpp Wed Sep 22 00:25:13 2021 +0300 +++ b/src/model.cpp Wed Sep 22 00:25:31 2021 +0300 @@ -32,8 +32,26 @@ return static_cast<int>(this->body.size()); } +/** + * @brief Looks up the object ID at the specified index. If out of bounds, returns NULL_ID. + * @param index Index of object to look up + * @return object ID + */ +ldraw::id_t Model::at(int index) const +{ + if (index >= 0 and index < this->size()) + { + return this->body[index]->id; + } + else + { + return ldraw::NULL_ID; + } +} + Model::EditContext Model::edit() { + this->editCounter += 1; return {*this}; } @@ -118,6 +136,17 @@ object->getPolygons(polygons_out, context); } +void Model::editFinished() +{ + this->editCounter -= 1; +} + +void Model::objectModified(ldraw::id_t id) +{ + const QModelIndex index = this->lookup(id); + Q_EMIT this->dataChanged(index, index); +} + void Model::append(ModelObjectPointer&& object) { const int position = static_cast<int>(this->body.size());