Commit 1246f319 authored by José Luis Vergara's avatar José Luis Vergara Committed by Jean-Nicolas Artaud
Browse files

Handle the start of a drag event in KoDocumentSectionView to bypass a bug in QTreeView

BUG:187346
parent a1bb9acd
......@@ -28,6 +28,7 @@
#include <QMenu>
#include <QMouseEvent>
#include <QPersistentModelIndex>
#include <QApplication>
class KoDocumentSectionView::Private
{
......@@ -36,6 +37,7 @@ public:
KoDocumentSectionDelegate *delegate;
DisplayMode mode;
QPersistentModelIndex hovered;
QPoint lastPos;
};
KoDocumentSectionView::KoDocumentSectionView(QWidget *parent)
......@@ -91,6 +93,7 @@ bool KoDocumentSectionView::viewportEvent(QEvent *e)
switch(e->type()) {
case QEvent::MouseButtonPress: {
const QPoint pos = static_cast<QMouseEvent*>(e)->pos();
d->lastPos = pos;
if (!indexAt(pos).isValid())
return QTreeView::viewportEvent(e);
QModelIndex index = model()->buddy(indexAt(pos));
......@@ -116,6 +119,13 @@ bool KoDocumentSectionView::viewportEvent(QEvent *e)
}
d->hovered = hovered;
}
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
if ((Qt::LeftButton | Qt::MidButton) & mouseEvent->buttons()) {
if ((mouseEvent->pos() - d->lastPos).manhattanLength() > qApp->startDragDistance()) {
return QTreeView::viewportEvent(e);
}
return true;
}
} break;
case QEvent::ToolTip: {
const QPoint pos = static_cast<QHelpEvent*>(e)->pos();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment