API cleanup: remove CoordinateType enum
The bridge can do the mapping to and from screen position. This is now done in the windows bridge. Change-Id: I5ca5df0fbeeb58202539f55a0f62717fb1685092 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>bb10
parent
d86e101d1b
commit
015bc43da0
|
|
@ -56,12 +56,6 @@ class QModelIndex;
|
|||
|
||||
namespace QAccessible2
|
||||
{
|
||||
enum CoordinateType
|
||||
{
|
||||
RelativeToScreen = 0,
|
||||
RelativeToParent = 1
|
||||
};
|
||||
|
||||
enum BoundaryType {
|
||||
CharBoundary,
|
||||
WordBoundary,
|
||||
|
|
@ -80,9 +74,9 @@ public:
|
|||
virtual void addSelection(int startOffset, int endOffset) = 0;
|
||||
virtual QString attributes(int offset, int *startOffset, int *endOffset) const = 0;
|
||||
virtual int cursorPosition() const = 0;
|
||||
virtual QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const = 0;
|
||||
virtual QRect characterRect(int offset) const = 0;
|
||||
virtual int selectionCount() const = 0;
|
||||
virtual int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const = 0;
|
||||
virtual int offsetAtPoint(const QPoint &point) const = 0;
|
||||
virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0;
|
||||
virtual QString text(int startOffset, int endOffset) const = 0;
|
||||
virtual QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
|
||||
|
|
@ -249,7 +243,7 @@ public:
|
|||
|
||||
virtual QString imageDescription() const = 0;
|
||||
virtual QSize imageSize() const = 0;
|
||||
virtual QRect imagePosition(QAccessible2::CoordinateType coordType) const = 0;
|
||||
virtual QRect imagePosition() const = 0;
|
||||
};
|
||||
|
||||
#endif // QT_NO_ACCESSIBILITY
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ int QAccessibleTextEdit::cursorPosition() const
|
|||
return textEdit()->textCursor().position();
|
||||
}
|
||||
|
||||
QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType) const
|
||||
QRect QAccessibleTextEdit::characterRect(int offset) const
|
||||
{
|
||||
QTextEdit *edit = textEdit();
|
||||
QTextCursor cursor(edit->document());
|
||||
|
|
@ -293,14 +293,7 @@ QRect QAccessibleTextEdit::characterRect(int offset, CoordinateType coordType) c
|
|||
r.setWidth(averageCharWidth);
|
||||
}
|
||||
|
||||
switch (coordType) {
|
||||
case RelativeToScreen:
|
||||
r.moveTo(edit->viewport()->mapToGlobal(r.topLeft()));
|
||||
break;
|
||||
case RelativeToParent:
|
||||
break;
|
||||
}
|
||||
|
||||
r.moveTo(edit->viewport()->mapToGlobal(r.topLeft()));
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -309,13 +302,11 @@ int QAccessibleTextEdit::selectionCount() const
|
|||
return textEdit()->textCursor().hasSelection() ? 1 : 0;
|
||||
}
|
||||
|
||||
int QAccessibleTextEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const
|
||||
int QAccessibleTextEdit::offsetAtPoint(const QPoint &point) const
|
||||
{
|
||||
QTextEdit *edit = textEdit();
|
||||
|
||||
QPoint p = point;
|
||||
if (coordType == RelativeToScreen)
|
||||
p = edit->viewport()->mapFromGlobal(p);
|
||||
QPoint p = edit->viewport()->mapFromGlobal(point);
|
||||
// convert to document coordinates
|
||||
p += QPoint(edit->horizontalScrollBar()->value(), edit->verticalScrollBar()->value());
|
||||
|
||||
|
|
|
|||
|
|
@ -81,9 +81,9 @@ public:
|
|||
void addSelection(int startOffset, int endOffset);
|
||||
QString attributes(int offset, int *startOffset, int *endOffset) const;
|
||||
int cursorPosition() const;
|
||||
QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const;
|
||||
QRect characterRect(int offset) const;
|
||||
int selectionCount() const;
|
||||
int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const;
|
||||
int offsetAtPoint(const QPoint &point) const;
|
||||
void selection(int selectionIndex, int *startOffset, int *endOffset) const;
|
||||
QString text(int startOffset, int endOffset) const;
|
||||
QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ QSize QAccessibleDisplay::imageSize() const
|
|||
}
|
||||
|
||||
/*! \internal */
|
||||
QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) const
|
||||
QRect QAccessibleDisplay::imagePosition() const
|
||||
{
|
||||
QLabel *label = qobject_cast<QLabel *>(widget());
|
||||
if (!label)
|
||||
|
|
@ -499,14 +499,7 @@ QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
|
|||
if (!pixmap)
|
||||
return QRect();
|
||||
|
||||
switch (coordType) {
|
||||
case QAccessible2::RelativeToScreen:
|
||||
return QRect(label->mapToGlobal(label->pos()), label->size());
|
||||
case QAccessible2::RelativeToParent:
|
||||
return label->geometry();
|
||||
}
|
||||
|
||||
return QRect();
|
||||
return QRect(label->mapToGlobal(label->pos()), label->size());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_LINEEDIT
|
||||
|
|
@ -613,7 +606,7 @@ int QAccessibleLineEdit::cursorPosition() const
|
|||
return lineEdit()->cursorPosition();
|
||||
}
|
||||
|
||||
QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/) const
|
||||
QRect QAccessibleLineEdit::characterRect(int /*offset*/) const
|
||||
{
|
||||
// QLineEdit doesn't hand out character rects
|
||||
return QRect();
|
||||
|
|
@ -624,11 +617,9 @@ int QAccessibleLineEdit::selectionCount() const
|
|||
return lineEdit()->hasSelectedText() ? 1 : 0;
|
||||
}
|
||||
|
||||
int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType) const
|
||||
int QAccessibleLineEdit::offsetAtPoint(const QPoint &point) const
|
||||
{
|
||||
QPoint p = point;
|
||||
if (coordType == RelativeToScreen)
|
||||
p = lineEdit()->mapFromGlobal(p);
|
||||
QPoint p = lineEdit()->mapFromGlobal(point);
|
||||
|
||||
return lineEdit()->cursorPositionAt(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public:
|
|||
// QAccessibleImageInterface
|
||||
QString imageDescription() const;
|
||||
QSize imageSize() const;
|
||||
QRect imagePosition(QAccessible2::CoordinateType coordType) const;
|
||||
QRect imagePosition() const;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_LINEEDIT
|
||||
|
|
@ -129,9 +129,9 @@ public:
|
|||
void addSelection(int startOffset, int endOffset);
|
||||
QString attributes(int offset, int *startOffset, int *endOffset) const;
|
||||
int cursorPosition() const;
|
||||
QRect characterRect(int offset, QAccessible2::CoordinateType coordType) const;
|
||||
QRect characterRect(int offset) const;
|
||||
int selectionCount() const;
|
||||
int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) const;
|
||||
int offsetAtPoint(const QPoint &point) const;
|
||||
void selection(int selectionIndex, int *startOffset, int *endOffset) const;
|
||||
QString text(int startOffset, int endOffset) const;
|
||||
QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
|
||||
|
|
|
|||
|
|
@ -1028,6 +1028,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_caretOffset(long *offset)
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offset,
|
||||
enum IA2CoordinateType coordType,
|
||||
long *x,
|
||||
|
|
@ -1037,9 +1038,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_characterExtents(long offse
|
|||
{
|
||||
accessibleDebugClientCalls(accessible);
|
||||
if (QAccessibleTextInterface *text = textInterface()) {
|
||||
const QRect rect = text->characterRect(offset, (QAccessible2::CoordinateType)coordType);
|
||||
*x = rect.x();
|
||||
*y = rect.y();
|
||||
QRect rect = text->characterRect(offset);
|
||||
mapFromScreenPos(coordType, rect.topLeft(), x, y);
|
||||
*width = rect.width();
|
||||
*height = rect.height();
|
||||
return S_OK;
|
||||
|
|
@ -1064,7 +1064,8 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_offsetAtPoint(long x,
|
|||
{
|
||||
accessibleDebugClientCalls(accessible);
|
||||
if (QAccessibleTextInterface *text = textInterface()) {
|
||||
*offset = text->offsetAtPoint(QPoint(x,y), (QAccessible2::CoordinateType)coordType);
|
||||
QPoint screenPos = mapToScreenPos(coordType, x, y);
|
||||
*offset = text->offsetAtPoint(screenPos);
|
||||
return (*offset >=0 ? S_OK : S_FALSE);
|
||||
}
|
||||
return E_FAIL;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,40 @@ private:
|
|||
return accessible->tableCellInterface();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\a screenPos is in screen relative position
|
||||
\a x and \y (out) is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE
|
||||
*/
|
||||
void mapFromScreenPos(enum IA2CoordinateType coordType, const QPoint &screenPos, long *x, long *y) const {
|
||||
if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) {
|
||||
// caller wants relative to parent
|
||||
if (QAccessibleInterface *parent = accessible->parent()) {
|
||||
const QRect parentScreenRect = parent->rect();
|
||||
*x = parentScreenRect.x() - screenPos.x();
|
||||
*y = parentScreenRect.y() - screenPos.y();
|
||||
return;
|
||||
}
|
||||
}
|
||||
*x = screenPos.x();
|
||||
*y = screenPos.y();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\a x and \y is in parent relative position if coordType == IA2_COORDTYPE_PARENT_RELATIVE
|
||||
\return a screen relative position
|
||||
*/
|
||||
QPoint mapToScreenPos(enum IA2CoordinateType coordType, long x, long y) const {
|
||||
if (coordType == IA2_COORDTYPE_PARENT_RELATIVE) {
|
||||
if (QAccessibleInterface *parent = accessible->parent()) {
|
||||
const QRect parentScreenRect = parent->rect();
|
||||
return QPoint(parentScreenRect.x() + x, parentScreenRect.y() + y);
|
||||
}
|
||||
}
|
||||
return QPoint(x,y);
|
||||
}
|
||||
|
||||
HRESULT getRelationsHelper(IAccessibleRelation **relations, int startIndex, long maxRelations, long *nRelations = 0);
|
||||
HRESULT wrapListOfCells(const QList<QAccessibleInterface*> &inputCells, IUnknown ***outputAccessibles, long *nCellCount);
|
||||
uint uniqueID() const;
|
||||
|
|
|
|||
|
|
@ -1527,9 +1527,9 @@ void tst_QAccessibility::textEditTest()
|
|||
QCOMPARE(endOffset, 30);
|
||||
QCOMPARE(iface->textInterface()->characterCount(), 31);
|
||||
QFontMetrics fm(edit.font());
|
||||
QCOMPARE(iface->textInterface()->characterRect(0, QAccessible2::RelativeToParent).size(), QSize(fm.width("h"), fm.height()));
|
||||
QCOMPARE(iface->textInterface()->characterRect(5, QAccessible2::RelativeToParent).size(), QSize(fm.width(" "), fm.height()));
|
||||
QCOMPARE(iface->textInterface()->characterRect(6, QAccessible2::RelativeToParent).size(), QSize(fm.width("w"), fm.height()));
|
||||
QCOMPARE(iface->textInterface()->characterRect(0).size(), QSize(fm.width("h"), fm.height()));
|
||||
QCOMPARE(iface->textInterface()->characterRect(5).size(), QSize(fm.width(" "), fm.height()));
|
||||
QCOMPARE(iface->textInterface()->characterRect(6).size(), QSize(fm.width("w"), fm.height()));
|
||||
|
||||
iface->editableTextInterface()->copyText(6, 11);
|
||||
QCOMPARE(QApplication::clipboard()->text(), QLatin1String("world"));
|
||||
|
|
@ -2760,7 +2760,8 @@ void tst_QAccessibility::labelTest()
|
|||
|
||||
QCOMPARE(imageInterface->imageSize(), testPixmap.size());
|
||||
QCOMPARE(imageInterface->imageDescription(), QString::fromLatin1("Test Description"));
|
||||
QCOMPARE(imageInterface->imagePosition(QAccessible2::RelativeToParent), imageLabel.geometry());
|
||||
const QPoint labelPos = imageLabel.mapToGlobal(QPoint(0,0));
|
||||
QCOMPARE(imageInterface->imagePosition().topLeft(), labelPos);
|
||||
|
||||
delete acc_label;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue