QWidgetTextControl: implement support for pos argument to ImAbsolutePosition

Implement support in QWidgetTextControl for the new API that lets
you specify a position argument when querying for Qt::ImCursorPosition.

Change-Id: I123e2522d33e783e6f3467b81be872e3620d6d15
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
Richard Moe Gustavsen 2016-03-09 10:56:19 +01:00
parent 3b18888982
commit 382ec79fab

View File

@ -2077,8 +2077,11 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa
return d->rectForPosition(d->cursor.anchor()); return d->rectForPosition(d->cursor.anchor());
case Qt::ImFont: case Qt::ImFont:
return QVariant(d->cursor.charFormat().font()); return QVariant(d->cursor.charFormat().font());
case Qt::ImCursorPosition: case Qt::ImCursorPosition: {
return QVariant(d->cursor.position() - block.position()); const QPointF pt = argument.toPointF();
if (!pt.isNull())
return QVariant(cursorForPosition(pt).position() - block.position());
return QVariant(d->cursor.position() - block.position()); }
case Qt::ImSurroundingText: case Qt::ImSurroundingText:
return QVariant(block.text()); return QVariant(block.text());
case Qt::ImCurrentSelection: case Qt::ImCurrentSelection:
@ -2087,8 +2090,11 @@ QVariant QWidgetTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVa
return QVariant(); // No limit. return QVariant(); // No limit.
case Qt::ImAnchorPosition: case Qt::ImAnchorPosition:
return QVariant(d->cursor.anchor() - block.position()); return QVariant(d->cursor.anchor() - block.position());
case Qt::ImAbsolutePosition: case Qt::ImAbsolutePosition: {
return QVariant(d->cursor.position()); const QPointF pt = argument.toPointF();
if (!pt.isNull())
return QVariant(cursorForPosition(pt).position());
return QVariant(d->cursor.position()); }
case Qt::ImTextAfterCursor: case Qt::ImTextAfterCursor:
{ {
int maxLength = argument.isValid() ? argument.toInt() : 1024; int maxLength = argument.isValid() ? argument.toInt() : 1024;