Hi,
oops sorry, this should be better: |
From 0ace99dd633761648da675acd3a1e433cdef7fdf Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Sun, 29 Nov 2015 16:13:57 +0100 Subject: [PATCH] Make pictures respond to double clicks again
The Drag & Drop functionality swallowd the click events so double clicks never happend. So here, we detect this and call the handler explicitly. Signed-off-by: Robert C. Helling <[email protected]> --- desktop-widgets/divepicturewidget.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/desktop-widgets/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp index c612ab6..d52fbb9 100644 --- a/desktop-widgets/divepicturewidget.cpp +++ b/desktop-widgets/divepicturewidget.cpp @@ -30,22 +30,29 @@ void DivePictureWidget::doubleClicked(const QModelIndex &index) void DivePictureWidget::mousePressEvent(QMouseEvent *event) { + ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval()); + static ulong lasttime = 0L; - QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>(); + if (event->timestamp() - lasttime <= doubleClickInterval) { + doubleClicked(indexAt(event->pos())); + } else { + lasttime = event->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; - QDataStream dataStream(&itemData, QIODevice::WriteOnly); - dataStream << filename << event->pos(); + 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); + } } -- 1.9.5 (Apple Git-50.3)
I forgot to press save in Creator between fixing spacing and committing. Which brings me to another point: For some reason,^H^H^H^H^H^H^H^H. No, now I understand, so I document it here for others not to fall in the same trap: Last time I looked at the subsurface source, I had enabled subsurface-mobile in ccmake. The result was that Qt Creator did not consider the subdirectory desktop-widgets as source code any more. Which a) meant I could not open the file via Control-K but also meant that it did not consider it C++ even though it has a .cpp file extension and thus it does not apply the coding style. It insisted in indenting with four spaces. Then another problem was that I tried so many things to fix this bug but it wouldn’t go away. Actually, the binary always did the same thing and no debugging messages from qDebug() were printed. So I realised that I should run ccmake again. What I forgot was to run cmake in Creator once more. But then I realised that also for text files, in a different preference screen, I could set indentation to TAB with 8 steps. But then, as I said, I forgot to save. But this is now amended with tabs instead of spaces. Sorry for this. Robert |
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
