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

