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
parent
5ea07a9cd1
commit
b67708f3d3
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue