diff options
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ed65a1943..d49c8844c 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -167,6 +167,13 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.cylinders->view()->setColumnHidden(i, checked); ui.cylinders->view()->horizontalHeader()->addAction(action); } + + QAction *deletePhoto = new QAction(this); + deletePhoto->setShortcut(Qt::Key_Delete); + deletePhoto->setShortcutContext(Qt::WidgetShortcut); + ui.photosView->addAction(deletePhoto); + ui.photosView->setSelectionMode(QAbstractItemView::SingleSelection); + connect(deletePhoto, SIGNAL(triggered(bool)), this, SLOT(removeSelectedPhotos())); } MainTab::~MainTab() @@ -1153,3 +1160,13 @@ void MainTab::photoDoubleClicked(const QString filePath) { QDesktopServices::openUrl(QUrl::fromLocalFile(filePath)); } + +void MainTab::removeSelectedPhotos() +{ + if (!ui.photosView->selectionModel()->hasSelection()) + return; + + QModelIndex photoIndex = ui.photosView->selectionModel()->selectedIndexes().first(); + QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString(); + DivePictureModel::instance()->removePicture(fileUrl); +} |