summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2012-07-25 15:22:26 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-07-30 17:56:38 (GMT)
commit2846f98c47b395cb3e847cd3b711c849242111cc (patch)
tree8bdfe7d62054e8f248262ce1e8b13ecd1561d4a4 /src
parent112c6609c0ffff20cea598a78ece549e676fbc95 (diff)
downloadQt-2846f98c47b395cb3e847cd3b711c849242111cc.zip
Qt-2846f98c47b395cb3e847cd3b711c849242111cc.tar.gz
Qt-2846f98c47b395cb3e847cd3b711c849242111cc.tar.bz2
Accessibility: fix updates for models with rootIndex set.
The accessible table/list implementation would ignore when a root index is set, resulting in trying to use row/column for the top level index, leading to accessing invalid indexes. Change-Id: I2568522053bafe48458446dd2f47b68d98d634aa Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/accessible/widgets/itemviews.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/plugins/accessible/widgets/itemviews.cpp b/src/plugins/accessible/widgets/itemviews.cpp
index c2e1c52..5850d02 100644
--- a/src/plugins/accessible/widgets/itemviews.cpp
+++ b/src/plugins/accessible/widgets/itemviews.cpp
@@ -111,7 +111,13 @@ QAccessibleInterface *QAccessibleTable2::childFromLogical(int logicalIndex) cons
}
--row;
}
- return new QAccessibleTable2Cell(view(), view()->model()->index(row, column), cellRole());
+
+ QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
+ if (!index.isValid()) {
+ qWarning() << "QAccessibleTable2::childFromLogical: Invalid index at: " << row << column;
+ return 0;
+ }
+ return new QAccessibleTable2Cell(view(), index, cellRole());
}
QAccessibleTable2::QAccessibleTable2(QWidget *w)
@@ -230,7 +236,7 @@ QAccessibleTable2Cell *QAccessibleTable2::cell(const QModelIndex &index) const
QAccessibleTable2CellInterface *QAccessibleTable2::cellAt(int row, int column) const
{
Q_ASSERT(role(0) != QAccessible::Tree);
- QModelIndex index = view()->model()->index(row, column);
+ QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
//Q_ASSERT(index.isValid());
if (!index.isValid()) {
qWarning() << "QAccessibleTable2::cellAt: invalid index: " << index << " for " << view();
@@ -323,7 +329,7 @@ bool QAccessibleTable2::isRowSelected(int row) const
bool QAccessibleTable2::selectRow(int row)
{
- QModelIndex index = view()->model()->index(row, 0);
+ QModelIndex index = view()->model()->index(row, 0, view()->rootIndex());
if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection)
return false;
view()->selectionModel()->select(index, QItemSelectionModel::Select);
@@ -332,7 +338,7 @@ bool QAccessibleTable2::selectRow(int row)
bool QAccessibleTable2::selectColumn(int column)
{
- QModelIndex index = view()->model()->index(0, column);
+ QModelIndex index = view()->model()->index(0, column, view()->rootIndex());
if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection)
return false;
view()->selectionModel()->select(index, QItemSelectionModel::Select);
@@ -341,7 +347,7 @@ bool QAccessibleTable2::selectColumn(int column)
bool QAccessibleTable2::unselectRow(int row)
{
- QModelIndex index = view()->model()->index(row, 0);
+ QModelIndex index = view()->model()->index(row, 0, view()->rootIndex());
if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection)
return false;
view()->selectionModel()->select(index, QItemSelectionModel::Deselect);
@@ -350,7 +356,7 @@ bool QAccessibleTable2::unselectRow(int row)
bool QAccessibleTable2::unselectColumn(int column)
{
- QModelIndex index = view()->model()->index(0, column);
+ QModelIndex index = view()->model()->index(0, column, view()->rootIndex());
if (!index.isValid() || view()->selectionMode() & QAbstractItemView::NoSelection)
return false;
view()->selectionModel()->select(index, QItemSelectionModel::Columns & QItemSelectionModel::Deselect);