diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-27 14:03:29 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-05-27 23:08:12 +0300 |
commit | 23d38a982deafb6ef12f597a355dc4eae24b832f (patch) | |
tree | 33865a026165644973d736b6cc7b3ec602d3b056 /desktop-widgets/tab-widgets | |
parent | f265504dabf4a7cafa0282e034919007d663f4f0 (diff) | |
download | subsurface-23d38a982deafb6ef12f597a355dc4eae24b832f.tar.gz |
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>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDivePhotos.cpp | 25 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDivePhotos.h | 2 |
2 files changed, 20 insertions, 7 deletions
diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.cpp b/desktop-widgets/tab-widgets/TabDivePhotos.cpp index 1a5d233e5..c01820777 100644 --- a/desktop-widgets/tab-widgets/TabDivePhotos.cpp +++ b/desktop-widgets/tab-widgets/TabDivePhotos.cpp @@ -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. diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.h b/desktop-widgets/tab-widgets/TabDivePhotos.h index e2e7aa05c..a752fef19 100644 --- a/desktop-widgets/tab-widgets/TabDivePhotos.h +++ b/desktop-widgets/tab-widgets/TabDivePhotos.h @@ -26,11 +26,13 @@ private slots: void addPhotosFromURL(); void removeAllPhotos(); void removeSelectedPhotos(); + void recalculateSelectedThumbnails(); void changeZoomLevel(int delta); private: Ui::TabDivePhotos *ui; DivePictureModel *divePictureModel; + QVector<QString> getSelectedFilenames() const; }; #endif |