Commit e440ec8a authored by Marcel Krems's avatar Marcel Krems Committed by hjk

BaseTextEditor: Fixed dragging of ITextMarks.

Only start dragging, when a draggable marker was clicked.
Reset drag after releasing mouse button.

Change-Id: I2dc275fc108b55d84b9ff5c69847b116c3307c41
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 10d22b08
......@@ -4391,7 +4391,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
emit editor()->markTooltipRequested(editor(), mapToGlobal(e->pos()), line);
}
if (e->buttons() & Qt::LeftButton) {
if (e->buttons() & Qt::LeftButton && !d->m_markDragStart.isNull()) {
int dist = (e->pos() - d->m_markDragStart).manhattanLength();
if (dist > QApplication::startDragDistance())
d->m_markDragging = true;
......@@ -4428,7 +4428,17 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
} else {
d->extraAreaToggleMarkBlockNumber = cursor.blockNumber();
d->m_markDragging = false;
d->m_markDragStart = e->pos();
QTextBlock block = cursor.document()->findBlockByNumber(d->extraAreaToggleMarkBlockNumber);
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
TextMarks marks = data->marks();
for (int i = marks.size(); --i >= 0; ) {
ITextMark *mark = marks.at(i);
if (mark->isDraggable()) {
d->m_markDragStart = e->pos();
break;
}
}
}
}
}
} else if (d->extraAreaSelectionAnchorBlockNumber >= 0) {
......@@ -4465,6 +4475,7 @@ void BaseTextEditorWidget::extraAreaMouseEvent(QMouseEvent *e)
const bool sameLine = cursor.blockNumber() == n;
const bool wasDragging = d->m_markDragging;
d->m_markDragging = false;
d->m_markDragStart = QPoint();
QTextBlock block = cursor.document()->findBlockByNumber(n);
if (TextBlockUserData *data = static_cast<TextBlockUserData *>(block.userData())) {
TextMarks marks = data->marks();
......
Markdown is supported
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