| 359 | |
| 360 | |
| 361 | QVariant TextObjectEditorHelper::inputMethodQuery(Qt::InputMethodQuery property, const QVariant& argument) const |
| 362 | { |
| 363 | switch (property) |
| 364 | { |
| 365 | case Qt::ImHints: |
| 366 | return { Qt::ImhMultiLine }; |
| 367 | case Qt::ImAnchorPosition: |
| 368 | return { anchor_position - blockStart() }; |
| 369 | case Qt::ImCursorPosition: |
| 370 | { |
| 371 | const auto point = argument.toPointF(); |
| 372 | if (!point.isNull()) |
| 373 | { |
| 374 | auto map_coord = editor->getMainWidget()->viewportToMapF(point); |
| 375 | return { text_object->calcTextPositionAt(map_coord, false) - blockStart() }; |
| 376 | } |
| 377 | } |
| 378 | return { cursor_position - blockStart() }; |
| 379 | case Qt::ImCursorRectangle: |
| 380 | return { cursorRectangle() }; |
| 381 | case Qt::ImSurroundingText: |
| 382 | return pristine_text.mid(blockStart(), blockEnd() - blockStart()); |
| 383 | case Qt::ImCurrentSelection: |
| 384 | return { selectionText() }; |
| 385 | case Qt::ImMaximumTextLength: |
| 386 | return { }; // No limit. |
| 387 | case Qt::ImAbsolutePosition: |
| 388 | { |
| 389 | const auto point = argument.toPointF(); |
| 390 | if (!point.isNull()) |
| 391 | { |
| 392 | auto map_coord = editor->getMainWidget()->viewportToMapF(point); |
| 393 | return { text_object->calcTextPositionAt(map_coord, false) }; |
| 394 | } |
| 395 | } |
| 396 | return { cursor_position }; |
| 397 | case Qt::ImTextBeforeCursor: |
| 398 | return pristine_text.mid(blockStart(), cursor_position - blockStart()); |
| 399 | case Qt::ImTextAfterCursor: |
| 400 | return pristine_text.mid(cursor_position, blockEnd() - cursor_position); |
| 401 | default: |
| 402 | return { }; |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | |
| 407 | bool TextObjectEditorHelper::inputMethodEvent(QInputMethodEvent* event) |
nothing calls this directly
no test coverage detected