Fix QAbstractItemModel::beginRemoveRows in examples
QAbstractItemModel::beginRemoveRows() must not take a negative value
for first or last. It will assert so we should make sure the examples
are correct.
The assertion was added in 00c09e752f
Change-Id: I539175c0597ed6f0ae76b7493fd3dca40638714e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Martin Smith <martin.smith@qt.io>
bb10
parent
fb58845d8f
commit
e954951423
|
|
@ -103,6 +103,9 @@ void FileListModel::fetchMore(const QModelIndex & /* index */)
|
|||
int remainder = fileList.size() - fileCount;
|
||||
int itemsToFetch = qMin(100, remainder);
|
||||
|
||||
if (itemsToFetch <= 0)
|
||||
return;
|
||||
|
||||
beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1);
|
||||
|
||||
fileCount += itemsToFetch;
|
||||
|
|
|
|||
|
|
@ -203,10 +203,12 @@ Qt::DropActions PiecesModel::supportedDropActions() const
|
|||
|
||||
void PiecesModel::addPieces(const QPixmap& pixmap)
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, 24);
|
||||
pixmaps.clear();
|
||||
locations.clear();
|
||||
endRemoveRows();
|
||||
if (!pixmaps.isEmpty()) {
|
||||
beginRemoveRows(QModelIndex(), 0, pixmaps.size() - 1);
|
||||
pixmaps.clear();
|
||||
locations.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
for (int y = 0; y < 5; ++y) {
|
||||
for (int x = 0; x < 5; ++x) {
|
||||
QPixmap pieceImage = pixmap.copy(x*m_PieceSize, y*m_PieceSize, m_PieceSize, m_PieceSize);
|
||||
|
|
|
|||
Loading…
Reference in New Issue