Changeset 64477 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Oct 28, 2016 3:57:24 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeView.cpp
r64473 r64477 21 21 22 22 /* Qt includes: */ 23 # include <QAccessibleWidget> 23 24 # include <QMouseEvent> 24 25 # include <QPainter> … … 27 28 # include "QITreeView.h" 28 29 30 /* Other VBox includes: */ 31 # include "iprt/assert.h" 32 29 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 35 36 /** QAccessibleWidget extension used as an accessibility interface for QITreeView. */ 37 class QIAccessibilityInterfaceForQITreeView : public QAccessibleWidget 38 { 39 public: 40 41 /** Returns an accessibility interface for passed @a strClassname and @a pObject. */ 42 static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject) 43 { 44 /* Creating QITreeView accessibility interface: */ 45 if (pObject && strClassname == QLatin1String("QITreeView")) 46 return new QIAccessibilityInterfaceForQITreeView(qobject_cast<QWidget*>(pObject)); 47 48 /* Null by default: */ 49 return 0; 50 } 51 52 /** Constructs an accessibility interface passing @a pWidget to the base-class. */ 53 QIAccessibilityInterfaceForQITreeView(QWidget *pWidget) 54 : QAccessibleWidget(pWidget, QAccessible::List) 55 {} 56 57 /** Returns the number of children. */ 58 virtual int childCount() const /* override */; 59 /** Returns the child with the passed @a iIndex. */ 60 virtual QAccessibleInterface *child(int iIndex) const /* override */; 61 /** Returns the index of the passed @a pChild. */ 62 virtual int indexOfChild(const QAccessibleInterface *pChild) const /* override */; 63 64 /** Returns a text for the passed @a enmTextRole. */ 65 virtual QString text(QAccessible::Text enmTextRole) const /* override */; 66 67 private: 68 69 /** Returns corresponding QITreeView. */ 70 QITreeView *tree() const { return qobject_cast<QITreeView*>(widget()); } 71 }; 72 73 74 /********************************************************************************************************************************* 75 * Class QIAccessibilityInterfaceForQITreeView implementation. * 76 *********************************************************************************************************************************/ 77 78 int QIAccessibilityInterfaceForQITreeView::childCount() const 79 { 80 /* Make sure tree still alive: */ 81 AssertPtrReturn(tree(), 0); 82 83 /* Return the number of children: */ 84 return tree()->childCount(); 85 } 86 87 QAccessibleInterface *QIAccessibilityInterfaceForQITreeView::child(int iIndex) const 88 { 89 /* Make sure tree still alive: */ 90 AssertPtrReturn(tree(), 0); 91 /* Make sure index is valid: */ 92 AssertReturn(iIndex >= 0 && iIndex < childCount(), 0); 93 94 /* Return the child with the passed iIndex: */ 95 return QAccessible::queryAccessibleInterface(tree()->childItem(iIndex)); 96 } 97 98 int QIAccessibilityInterfaceForQITreeView::indexOfChild(const QAccessibleInterface *pChild) const 99 { 100 /* Search for corresponding child: */ 101 for (int i = 0; i < childCount(); ++i) 102 if (child(i) == pChild) 103 return i; 104 105 /* -1 by default: */ 106 return -1; 107 } 108 109 QString QIAccessibilityInterfaceForQITreeView::text(QAccessible::Text /* enmTextRole */) const 110 { 111 /* Make sure tree still alive: */ 112 AssertPtrReturn(tree(), QString()); 113 114 /* Return tree whats-this: */ 115 return tree()->whatsThis(); 116 } 30 117 31 118 … … 140 227 void QITreeView::prepare() 141 228 { 229 /* Install QITreeView accessibility interface factory: */ 230 QAccessible::installFactory(QIAccessibilityInterfaceForQITreeView::pFactory); 231 142 232 /* Mark header hidden: */ 143 233 setHeaderHidden(true);
Note:
See TracChangeset
for help on using the changeset viewer.