mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Delete pictures from the Widget by pressing delete
Select the picture, press delete, profit. [Dirk Hohndel: removed the stray hunk that snuck into this patch] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b0addb4567
commit
68af9f0afb
4 changed files with 24 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ slots:
|
|||
void updateTextLabels(bool showUnits = true);
|
||||
void escDetected(void);
|
||||
void photoDoubleClicked(const QString filePath);
|
||||
|
||||
void removeSelectedPhotos();
|
||||
private:
|
||||
Ui::MainTab ui;
|
||||
WeightModel *weightModel;
|
||||
|
|
|
@ -114,6 +114,11 @@ void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
button->hide();
|
||||
}
|
||||
|
||||
DivePictureItem::~DivePictureItem(){
|
||||
if(button)
|
||||
Animations::hide(button);
|
||||
}
|
||||
|
||||
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(fileUrl));
|
||||
|
@ -121,7 +126,5 @@ void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
void DivePictureItem::removePicture()
|
||||
{
|
||||
Animations::hide(button);
|
||||
hide();
|
||||
DivePictureModel::instance()->removePicture(fileUrl);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class DivePictureItem : public DivePixmapItem {
|
|||
Q_PROPERTY(qreal scale WRITE setScale READ scale)
|
||||
public:
|
||||
DivePictureItem(QObject *parent = 0);
|
||||
virtual ~DivePictureItem();
|
||||
void setPixmap(const QPixmap& pix);
|
||||
public slots:
|
||||
void settingsChanged();
|
||||
|
|
Loading…
Reference in a new issue