diff options
| author | Michael Weghorn <[email protected]> | 2025-09-24 22:08:30 +0200 |
|---|---|---|
| committer | Michael Weghorn <[email protected]> | 2025-11-01 17:23:39 +0200 |
| commit | 1302a8fdc18c217b5c7831542879d39900802fd7 (patch) | |
| tree | e323b4f7e5912b7ec7eb601ca17d5ad0278e9a24 | |
| parent | 72219375fcae2b4a2663b07ac532427b5254ef38 (diff) | |
New QtGuiPrivate helper methods qt_accTextBeforeOffsetHelper,
qt_accTextAfterOffsetHelper and qt_accTextAtOffsetHelper
were recently introduced in qtbase as QtGuiPrivate helper
functions in order to deduplicate the logic implemented in
both, QAccessibleTextWidget (in qtbase) and QAccessibleQuickItem,
and then fix existing issues in one place.
Switch the QAccessibleQuickItem implementations to use these
helpers, which fixes the issue described in more detail
for the QTextEdit in QTBUG-140504 also for the QML TextEdit.
Task-number: QTBUG-140504
Task-number: QTBUG-139943
Change-Id: Ia50213d114ca415c24837e0212619a369d31bc3c
Reviewed-by: Morten Johan Sørvig <[email protected]>
| -rw-r--r-- | src/quick/accessible/qaccessiblequickitem.cpp | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp index cac896143d..a55b817701 100644 --- a/src/quick/accessible/qaccessiblequickitem.cpp +++ b/src/quick/accessible/qaccessiblequickitem.cpp @@ -4,6 +4,7 @@ #include "qaccessiblequickitem_p.h" +#include <QtGui/private/qaccessiblehelper_p.h> #include <QtGui/qtextdocument.h> #include "QtQuick/private/qquickitem_p.h" @@ -876,16 +877,7 @@ QString QAccessibleQuickItem::textBeforeOffset(int offset, QAccessible::TextBoun Q_ASSERT(endOffset); if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.first - 1); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); + return qt_accTextBeforeOffsetHelper(*this, QTextCursor(m_doc), offset, boundaryType, startOffset, endOffset); } else { return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset); } @@ -898,16 +890,7 @@ QString QAccessibleQuickItem::textAfterOffset(int offset, QAccessible::TextBound Q_ASSERT(endOffset); if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.second); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); + return qt_accTextAfterOffsetHelper(*this, QTextCursor(m_doc), offset, boundaryType, startOffset, endOffset); } else { return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset); } @@ -920,13 +903,7 @@ QString QAccessibleQuickItem::textAtOffset(int offset, QAccessible::TextBoundary Q_ASSERT(endOffset); if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - return text(boundaries.first, boundaries.second); + return qt_accTextAtOffsetHelper(*this, QTextCursor(m_doc), offset, boundaryType, startOffset, endOffset); } else { return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset); } |
