aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-11-29 12:40:06 +0100
committerGravatar Robert C. Helling <helling@atdotde.de>2017-12-01 09:44:34 +0100
commita1e6ac2e0942a3950f76432e8dcf3c195c281052 (patch)
tree8d37be8fc2b708aea41f04788f064435d828bae8
parent8ef87e618afd1ec943c0f42a852b3b393c1e2113 (diff)
downloadsubsurface-a1e6ac2e0942a3950f76432e8dcf3c195c281052.tar.gz
Dive picture handling: Re enable multi select, improve mouse events
Some improvements for the dive picture tab and dive pictures in profile: - Bugfix mouse event in profile: Only Left-click will open picture - Bugfix mouse events in picture tab: - Re-enable context menu (Windows bug mainly) - Re-enable multi select in a nice way - Only double-left-click will open picture Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r--desktop-widgets/divepicturewidget.cpp48
-rw-r--r--desktop-widgets/divepicturewidget.h4
-rw-r--r--profile-widget/divepixmapitem.cpp6
3 files changed, 28 insertions, 30 deletions
diff --git a/desktop-widgets/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp
index fcdd010da..eadc493e8 100644
--- a/desktop-widgets/divepicturewidget.cpp
+++ b/desktop-widgets/divepicturewidget.cpp
@@ -19,42 +19,40 @@
DivePictureWidget::DivePictureWidget(QWidget *parent) : QListView(parent)
{
- connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClicked(const QModelIndex &)));
}
-void DivePictureWidget::doubleClicked(const QModelIndex &index)
+void DivePictureWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
- QString filePath = model()->data(index, Qt::DisplayPropertyRole).toString();
- emit photoDoubleClicked(localFilePath(filePath));
+ if (event->button() == Qt::LeftButton) {
+ QString filePath = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
+ emit photoDoubleClicked(localFilePath(filePath));
+ }
}
-
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
{
- int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval();
- static qint64 lasttime = 0L;
- qint64 timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
-
- if (timestamp - lasttime <= doubleClickInterval) {
- doubleClicked(indexAt(event->pos()));
- } else {
- lasttime = timestamp;
- QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
-
+ if (event->button() == Qt::LeftButton && event->modifiers() == Qt::NoModifier) {
QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
- QByteArray itemData;
- QDataStream dataStream(&itemData, QIODevice::WriteOnly);
- dataStream << filename << event->pos();
+ if (!filename.isEmpty()) {
+ QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
+ QByteArray itemData;
+ QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+ dataStream << filename << event->pos();
+
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setData("application/x-subsurfaceimagedrop", itemData);
- QMimeData *mimeData = new QMimeData;
- mimeData->setData("application/x-subsurfaceimagedrop", itemData);
+ QDrag *drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(pixmap);
+ drag->setHotSpot(event->pos() - rectForIndex(indexAt(event->pos())).topLeft());
- QDrag *drag = new QDrag(this);
- drag->setMimeData(mimeData);
- drag->setPixmap(pixmap);
- drag->setHotSpot(event->pos() - rectForIndex(indexAt(event->pos())).topLeft());
+ drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+ }
- drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+ QListView::mousePressEvent(event);
+ } else {
+ QListView::mousePressEvent(event);
}
}
diff --git a/desktop-widgets/divepicturewidget.h b/desktop-widgets/divepicturewidget.h
index 7980acc54..09d4608c4 100644
--- a/desktop-widgets/divepicturewidget.h
+++ b/desktop-widgets/divepicturewidget.h
@@ -12,13 +12,11 @@ class DivePictureWidget : public QListView {
public:
DivePictureWidget(QWidget *parent);
protected:
+ void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
signals:
void photoDoubleClicked(const QString filePath);
-private
-slots:
- void doubleClicked(const QModelIndex &index);
};
class DivePictureThumbnailThread : public QThread {
diff --git a/profile-widget/divepixmapitem.cpp b/profile-widget/divepixmapitem.cpp
index 1c2f18b29..c1ce3b6dd 100644
--- a/profile-widget/divepixmapitem.cpp
+++ b/profile-widget/divepixmapitem.cpp
@@ -10,6 +10,7 @@
#include <QDesktopServices>
#include <QGraphicsView>
#include <QUrl>
+#include <QGraphicsSceneMouseEvent>
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
{
@@ -129,8 +130,9 @@ DivePictureItem::~DivePictureItem(){
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
- Q_UNUSED(event);
- QDesktopServices::openUrl(QUrl::fromLocalFile(fileUrl));
+ if (event->button() == Qt::LeftButton) {
+ QDesktopServices::openUrl(QUrl::fromLocalFile(fileUrl));
+ }
}
void DivePictureItem::removePicture()