Index: sources/model/MListModel.cpp =================================================================== diff -u -r53f7433638ec721d4f687fe8a4ed5d98c03c2fe7 -rbae1ae230d8b41f90b1fcd34b9bccdfa87bf3cd9 --- sources/model/MListModel.cpp (.../MListModel.cpp) (revision 53f7433638ec721d4f687fe8a4ed5d98c03c2fe7) +++ sources/model/MListModel.cpp (.../MListModel.cpp) (revision bae1ae230d8b41f90b1fcd34b9bccdfa87bf3cd9) @@ -1,6 +1,32 @@ #include "MListModel.h" /*! + * \brief Constructor + * \param[in] parent - Parent of this object. + */ +View::MListModel::MListModel(QObject *parent) + : QAbstractListModel(parent) +{ + connect(this, &MListModel::rowsInserted, this, &MListModel::countChanged); + connect(this, &MListModel::rowsRemoved, this, &MListModel::countChanged); +} + +/*! + * \brief Inserts data into the model at a given position. + * \param[in] pos - The position where the data will be inserted. + * If row is less than 0, then data will be prepended to the model. + * If row is greater than or equal to rowCount(), then data will be appeneded to the model. + * \param[in] data - The data to insert into the model. + */ +void View::MListModel::insertRow(const int pos, const QHash &vData) +{ + const int index = std::clamp(pos, 0, rowCount()); + beginInsertRows(QModelIndex(), index, index); + _data.insert(index, vData); + endInsertRows(); +} + +/*! * \brief Retrieve the role names set for this list model. * \return Role names used for this model. */