From fbe1144eaf7e800a014c7a97b846835ba9f3bc7f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 18 May 2018 20:33:01 +0200 Subject: Dive pictures: use modelReset signal when reseting picture list In the old code a combination of removeRows()/insertRows() was used to signal a model reset. Replace this by a single, modelReset signal. This saves a call to plotPictures() and will allow us to be smarter in the future, when removing pictures. Reset-model and remove-items are semantically different. Signed-off-by: Berthold Stoeger --- qt-models/divepicturemodel.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 2fc7b8311..9b993cb5a 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -57,10 +57,9 @@ void DivePictureModel::updateThumbnails() void DivePictureModel::updateDivePictures() { + beginResetModel(); if (!pictures.isEmpty()) { - beginRemoveRows(QModelIndex(), 0, pictures.count() - 1); pictures.clear(); - endRemoveRows(); rowDDStart = rowDDEnd = 0; Thumbnailer::instance()->clearWorkQueue(); } @@ -83,11 +82,7 @@ void DivePictureModel::updateDivePictures() } updateThumbnails(); - - if (!pictures.isEmpty()) { - beginInsertRows(QModelIndex(), 0, pictures.count() - 1); - endInsertRows(); - } + endResetModel(); } int DivePictureModel::columnCount(const QModelIndex &parent) const -- cgit v1.2.3-70-g09d2