diff --git a/model/tablemodel.cpp b/model/tablemodel.cpp index 551e125..7a05900 100644 --- a/model/tablemodel.cpp +++ b/model/tablemodel.cpp @@ -88,20 +88,20 @@ bool TableModel::setData(const QModelIndex& index, const QVariant& value, int ro // bool TableModel::setItemData(const QModelIndex& index, const QMap& roles) {} -bool TableModel::removeRows(int position, int rows, const QModelIndex& parentIndex) { +bool TableModel::removeRows(int firstRow, int nRows, const QModelIndex& parentIndex) { if (parentIndex != QModelIndex()) { qWarning() << "Removing of child rows is not supported yet!"; return false; } - const int endPosition = position + rows; - if (position < 0 || endPosition >= m_items.size()) { + const int lastRow = firstRow + nRows - 1; + if (firstRow < 0 || lastRow >= m_items.size()) { qWarning() << "Trying to remove rows is out of bounds!"; return false; } - beginRemoveRows(QModelIndex(), position, position + rows - 1); - m_items.remove(position, rows); + beginRemoveRows(QModelIndex(), firstRow, lastRow); + m_items.remove(firstRow, nRows); endRemoveRows(); return true; diff --git a/model/tablemodel.h b/model/tablemodel.h index b105975..5778f52 100644 --- a/model/tablemodel.h +++ b/model/tablemodel.h @@ -31,7 +31,7 @@ class TableModel : public QAbstractTableModel { public slots: // bool insertRows(int position, int rows, const QModelIndex& parentIndex = QModelIndex()) // override; - bool removeRows(int position, int rows, const QModelIndex& parentIndex = QModelIndex()) override; + bool removeRows(int firstRow, int nRows, const QModelIndex& parentIndex = QModelIndex()) override; void appendItems(const QByteArray& jsonDoc); void insertItems(int startPosition, const QByteArray& jsonDoc, const QModelIndex& parentIndex);