diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 17 | ||||
-rw-r--r-- | qt-models/divepicturemodel.h | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 3fa1a07f4..48fa652c9 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -149,7 +149,22 @@ void DivePictureModel::removePictures(const QVector<QString> &fileUrls) copy_dive(current_dive, &displayed_dive); mark_divelist_changed(true); - updateDivePictures(); + for (int i = 0; i < pictures.size(); ++i) { + // Find range [i j) of pictures to remove + if (std::find(fileUrls.begin(), fileUrls.end(), pictures[i].filename) == fileUrls.end()) + continue; + int j; + for (j = i + 1; j < pictures.size(); ++j) { + if (std::find(fileUrls.begin(), fileUrls.end(), pictures[j].filename) == fileUrls.end()) + break; + } + + // Qt's model-interface is surprisingly idiosyncratic: you don't pass [first last), but [first last] ranges. + // For example, an empty list would be [0 -1]. + beginRemoveRows(QModelIndex(), i, j - 1); + pictures.erase(pictures.begin() + i, pictures.begin() + j); + endRemoveRows(); + } } int DivePictureModel::rowCount(const QModelIndex &parent) const diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h index 61eb1d984..a7a3d7180 100644 --- a/qt-models/divepicturemodel.h +++ b/qt-models/divepicturemodel.h @@ -30,7 +30,7 @@ public slots: void updateThumbnail(QString filename, QImage thumbnail); private: DivePictureModel(); - QList<PictureEntry> pictures; + QVector<PictureEntry> pictures; int findPictureId(const QString &filename); // Return -1 if not found double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum int size; |