mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
8ef87e618a
commit
a1e6ac2e09
3 changed files with 28 additions and 30 deletions
|
@ -19,42 +19,40 @@
|
||||||
|
|
||||||
DivePictureWidget::DivePictureWidget(QWidget *parent) : QListView(parent)
|
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();
|
if (event->button() == Qt::LeftButton) {
|
||||||
emit photoDoubleClicked(localFilePath(filePath));
|
QString filePath = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
|
||||||
|
emit photoDoubleClicked(localFilePath(filePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
|
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval();
|
if (event->button() == Qt::LeftButton && event->modifiers() == Qt::NoModifier) {
|
||||||
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>();
|
|
||||||
|
|
||||||
QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
|
QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
|
||||||
|
|
||||||
QByteArray itemData;
|
if (!filename.isEmpty()) {
|
||||||
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
|
||||||
dataStream << filename << event->pos();
|
QByteArray itemData;
|
||||||
|
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
||||||
|
dataStream << filename << event->pos();
|
||||||
|
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-subsurfaceimagedrop", itemData);
|
mimeData->setData("application/x-subsurfaceimagedrop", itemData);
|
||||||
|
|
||||||
QDrag *drag = new QDrag(this);
|
QDrag *drag = new QDrag(this);
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
drag->setPixmap(pixmap);
|
drag->setPixmap(pixmap);
|
||||||
drag->setHotSpot(event->pos() - rectForIndex(indexAt(event->pos())).topLeft());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,11 @@ class DivePictureWidget : public QListView {
|
||||||
public:
|
public:
|
||||||
DivePictureWidget(QWidget *parent);
|
DivePictureWidget(QWidget *parent);
|
||||||
protected:
|
protected:
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void photoDoubleClicked(const QString filePath);
|
void photoDoubleClicked(const QString filePath);
|
||||||
private
|
|
||||||
slots:
|
|
||||||
void doubleClicked(const QModelIndex &index);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DivePictureThumbnailThread : public QThread {
|
class DivePictureThumbnailThread : public QThread {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
|
||||||
{
|
{
|
||||||
|
@ -129,8 +130,9 @@ DivePictureItem::~DivePictureItem(){
|
||||||
|
|
||||||
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
if (event->button() == Qt::LeftButton) {
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(fileUrl));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(fileUrl));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePictureItem::removePicture()
|
void DivePictureItem::removePicture()
|
||||||
|
|
Loading…
Add table
Reference in a new issue