VirtualBox

Changeset 64126 in vbox for trunk/src


Ignore:
Timestamp:
Oct 3, 2016 3:38:04 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 67): Extend QITreeWidget with QITreeWidgetItem interface required to make this widget accessible.

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

Legend:

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

    r64125 r64126  
    3030
    3131
     32/*********************************************************************************************************************************
     33*   Class QITreeWidgetItem implementation.                                                                                       *
     34*********************************************************************************************************************************/
     35
     36/* static */
     37QITreeWidgetItem *QITreeWidgetItem::toItem(QTreeWidgetItem *pItem)
     38{
     39    /* Make sure alive QITreeWidgetItem passed: */
     40    if (!pItem || pItem->type() != QITreeWidgetItem::ItemType)
     41        return 0;
     42
     43    /* Return casted QITreeWidgetItem: */
     44    return static_cast<QITreeWidgetItem*>(pItem);
     45}
     46
     47/* static */
     48const QITreeWidgetItem *QITreeWidgetItem::toItem(const QTreeWidgetItem *pItem)
     49{
     50    /* Make sure alive QITreeWidgetItem passed: */
     51    if (!pItem || pItem->type() != QITreeWidgetItem::ItemType)
     52        return 0;
     53
     54    /* Return casted QITreeWidgetItem: */
     55    return static_cast<const QITreeWidgetItem*>(pItem);
     56}
     57
     58QITreeWidgetItem::QITreeWidgetItem(QITreeWidget *pTreeWidget)
     59    : QTreeWidgetItem(pTreeWidget, ItemType)
     60{
     61}
     62
     63QITreeWidgetItem::QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem)
     64    : QTreeWidgetItem(pTreeWidgetItem, ItemType)
     65{
     66}
     67
     68QITreeWidgetItem::QITreeWidgetItem(QITreeWidget *pTreeWidget, const QStringList &strings)
     69    : QTreeWidgetItem(pTreeWidget, strings, ItemType)
     70{
     71}
     72
     73QITreeWidgetItem::QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem, const QStringList &strings)
     74    : QTreeWidgetItem(pTreeWidgetItem, strings, ItemType)
     75{
     76}
     77
     78QITreeWidget *QITreeWidgetItem::parentTree() const
     79{
     80    /* Return the parent tree if any: */
     81    return treeWidget() ? qobject_cast<QITreeWidget*>(treeWidget()) : 0;
     82}
     83
     84QITreeWidgetItem *QITreeWidgetItem::parentItem() const
     85{
     86    /* Return the parent item if any: */
     87    return QTreeWidgetItem::parent() ? toItem(QTreeWidgetItem::parent()) : 0;
     88}
     89
     90QITreeWidgetItem *QITreeWidgetItem::childItem(int iIndex) const
     91{
     92    /* Return the child item with iIndex if any: */
     93    return QTreeWidgetItem::child(iIndex) ? toItem(QTreeWidgetItem::child(iIndex)) : 0;
     94}
     95
     96
     97/*********************************************************************************************************************************
     98*   Class QITreeWidget implementation.                                                                                           *
     99*********************************************************************************************************************************/
     100
    32101QITreeWidget::QITreeWidget(QWidget *pParent)
    33102    : QTreeWidget(pParent)
     
    48117}
    49118
    50 QTreeWidgetItem *QITreeWidget::childItem(int iIndex) const
     119QITreeWidgetItem *QITreeWidget::childItem(int iIndex) const
    51120{
    52121    /* Return the child item with iIndex if any: */
    53     return invisibleRootItem()->child(iIndex);
     122    return invisibleRootItem()->child(iIndex) ? QITreeWidgetItem::toItem(invisibleRootItem()->child(iIndex)) : 0;
    54123}
    55124
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.h

    r64125 r64126  
    2121/* Qt includes: */
    2222#include <QTreeWidget>
     23#include <QTreeWidgetItem>
     24
     25/* Forward declarations: */
     26class QITreeWidget;
     27
     28
     29/** QTreeWidgetItem subclass extending standard functionality. */
     30class QITreeWidgetItem : public QObject, public QTreeWidgetItem
     31{
     32    Q_OBJECT;
     33
     34public:
     35
     36    /** Item type for QITreeWidgetItem. */
     37    enum { ItemType = QTreeWidgetItem::UserType + 1 };
     38
     39    /** Casts QTreeWidgetItem* to QITreeWidgetItem* if possible. */
     40    static QITreeWidgetItem *toItem(QTreeWidgetItem *pItem);
     41    /** Casts const QTreeWidgetItem* to const QITreeWidgetItem* if possible. */
     42    static const QITreeWidgetItem *toItem(const QTreeWidgetItem *pItem);
     43
     44    /** Constructs item passing @a pTreeWidget into the base-class. */
     45    QITreeWidgetItem(QITreeWidget *pTreeWidget);
     46    /** Constructs item passing @a pTreeWidgetItem into the base-class. */
     47    QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem);
     48
     49    /** Constructs item passing @a pTreeWidget and @a strings into the base-class. */
     50    QITreeWidgetItem(QITreeWidget *pTreeWidget, const QStringList &strings);
     51    /** Constructs item passing @a pTreeWidgetItem and @a strings into the base-class. */
     52    QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem, const QStringList &strings);
     53
     54    /** Returns the parent tree-widget. */
     55    QITreeWidget *parentTree() const;
     56    /** Returns the parent tree-widget item. */
     57    QITreeWidgetItem *parentItem() const;
     58    /** Returns the child tree-widget item with @a iIndex. */
     59    QITreeWidgetItem *childItem(int iIndex) const;
     60};
    2361
    2462
     
    4684    int childCount() const;
    4785    /** Returns the child item with @a iIndex. */
    48     QTreeWidgetItem *childItem(int iIndex) const;
     86    QITreeWidgetItem *childItem(int iIndex) const;
    4987
    5088protected:
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