mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive pictures: change removePicture() interface
The function removePicture() had a flag "last", which would indicate that the called had finished removing pictures. Only then would the model be recalculated. This is a strange interface and, matter of fact, the caller was buggy: if the last picture to be removed didn't have a proper url, removePicture() was never called with "last" being set. Change the interface to take a list of pictures to be deleted. This will allow us to make picture deletion smarter in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fbe1144eaf
commit
3c0c1801cd
4 changed files with 27 additions and 19 deletions
|
@ -60,23 +60,21 @@ void TabDivePhotos::contextMenuEvent(QContextMenuEvent *event)
|
|||
|
||||
void TabDivePhotos::removeSelectedPhotos()
|
||||
{
|
||||
bool last = false;
|
||||
if (!ui->photosView->selectionModel()->hasSelection())
|
||||
return;
|
||||
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
|
||||
if (indexes.count() == 0)
|
||||
indexes = ui->photosView->selectionModel()->selectedIndexes();
|
||||
QModelIndex photo = indexes.first();
|
||||
do {
|
||||
photo = indexes.first();
|
||||
last = indexes.count() == 1;
|
||||
QVector<QString> photosToDelete;
|
||||
photosToDelete.reserve(indexes.count());
|
||||
for (const auto &photo: indexes) {
|
||||
if (photo.isValid()) {
|
||||
QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
|
||||
if (fileUrl.length() > 0)
|
||||
DivePictureModel::instance()->removePicture(fileUrl, last);
|
||||
if (!fileUrl.isEmpty())
|
||||
photosToDelete.push_back(fileUrl);
|
||||
}
|
||||
indexes.removeFirst();
|
||||
} while(!indexes.isEmpty());
|
||||
}
|
||||
DivePictureModel::instance()->removePictures(photosToDelete);
|
||||
}
|
||||
|
||||
//TODO: This looks overly wrong. We shouldn't call MainWindow to retrieve the DiveList to add Images.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue