VirtualBox

Changeset 105540 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 30, 2024 11:41:25 AM (6 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10681: QITreeView: A bit of cleanup and polishing for accessibility interface; This is the subsequent step, s.a. r164182.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeView.cpp

    r105517 r105540  
    157157
    158158    /* Return the number of children: */
    159     return item()->parentTree()->model()->rowCount(itemIndex);;
     159    return item()->parentTree()->model()->rowCount(itemIndex);
    160160}
    161161
    162162QAccessibleInterface *QIAccessibilityInterfaceForQITreeViewItem::child(int iIndex) const /* override */
    163163{
    164     /* Sanity check: */
    165     AssertPtrReturn(item(), 0);
    166     AssertPtrReturn(item()->parentTree(), 0);
    167     AssertPtrReturn(item()->parentTree()->model(), 0);
     164    /* Make sure item still alive: */
     165    QITreeViewItem *pThisItem = item();
     166    AssertPtrReturn(pThisItem, 0);
     167    /* Make sure tree still alive: */
     168    QITreeView *pTree = pThisItem->parentTree();
     169    AssertPtrReturn(pTree, 0);
     170    /* Make sure model still alive: */
     171    QAbstractItemModel *pModel = pTree->model();
     172    AssertPtrReturn(pModel, 0);
     173    /* Make sure index is valid: */
    168174    AssertReturn(iIndex >= 0 && iIndex < childCount(), 0);
    169175
    170     /* Acquire item model-index: */
    171     const QModelIndex itemIndex = item()->modelIndex();
    172     /* Acquire child model-index: */
    173     const QModelIndex childIndex = item()->parentTree()->model()->index(iIndex, 0, itemIndex);
    174 
     176    /* Acquire parent model-index: */
     177    const QModelIndex parentIndex = pThisItem->modelIndex();
     178
     179    /* Acquire child-index: */
     180    const QModelIndex childIndex = pModel->index(iIndex, 0, parentIndex);
    175181    /* Check whether we have proxy model set or source one otherwise: */
    176     const QSortFilterProxyModel *pProxyModel = qobject_cast<const QSortFilterProxyModel*>(item()->parentTree()->model());
    177     /* Acquire source child model-index, which can be the same as child model-index: */
     182    const QSortFilterProxyModel *pProxyModel = qobject_cast<const QSortFilterProxyModel*>(pModel);
     183    /* Acquire source-model child-index (can be the same as original if there is no proxy model): */
    178184    const QModelIndex sourceChildIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex;
    179     /* Acquire source child item: */
     185
     186    /* Acquire child item: */
    180187    QITreeViewItem *pItem = reinterpret_cast<QITreeViewItem*>(sourceChildIndex.internalPointer());
    181     /* Return the child with the passed iIndex: */
     188    /* Return child item's accessibility interface: */
    182189    return QAccessible::queryAccessibleInterface(pItem);
    183190}
     
    281288QAccessibleInterface *QIAccessibilityInterfaceForQITreeView::child(int iIndex) const
    282289{
    283     /* Make sure table still alive: */
     290    /* Make sure tree still alive: */
    284291    QITreeView *pTree = tree();
    285292    AssertPtrReturn(pTree, 0);
     
    370377    const QModelIndex rootIndex = parentTree()->rootIndex();
    371378    /* Acquire source root model-index, which can be the same as root model-index: */
    372     const QModelIndex sourceRootModelIndex = pProxyModel ? pProxyModel->mapToSource(rootIndex) : rootIndex;
     379    const QModelIndex rootSourceModelIndex = pProxyModel ? pProxyModel->mapToSource(rootIndex) : rootIndex;
    373380
    374381    /* Check whether we have root model-index here: */
    375     if (   sourceRootModelIndex.internalPointer()
    376         && sourceRootModelIndex.internalPointer() == this)
     382    if (   rootSourceModelIndex.internalPointer()
     383        && rootSourceModelIndex.internalPointer() == this)
    377384        return rootIndex;
    378385
     
    387394        const QModelIndex childIndex = pModel->index(i, 0, parentIndex);
    388395        /* Acquire source child model-index, which can be the same as child model-index: */
    389         const QModelIndex sourceChildModelIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex;
     396        const QModelIndex childSourceModelIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex;
    390397
    391398        /* Check whether we have child model-index here: */
    392         if (   sourceChildModelIndex.internalPointer()
    393             && sourceChildModelIndex.internalPointer() == this)
     399        if (   childSourceModelIndex.internalPointer()
     400            && childSourceModelIndex.internalPointer() == this)
    394401        {
    395402            iPositionInParent = i;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette