summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Guido Lerch <guido.lerch@gmail.com>2015-10-20 21:08:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-03 08:31:41 -0800
commit951e3d920b943baa105573de181f727319494a25 (patch)
treea70e43169697444419673c9d09d12317b84bb402
parenteb6d5415c1eefcdba184a7939075f114d086a37e (diff)
downloadsubsurface-951e3d920b943baa105573de181f727319494a25.tar.gz
Context menu for images: support deletion
Adding modified code to support deletion of selected images as well as deleting of all images (with warning messagebox) Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--desktop-widgets/maintab.cpp25
-rw-r--r--desktop-widgets/maintab.h1
2 files changed, 23 insertions, 3 deletions
diff --git a/desktop-widgets/maintab.cpp b/desktop-widgets/maintab.cpp
index 7642213e1..42bc29c8d 100644
--- a/desktop-widgets/maintab.cpp
+++ b/desktop-widgets/maintab.cpp
@@ -1556,12 +1556,31 @@ void MainTab::photoDoubleClicked(const QString filePath)
void MainTab::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;
+ if (photo.isValid()) {
+ QString fileUrl = photo.data(Qt::DisplayPropertyRole).toString();
+ if (fileUrl.length() > 0)
+ DivePictureModel::instance()->removePicture(fileUrl, last);
+ }
+ indexes.removeFirst();
+ } while(!indexes.isEmpty());
+}
- QModelIndex photoIndex = ui.photosView->selectionModel()->selectedIndexes().first();
- QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString();
- DivePictureModel::instance()->removePicture(fileUrl);
+void MainTab::removeAllPhotos()
+{
+ if (QMessageBox::warning(this, tr("Deleting Images"), tr("Are you sure you want to delete all images?"), QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Cancel ) {
+ ui.photosView->selectAll();
+ removeSelectedPhotos();
+ }
}
#define SHOW_SELECTIVE(_component) \
diff --git a/desktop-widgets/maintab.h b/desktop-widgets/maintab.h
index 7b2bb863b..c3f6649a8 100644
--- a/desktop-widgets/maintab.h
+++ b/desktop-widgets/maintab.h
@@ -97,6 +97,7 @@ slots:
void escDetected(void);
void photoDoubleClicked(const QString filePath);
void removeSelectedPhotos();
+ void removeAllPhotos();
void showLocation();
void enableGeoLookupEdition();
void disableGeoLookupEdition();