VirtualBox

Changeset 64479 in vbox


Ignore:
Timestamp:
Oct 28, 2016 4:01:01 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111613
Message:

FE/Qt: bugref:6899: Accessibility support (step 108): Accessibility workaround cleanup for basic model/view classes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/extensions
Files:
5 edited

Legend:

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

    r64238 r64479  
    397397    AssertPtrReturn(table(), QString());
    398398
    399     /* Return tree whats-this: */
     399    /* Return table whats-this: */
    400400    return table()->whatsThis();
    401401}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITableView.h

    r64228 r64479  
    102102    virtual int childCount() const { return 0; }
    103103    /** Returns the child item with @a iIndex. */
    104     virtual QITableViewRow *childItem(int iIndex) const { Q_UNUSED(iIndex); return 0; }
     104    virtual QITableViewRow *childItem(int /* iIndex */) const { return 0; }
    105105
    106106    /** Makes sure current editor data committed. */
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeView.cpp

    r64478 r64479  
    231231    AssertPtrReturn(tree(), 0);
    232232    /* Make sure index is valid: */
    233     AssertReturn(iIndex >= 0 && iIndex < childCount(), 0);
     233    AssertReturn(iIndex >= 0, 0);
     234    if (iIndex >= childCount())
     235    {
     236        // WORKAROUND:
     237        // Normally I would assert here, but Qt5 accessibility code has
     238        // a hard-coded architecture for a tree-views which we do not like
     239        // but have to live with and this architecture enumerates children
     240        // of all levels as children of level 0, so Qt5 can try to address
     241        // our interface with index which surely out of bounds by our laws.
     242        // So let's assume that's exactly such case and try to enumerate
     243        // visible children like they are a part of the list, not tree.
     244        // printf("Invalid index: %d\n", iIndex);
     245
     246        // Take into account we also have header with 'column count' indexes,
     247        // so we should start enumerating tree indexes since 'column count'.
     248        const int iColumnCount = tree()->model()->columnCount();
     249        int iCurrentIndex = iColumnCount;
     250
     251        // Set iterator to root-index initially:
     252        const QModelIndex root = tree()->rootIndex();
     253        QModelIndex index = root;
     254
     255        // But if root-index has child, go deeper:
     256        if (index.child(0, 0).isValid())
     257            index = index.child(0, 0);
     258
     259        // Search for sibling with corresponding index:
     260        while (index.isValid() && iCurrentIndex < iIndex)
     261        {
     262            ++iCurrentIndex;
     263            if (iCurrentIndex % iColumnCount == 0)
     264                index = tree()->indexBelow(index);
     265        }
     266
     267        // Return what we found:
     268        // if (index.isValid())
     269        //     printf("Item found: [%s]\n", ((QITreeViewItem*)index.internalPointer())->text().toUtf8().constData());
     270        // else
     271        //     printf("Item not found\n");
     272        return index.isValid() ? QAccessible::queryAccessibleInterface((QITreeViewItem*)index.internalPointer()) : 0;
     273    }
    234274
    235275    /* Return the child with the passed iIndex: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.cpp

    r64308 r64479  
    261261        // WORKAROUND:
    262262        // Normally I would assert here, but Qt5 accessibility code has
    263         // a hard-coded architecture for a tree-views which we do not like
     263        // a hard-coded architecture for a tree-widgets which we do not like
    264264        // but have to live with and this architecture enumerates children
    265265        // of all levels as children of level 0, so Qt5 can try to address
     
    269269        // printf("Invalid index: %d\n", iIndex);
    270270
     271        // Take into account we also have header with 'column count' indexes,
     272        // so we should start enumerating tree indexes since 'column count'.
     273        const int iColumnCount = tree()->columnCount();
     274        int iCurrentIndex = iColumnCount;
     275
    271276        // Do some sanity check as well, enough?
    272         AssertReturn(iIndex >= tree()->columnCount(), 0);
    273 
    274         // The enumeration step is column count:
    275         int iCurrentIndex = tree()->columnCount();
     277        AssertReturn(iIndex >= iColumnCount, 0);
     278
     279        // Search for sibling with corresponding index:
    276280        QTreeWidgetItem *pItem = tree()->topLevelItem(0);
    277281        while (pItem && iCurrentIndex < iIndex)
    278282        {
    279283            ++iCurrentIndex;
    280             if (iCurrentIndex % tree()->columnCount() == 0)
     284            if (iCurrentIndex % iColumnCount == 0)
    281285                pItem = tree()->itemBelow(pItem);
    282286        }
     
    284288        // Return what we found:
    285289        // if (pItem)
    286         //     printf("Item found: [%s]\n", pItem->defaultText().toUtf8().constData());
     290        //     printf("Item found: [%s]\n", pItem->text(0).toUtf8().constData());
     291        // else
     292        //     printf("Item not found\n");
    287293        return pItem ? QAccessible::queryAccessibleInterface(QITreeWidgetItem::toItem(pItem)) : 0;
    288294    }
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.h

    r64302 r64479  
    5959    /** Returns the parent tree-widget item. */
    6060    QITreeWidgetItem *parentItem() const;
     61
    6162    /** Returns the child tree-widget item with @a iIndex. */
    6263    QITreeWidgetItem *childItem(int iIndex) const;
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