2016-04-05 05:02:03 +00:00
|
|
|
#include "desktop-widgets/divepicturewidget.h"
|
|
|
|
#include "qt-models/divepicturemodel.h"
|
|
|
|
#include "core/metrics.h"
|
|
|
|
#include "core/dive.h"
|
|
|
|
#include "core/divelist.h"
|
2015-03-02 15:18:16 +00:00
|
|
|
#include <unistd.h>
|
2014-06-26 17:01:31 +00:00
|
|
|
#include <QtConcurrentMap>
|
2015-02-26 13:39:42 +00:00
|
|
|
#include <QtConcurrentRun>
|
2015-03-10 17:22:34 +00:00
|
|
|
#include <QFuture>
|
2014-06-26 17:01:31 +00:00
|
|
|
#include <QDir>
|
2015-02-26 13:39:42 +00:00
|
|
|
#include <QCryptographicHash>
|
2015-03-02 15:18:16 +00:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "desktop-widgets/mainwindow.h"
|
|
|
|
#include "core/qthelper.h"
|
2015-03-02 15:18:16 +00:00
|
|
|
#include <QStandardPaths>
|
2015-11-03 20:17:50 +00:00
|
|
|
#include <QtWidgets>
|
2015-03-02 15:18:16 +00:00
|
|
|
|
2014-06-03 23:48:59 +00:00
|
|
|
DivePictureWidget::DivePictureWidget(QWidget *parent) : QListView(parent)
|
2014-05-30 17:38:27 +00:00
|
|
|
{
|
2014-06-27 12:16:55 +00:00
|
|
|
connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClicked(const QModelIndex &)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DivePictureWidget::doubleClicked(const QModelIndex &index)
|
|
|
|
{
|
|
|
|
QString filePath = model()->data(index, Qt::DisplayPropertyRole).toString();
|
2015-02-26 13:39:42 +00:00
|
|
|
emit photoDoubleClicked(localFilePath(filePath));
|
2014-05-30 17:38:27 +00:00
|
|
|
}
|
2015-11-03 20:17:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
2015-11-29 15:13:57 +00:00
|
|
|
ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
|
|
|
|
static ulong lasttime = 0L;
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
if (event->timestamp() - lasttime <= doubleClickInterval) {
|
|
|
|
doubleClicked(indexAt(event->pos()));
|
|
|
|
} else {
|
|
|
|
lasttime = event->timestamp();
|
|
|
|
QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
QByteArray itemData;
|
|
|
|
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
|
|
|
dataStream << filename << event->pos();
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
QMimeData *mimeData = new QMimeData;
|
|
|
|
mimeData->setData("application/x-subsurfaceimagedrop", itemData);
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
QDrag *drag = new QDrag(this);
|
|
|
|
drag->setMimeData(mimeData);
|
|
|
|
drag->setPixmap(pixmap);
|
|
|
|
drag->setHotSpot(event->pos() - rectForIndex(indexAt(event->pos())).topLeft());
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2015-11-29 15:13:57 +00:00
|
|
|
drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
|
|
|
|
}
|
2015-11-03 20:17:50 +00:00
|
|
|
}
|