diff -r 68443f5be176 -r 44679e468ba9 src/model.cpp --- a/src/model.cpp Sat Oct 05 23:47:03 2019 +0300 +++ b/src/model.cpp Sun Nov 03 12:17:41 2019 +0200 @@ -1,3 +1,5 @@ +#include +#include #include "model.h" #include "modeleditcontext.h" @@ -15,3 +17,43 @@ { return {*this}; } + +int Model::rowCount(const QModelIndex&) const +{ + return size(); +} + +QVariant Model::data(const QModelIndex& index, int role) const +{ + const int row = index.row(); + modelobjects::BaseObject* object = this->body[row].get(); + switch(role) + { + case Qt::DisplayRole: + return object->textRepresentation(); + case Qt::ForegroundRole: + return object->textRepresentationForeground(); + case Qt::BackgroundRole: + return object->textRepresentationBackground(); + case Qt::FontRole: + return object->textRepresentationFont(); + default: + return {}; + } +} + +QVariant Model::getHeaderProperty(const HeaderProperty property) +{ + switch (property) + { + case HeaderProperty::Name: + return header.name; + default: + return {}; + } +} + +void Model::append(ModelObjectPointer&& object) +{ + this->body.push_back(std::move(object)); +}