VTextEdit: force to update() to show cursor while dragging text

This is a work-around.
This commit is contained in:
Le Tan 2018-07-19 20:53:09 +08:00
parent 42fbdace55
commit 21e5aac024
4 changed files with 23 additions and 10 deletions

View File

@ -793,16 +793,6 @@ void VTextDocumentLayout::updateDocumentSize()
}
}
void VTextDocumentLayout::setCursorWidth(int p_width)
{
m_cursorWidth = p_width;
}
int VTextDocumentLayout::cursorWidth() const
{
return m_cursorWidth;
}
QRectF VTextDocumentLayout::blockRectFromTextLayout(const QTextBlock &p_block,
ImagePaintInfo *p_image)
{

View File

@ -385,4 +385,14 @@ inline void VTextDocumentLayout::setCursorLineBlockNumber(int p_blockNumber)
}
}
}
inline void VTextDocumentLayout::setCursorWidth(int p_width)
{
m_cursorWidth = p_width;
}
inline int VTextDocumentLayout::cursorWidth() const
{
return m_cursorWidth;
}
#endif // VTEXTDOCUMENTLAYOUT_H

View File

@ -447,3 +447,14 @@ void VTextEdit::updateLineNumberAreaWidth(const QFontMetrics &p_metrics)
{
m_lineNumberArea->setDigitWidth(p_metrics.width(QLatin1Char('8')));
}
void VTextEdit::dragMoveEvent(QDragMoveEvent *p_event)
{
QTextEdit::dragMoveEvent(p_event);
// We need to update the cursor rect to show the cursor while dragging text.
// This is a work-around. We do not know why VTextEdit won't update the cursor
// rect to show the cursor.
// TODO: find out the rect of current cursor to update that rect only.
update();
}

View File

@ -83,6 +83,8 @@ protected:
void updateLineNumberAreaWidth(const QFontMetrics &p_metrics);
void dragMoveEvent(QDragMoveEvent *p_event) Q_DECL_OVERRIDE;
private slots:
// Update viewport margin to hold the line number area.
void updateLineNumberAreaMargin();