Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
bool QAccessibleTree::isRowSelected(int row) const
{
    if (!view()->selectionModel())
        return false;
    QModelIndex index = indexFromLogical(row);
    return view()->selectionModel()->isRowSelected(index.row(), index.parent());
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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());
}
Esempio n. 7
0
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());
}
Esempio n. 8
0
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;
}