diff options
-rw-r--r-- | qobjectlistmodel.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/qobjectlistmodel.cpp b/qobjectlistmodel.cpp index 899a0a1..d7ab1e9 100644 --- a/qobjectlistmodel.cpp +++ b/qobjectlistmodel.cpp @@ -167,7 +167,7 @@ void QObjectListModel::append(QObject *object) */ void QObjectListModel::append(const QObjectList &objects) { - beginInsertRows(QModelIndex(), m_objects.count(), m_objects.count()+objects.count()); + beginInsertRows(QModelIndex(), m_objects.count(), m_objects.count()+objects.count()-1); m_objects.append(objects); endInsertRows(); emit countChanged(); @@ -196,7 +196,10 @@ void QObjectListModel::insert(int i, QObject *object) */ void QObjectListModel::insert(int i, const QObjectList &objects) { - beginInsertRows(QModelIndex(), i, i+objects.count()); + if (objects.isEmpty()) + return; + + beginInsertRows(QModelIndex(), i, i+objects.count()-1); for (int j = objects.count() - 1; j > -1; --j) m_objects.insert(i, objects.at(j)); endInsertRows(); @@ -237,13 +240,13 @@ void QObjectListModel::move(int from, int to) /*! Removes \a count number of items from index position \a i and notifies any views. \a i must be a valid index position in the model (i.e., 0 <= \a i < size()), as - must \c{i + count}. + must \c{i + count - 1}. \sa takeAt() */ void QObjectListModel::removeAt(int i, int count) { - beginRemoveRows(QModelIndex(), i, i + count); + beginRemoveRows(QModelIndex(), i, i + count - 1); for (int j = 0; j < count; ++j) m_objects.removeAt(i); endRemoveRows(); |