forked from qt-creator/qt-creator
Editor: Fix drop location marker
Change-Id: Id63ff9e8089fd8aaf38fb61ff6d79384a60135d7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -768,6 +768,7 @@ public:
|
|||||||
bool m_markDragging = false;
|
bool m_markDragging = false;
|
||||||
QCursor m_markDragCursor;
|
QCursor m_markDragCursor;
|
||||||
TextMark* m_dragMark = nullptr;
|
TextMark* m_dragMark = nullptr;
|
||||||
|
QTextCursor m_dndCursor;
|
||||||
|
|
||||||
QScopedPointer<ClipboardAssistProvider> m_clipboardAssistProvider;
|
QScopedPointer<ClipboardAssistProvider> m_clipboardAssistProvider;
|
||||||
|
|
||||||
@@ -4298,9 +4299,18 @@ void TextEditorWidgetPrivate::addCursorsPosition(PaintEventData &data,
|
|||||||
QPainter &painter,
|
QPainter &painter,
|
||||||
const PaintEventBlockData &blockData) const
|
const PaintEventBlockData &blockData) const
|
||||||
{
|
{
|
||||||
|
if (!m_dndCursor.isNull()) {
|
||||||
|
if (blockContainsCursor(blockData, m_dndCursor)) {
|
||||||
|
data.cursors.append(
|
||||||
|
generateCursorData(m_dndCursor.positionInBlock(), data, blockData, painter));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const QTextCursor &cursor : m_cursors) {
|
for (const QTextCursor &cursor : m_cursors) {
|
||||||
if (blockContainsCursor(blockData, cursor))
|
if (blockContainsCursor(blockData, cursor)) {
|
||||||
data.cursors.append(generateCursorData(cursor.positionInBlock(), data, blockData, painter));
|
data.cursors.append(
|
||||||
|
generateCursorData(cursor.positionInBlock(), data, blockData, painter));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4377,13 +4387,17 @@ void TextEditorWidget::paintEvent(QPaintEvent *e)
|
|||||||
|
|
||||||
d->paintCurrentLineHighlight(data, painter);
|
d->paintCurrentLineHighlight(data, painter);
|
||||||
|
|
||||||
bool drawCursor = d->m_cursorVisible
|
bool drawCursor = false;
|
||||||
&& Utils::anyOf(d->m_cursors,
|
bool drawCursorAsBlock = false;
|
||||||
[&](const QTextCursor &cursor) {
|
if (d->m_dndCursor.isNull()) {
|
||||||
|
drawCursor = d->m_cursorVisible
|
||||||
|
&& Utils::anyOf(d->m_cursors, [&](const QTextCursor &cursor) {
|
||||||
return blockContainsCursor(blockData, cursor);
|
return blockContainsCursor(blockData, cursor);
|
||||||
});
|
});
|
||||||
|
drawCursorAsBlock = drawCursor && overwriteMode();
|
||||||
bool drawCursorAsBlock = drawCursor && overwriteMode();
|
} else {
|
||||||
|
drawCursor = blockContainsCursor(blockData, d->m_dndCursor);
|
||||||
|
}
|
||||||
|
|
||||||
if (drawCursorAsBlock) {
|
if (drawCursorAsBlock) {
|
||||||
for (const QTextCursor &cursor : multiTextCursor()) {
|
for (const QTextCursor &cursor : multiTextCursor()) {
|
||||||
@@ -7375,8 +7389,29 @@ void TextEditorWidget::insertFromMimeData(const QMimeData *source)
|
|||||||
setMultiTextCursor(cursor);
|
setMultiTextCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidget::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
|
{
|
||||||
|
const QRect rect = cursorRect(d->m_dndCursor);
|
||||||
|
d->m_dndCursor = QTextCursor();
|
||||||
|
if (!rect.isNull())
|
||||||
|
viewport()->update(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEditorWidget::dragMoveEvent(QDragMoveEvent *e)
|
||||||
|
{
|
||||||
|
const QRect rect = cursorRect(d->m_dndCursor);
|
||||||
|
d->m_dndCursor = cursorForPosition(e->pos());
|
||||||
|
if (!rect.isNull())
|
||||||
|
viewport()->update(rect);
|
||||||
|
viewport()->update(cursorRect(d->m_dndCursor));
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditorWidget::dropEvent(QDropEvent *e)
|
void TextEditorWidget::dropEvent(QDropEvent *e)
|
||||||
{
|
{
|
||||||
|
const QRect rect = cursorRect(d->m_dndCursor);
|
||||||
|
d->m_dndCursor = QTextCursor();
|
||||||
|
if (!rect.isNull())
|
||||||
|
viewport()->update(rect);
|
||||||
const QMimeData *mime = e->mimeData();
|
const QMimeData *mime = e->mimeData();
|
||||||
if (!canInsertFromMimeData(mime))
|
if (!canInsertFromMimeData(mime))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -531,6 +531,8 @@ protected:
|
|||||||
QMimeData *createMimeDataFromSelection() const override;
|
QMimeData *createMimeDataFromSelection() const override;
|
||||||
bool canInsertFromMimeData(const QMimeData *source) const override;
|
bool canInsertFromMimeData(const QMimeData *source) const override;
|
||||||
void insertFromMimeData(const QMimeData *source) override;
|
void insertFromMimeData(const QMimeData *source) override;
|
||||||
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
||||||
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
void dropEvent(QDropEvent *e) override;
|
void dropEvent(QDropEvent *e) override;
|
||||||
|
|
||||||
virtual QString plainTextFromSelection(const QTextCursor &cursor) const;
|
virtual QString plainTextFromSelection(const QTextCursor &cursor) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user