VirtualBox

Ignore:
Timestamp:
Dec 1, 2016 3:34:45 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 144): Improving QITreeViewItem model-index calculation algorithm by taking sort-filter-proxy models into account.

File:
1 edited

Legend:

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

    r64742 r64774  
    321321QModelIndex QITreeViewItem::modelIndex() const
    322322{
     323    /* Check whether we have proxy model set or source one otherwise: */
     324    QSortFilterProxyModel *pProxyModel = qobject_cast<QSortFilterProxyModel*>(parentTree()->model());
     325
     326    /* Determine proxy and source root model-indexes, they can be equal: */
     327    const QModelIndex rootInProxy = parentTree()->rootIndex();
     328    const QModelIndex rootInSource = pProxyModel ? pProxyModel->mapToSource(rootInProxy) : rootInProxy;
     329
    323330    /* Make sure it's not root model-index: */
    324     if (   parentTree()->rootIndex().internalPointer()
    325         && parentTree()->rootIndex().internalPointer() == this)
    326         return parentTree()->rootIndex();
     331    if (   rootInSource.internalPointer()
     332        && rootInSource.internalPointer() == this)
     333        return rootInProxy;
    327334
    328335    /* Determine our index inside parent: */
     
    350357
    351358    /* Get parent model-index: */
    352     QModelIndex parentModelIndex = parentItem() ? parentItem()->modelIndex() : parentTree()->rootIndex();
     359    QModelIndex parentModelIndex = parentItem() ? parentItem()->modelIndex() : rootInProxy;
    353360
    354361    /* Return model-index as child of parent model-index: */
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