Dive pictures: give user option to recalculate thumbnails

Even though hashes of image contents are calculated, the hashes are
not compared to actual file contents in routine-operation. Therefore
give the user the option to recalculate thumbnails, should they have
edited the picture.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-05-27 14:03:29 +02:00 committed by Lubomir I. Ivanov
parent f265504dab
commit 23d38a982d
4 changed files with 52 additions and 7 deletions

View file

@ -54,27 +54,38 @@ void TabDivePhotos::contextMenuEvent(QContextMenuEvent *event)
popup.addSeparator();
popup.addAction(tr("Delete selected images"), this, SLOT(removeSelectedPhotos()));
popup.addAction(tr("Delete all images"), this, SLOT(removeAllPhotos()));
popup.addAction(tr("Recalculate selected thumbnails"), this, SLOT(recalculateSelectedThumbnails()));
popup.exec(event->globalPos());
event->accept();
}
void TabDivePhotos::removeSelectedPhotos()
QVector<QString> TabDivePhotos::getSelectedFilenames() const
{
QVector<QString> selectedPhotos;
if (!ui->photosView->selectionModel()->hasSelection())
return;
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
return selectedPhotos;
QModelIndexList indexes = ui->photosView->selectionModel()->selectedRows();
if (indexes.count() == 0)
indexes = ui->photosView->selectionModel()->selectedIndexes();
QVector<QString> photosToDelete;
photosToDelete.reserve(indexes.count());
selectedPhotos.reserve(indexes.count());
for (const auto &photo: indexes) {
if (photo.isValid()) {
QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
if (!fileUrl.isEmpty())
photosToDelete.push_back(fileUrl);
selectedPhotos.push_back(fileUrl);
}
}
DivePictureModel::instance()->removePictures(photosToDelete);
return selectedPhotos;
}
void TabDivePhotos::removeSelectedPhotos()
{
DivePictureModel::instance()->removePictures(getSelectedFilenames());
}
void TabDivePhotos::recalculateSelectedThumbnails()
{
Thumbnailer::instance()->calculateThumbnails(getSelectedFilenames());
}
//TODO: This looks overly wrong. We shouldn't call MainWindow to retrieve the DiveList to add Images.