diff options
author | Jan-Arve Saether <jan-arve.saether@nokia.com> | 2012-08-13 15:35:44 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-16 14:10:43 (GMT) |
commit | 8c749cab4d457644a14698709d1c74dfa4d5ac6e (patch) | |
tree | 5ef0f063f50db9fa835b8f0de3b78ff6dfb99061 /src/plugins/accessible | |
parent | 4917daf500f0403042de35fcc17daa2d7d4f8475 (diff) | |
download | Qt-8c749cab4d457644a14698709d1c74dfa4d5ac6e.zip Qt-8c749cab4d457644a14698709d1c74dfa4d5ac6e.tar.gz Qt-8c749cab4d457644a14698709d1c74dfa4d5ac6e.tar.bz2 |
Implement QAccessibleLineEdit::characterRect()
It was probably not implemented because it needed to access
private APIs.
However, accessing those from this a11y plugin is unproblematic.
Change-Id: Icadad45a83daa60e2fbc4cab17b91c84c3f36a7f
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Diffstat (limited to 'src/plugins/accessible')
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 46d76f0..126045e 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -51,6 +51,7 @@ #include <qgroupbox.h> #include <qlcdnumber.h> #include <qlineedit.h> +#include <private/qlineedit_p.h> #include <qstyle.h> #include <qstyleoption.h> @@ -876,10 +877,22 @@ int QAccessibleLineEdit::cursorPosition() return lineEdit()->cursorPosition(); } -QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/) +QRect QAccessibleLineEdit::characterRect(int offset, CoordinateType coordType) { - // QLineEdit doesn't hand out character rects - return QRect(); + int left, top, right, bottom; + lineEdit()->getTextMargins(&left, &top, &right, &bottom); + int x = lineEdit()->d_func()->control->cursorToX(offset); + int y = top; + QFontMetrics fm(lineEdit()->font()); + const QString ch = text(offset, offset + 1); + int w = fm.width(ch); + int h = fm.height(); + + QRect r(x, y, w, h); + if (coordType == QAccessible2::RelativeToScreen) + r.moveTo(lineEdit()->mapToGlobal(r.topLeft())); + + return r; } int QAccessibleLineEdit::selectionCount() |