VirtualBox

Changeset 63729 in vbox


Ignore:
Timestamp:
Sep 5, 2016 4:33:44 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 12): Selector UI: Basic Details-view accessibility interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsView.cpp

    r63726 r63729  
    2121
    2222/* Qt includes: */
     23# include <QAccessibleWidget>
    2324# include <QApplication>
    2425# include <QScrollBar>
     
    2627/* GUI includes: */
    2728# include "UIGDetails.h"
     29# include "UIGDetailsModel.h"
    2830# include "UIGDetailsView.h"
     31# include "UIGDetailsItem.h"
     32
     33/* Other VBox includes: */
     34# include <iprt/assert.h>
    2935
    3036#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     37
     38
     39/** QAccessibleWidget extension used as an accessibility interface for Details-view. */
     40class UIAccessibilityInterfaceForUIGDetailsView : public QAccessibleWidget
     41{
     42public:
     43
     44    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     45    static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
     46    {
     47        /* Creating Details-view accessibility interface: */
     48        if (pObject && strClassname == QLatin1String("UIGDetailsView"))
     49            return new UIAccessibilityInterfaceForUIGDetailsView(qobject_cast<QWidget*>(pObject));
     50
     51        /* Null by default: */
     52        return 0;
     53    }
     54
     55    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     56    UIAccessibilityInterfaceForUIGDetailsView(QWidget *pWidget)
     57        : QAccessibleWidget(pWidget, QAccessible::List)
     58    {}
     59
     60    /** Returns the number of children. */
     61    virtual int childCount() const /* override */
     62    {
     63        /* Make sure view still alive: */
     64        AssertPtrReturn(view(), 0);
     65
     66        /* What amount of children root has? */
     67        const int cChildCount = view()->details()->model()->root()->items().size();
     68
     69        /* Return amount of children root has (if there are many of children): */
     70        if (cChildCount > 1)
     71            return cChildCount;
     72
     73        /* Return the number of children lone root child has (otherwise): */
     74        return view()->details()->model()->root()->items().first()->items().size();
     75    }
     76
     77    /** Returns the child with the passed @a iIndex. */
     78    virtual QAccessibleInterface *child(int iIndex) const /* override */
     79    {
     80        /* Make sure view still alive: */
     81        AssertPtrReturn(view(), 0);
     82        /* Make sure index is valid: */
     83        AssertReturn(iIndex >= 0 && iIndex < childCount(), 0);
     84
     85        /* What amount of children root has? */
     86        const int cChildCount = view()->details()->model()->root()->items().size();
     87
     88        /* Return the root child with the passed iIndex (if there are many of children): */
     89        if (cChildCount > 1)
     90            return QAccessible::queryAccessibleInterface(view()->details()->model()->root()->items().at(iIndex));
     91
     92        /* Return the lone root child's child with the passed iIndex (otherwise): */
     93        return QAccessible::queryAccessibleInterface(view()->details()->model()->root()->items().first()->items().at(iIndex));
     94    }
     95
     96    /** Returns a text for the passed @a enmTextRole. */
     97    virtual QString text(QAccessible::Text enmTextRole) const /* override */
     98    {
     99        /* Make sure view still alive: */
     100        AssertPtrReturn(view(), QString());
     101
     102        /* Return view tool-tip: */
     103        Q_UNUSED(enmTextRole);
     104        return view()->toolTip();
     105    }
     106
     107private:
     108
     109    /** Returns corresponding Details-view. */
     110    UIGDetailsView *view() const { return qobject_cast<UIGDetailsView*>(widget()); }
     111};
    31112
    32113
     
    37118    , m_iMinimumHeightHint(0)
    38119{
     120    /* Install Details-view accessibility interface factory: */
     121    QAccessible::installFactory(UIAccessibilityInterfaceForUIGDetailsView::pFactory);
     122
    39123    /* Prepare palette: */
    40124    preparePalette();
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