bool QAccessibleTree::selectRow(int row) { if (!view()->selectionModel()) return false; QModelIndex index = indexFromLogical(row); if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns) return false; switch (view()->selectionMode()) { case QAbstractItemView::NoSelection: return false; case QAbstractItemView::SingleSelection: if ((view()->selectionBehavior() != QAbstractItemView::SelectRows) && (columnCount() > 1)) return false; view()->clearSelection(); break; case QAbstractItemView::ContiguousSelection: if ((!row || !view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex())) && !view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex())) view()->clearSelection(); break; default: break; } view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); return true; }
QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const { if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount()) return 0; QAccessibleInterface *iface = 0; int index = logicalIndex; if (horizontalHeader()) { if (index < view()->model()->columnCount()) { iface = new QAccessibleTableHeaderCell(view(), index, Qt::Horizontal); } else { index -= view()->model()->columnCount(); } } if (!iface) { int row = index / view()->model()->columnCount(); int column = index % view()->model()->columnCount(); QModelIndex modelIndex = indexFromLogical(row, column); if (!modelIndex.isValid()) return 0; iface = new QAccessibleTableCell(view(), modelIndex, cellRole()); } QAccessible::registerAccessibleInterface(iface); // ### FIXME: get interfaces from the cache instead of re-creating them return iface; }
bool QAccessibleTree::isRowSelected(int row) const { if (!view()->selectionModel()) return false; QModelIndex index = indexFromLogical(row); return view()->selectionModel()->isRowSelected(index.row(), index.parent()); }
int QAccessibleTree::navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const { switch (relation) { case QAccessible::Child: { Q_ASSERT(index > 0); --index; int hHeader = horizontalHeader() ? 1 : 0; if (hHeader) { if (index < view->model()->columnCount()) { *iface = new QAccessibleTable2HeaderCell(view, index, Qt::Horizontal); return 0; } else { index -= view->model()->columnCount(); } } int row = index / view->model()->columnCount(); int column = index % view->model()->columnCount(); QModelIndex modelIndex = indexFromLogical(row, column); if (modelIndex.isValid()) { *iface = cell(modelIndex); return 0; } return -1; } default: break; } return QAccessibleTable2::navigate(relation, index, iface); }
bool QAccessibleTree::selectRow(int row) { QModelIndex index = indexFromLogical(row); if (!index.isValid() || view->selectionMode() & QAbstractItemView::NoSelection) return false; view->selectionModel()->select(index, QItemSelectionModel::Select); return true; }
QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const { QModelIndex index = indexFromLogical(row, column); if (!index.isValid()) { qWarning() << "Requested invalid tree cell: " << row << column; return 0; } return new QAccessibleTableCell(view, index, cellRole()); }
QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const { QModelIndex index = indexFromLogical(row, column); if (!index.isValid()) { qWarning() << "Requested invalid tree cell: " << row << column; return 0; } const QTreeView *treeView = qobject_cast<const QTreeView*>(view()); Q_ASSERT(treeView); int logicalIndex = treeView->d_func()->accessibleTable2Index(index); return child(logicalIndex); // FIXME ### new QAccessibleTableCell(view(), index, cellRole()); }
QAccessibleInterface *QAccessibleTree::child(int index) const { Q_ASSERT(index >= 0); int hHeader = horizontalHeader() ? 1 : 0; if (hHeader) { if (index < view->model()->columnCount()) { return new QAccessibleTableHeaderCell(view, index, Qt::Horizontal); } else { index -= view->model()->columnCount(); } } int row = index / view->model()->columnCount(); int column = index % view->model()->columnCount(); QModelIndex modelIndex = indexFromLogical(row, column); if (modelIndex.isValid()) { return cell(modelIndex); } return 0; }