mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
eb6d5415c1
commit
951e3d920b
2 changed files with 23 additions and 3 deletions
|
@ -1556,12 +1556,31 @@ void MainTab::photoDoubleClicked(const QString filePath)
|
||||||
|
|
||||||
void MainTab::removeSelectedPhotos()
|
void MainTab::removeSelectedPhotos()
|
||||||
{
|
{
|
||||||
|
bool last = false;
|
||||||
if (!ui.photosView->selectionModel()->hasSelection())
|
if (!ui.photosView->selectionModel()->hasSelection())
|
||||||
return;
|
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();
|
void MainTab::removeAllPhotos()
|
||||||
QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString();
|
{
|
||||||
DivePictureModel::instance()->removePicture(fileUrl);
|
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) \
|
#define SHOW_SELECTIVE(_component) \
|
||||||
|
|
|
@ -97,6 +97,7 @@ slots:
|
||||||
void escDetected(void);
|
void escDetected(void);
|
||||||
void photoDoubleClicked(const QString filePath);
|
void photoDoubleClicked(const QString filePath);
|
||||||
void removeSelectedPhotos();
|
void removeSelectedPhotos();
|
||||||
|
void removeAllPhotos();
|
||||||
void showLocation();
|
void showLocation();
|
||||||
void enableGeoLookupEdition();
|
void enableGeoLookupEdition();
|
||||||
void disableGeoLookupEdition();
|
void disableGeoLookupEdition();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue