- Timestamp:
- Nov 2, 2016 3:54:12 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIComboBox.cpp
r64521 r64522 21 21 22 22 /* Qt includes: */ 23 # include <QAccessibleWidget> 23 24 # include <QHBoxLayout> 24 25 # include <QLineEdit> … … 32 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 34 35 36 /** QAccessibleWidget extension used as an accessibility interface for QIComboBox. */ 37 class QIAccessibilityInterfaceForQIComboBox : 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 QIComboBox accessibility interface: */ 45 if (pObject && strClassname == QLatin1String("QIComboBox")) 46 return new QIAccessibilityInterfaceForQIComboBox(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 QIAccessibilityInterfaceForQIComboBox(QWidget *pWidget) 54 : QAccessibleWidget(pWidget, QAccessible::ToolBar) 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 QIComboBox. */ 70 QIComboBox *combo() const { return qobject_cast<QIComboBox*>(widget()); } 71 }; 72 73 74 /********************************************************************************************************************************* 75 * Class QIAccessibilityInterfaceForQIComboBox implementation. * 76 *********************************************************************************************************************************/ 77 78 int QIAccessibilityInterfaceForQIComboBox::childCount() const 79 { 80 /* Make sure combo still alive: */ 81 AssertPtrReturn(combo(), 0); 82 83 /* Return the number of children: */ 84 return combo()->subElementCount(); 85 } 86 87 QAccessibleInterface *QIAccessibilityInterfaceForQIComboBox::child(int iIndex) const 88 { 89 /* Make sure combo still alive: */ 90 AssertPtrReturn(combo(), 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(combo()->subElement(iIndex)); 96 } 97 98 int QIAccessibilityInterfaceForQIComboBox::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 QIAccessibilityInterfaceForQIComboBox::text(QAccessible::Text /* enmTextRole */) const 110 { 111 /* Return empty string: */ 112 return QString(); 113 } 114 115 116 /********************************************************************************************************************************* 117 * Class QIComboBox implementation. * 118 *********************************************************************************************************************************/ 34 119 35 120 QIComboBox::QIComboBox(QWidget *pParent /* = 0 */) … … 204 289 void QIComboBox::prepare() 205 290 { 291 /* Install QIComboBox accessibility interface factory: */ 292 QAccessible::installFactory(QIAccessibilityInterfaceForQIComboBox::pFactory); 293 206 294 /* Create layout: */ 207 295 QHBoxLayout *pLayout = new QHBoxLayout(this);
Note:
See TracChangeset
for help on using the changeset viewer.

