Use interfaces in QAccessibleWidget childAt.

Simplify the implementation of childAt.
Using rect(child) depends on the virtual children.

For QAccessibleMenuBar the implementation would assert.

Change-Id: I6ef018a063beee67d7436dff148e8b0219ff2a3c
Reviewed-on: http://codereview.qt-project.org/5742
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
bb10
Frederik Gladhorn 2011-09-28 17:03:07 +02:00 committed by Qt by Nokia
parent 5ea07a9cd1
commit b67708f3d3
3 changed files with 7 additions and 27 deletions

View File

@ -199,15 +199,6 @@ QRect QAccessibleMenuBar::rect(int child) const
return QAccessibleWidget::rect(child);
}
int QAccessibleMenuBar::childAt(int x, int y) const
{
for (int i = childCount(); i >= 0; --i) {
if (rect(i).contains(x,y))
return i;
}
return -1;
}
QAccessibleInterface *QAccessibleMenuBar::child(int index) const
{
if (index < childCount())

View File

@ -85,7 +85,6 @@ public:
QAccessibleInterface *child(int index) const;
int childCount() const;
int childAt(int x, int y) const;
QRect rect(int child) const;
QString text(Text t, int child) const;

View File

@ -231,24 +231,14 @@ int QAccessibleWidget::childAt(int x, int y) const
if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
return -1;
QWidgetList list = childWidgets(w);
int ccount = childCount();
// a complex child
if (list.size() < ccount) {
for (int i = 1; i <= ccount; ++i) {
if (rect(i).contains(x, y))
return i;
}
return 0;
}
QPoint rp = w->mapFromGlobal(QPoint(x, y));
for (int i = 0; i<list.size(); ++i) {
QWidget *child = list.at(i);
if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
for (int i = 0; i < childCount(); ++i) {
QAccessibleInterface *childIface = child(i);
bool found = false;
if (childIface->rect().contains(x, y))
found = true;
delete childIface;
if (found)
return i + 1;
}
}
return 0;
}