Changeset 63896 in vbox
- Timestamp:
- Sep 19, 2016 4:26:16 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110770
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r63895 r63896 21 21 22 22 /* Qt includes: */ 23 # include <QAccessibleWidget> 23 24 # include <QApplication> 24 25 # include <QDateTime> … … 54 55 55 56 57 /** QAccessibleWidget extension used as an accessibility interface for Snapshot tree. */ 58 class UIAccessibilityInterfaceForUISnapshotTree : public QAccessibleWidget 59 { 60 public: 61 62 /** Returns an accessibility interface for passed @a strClassname and @a pObject. */ 63 static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject) 64 { 65 /* Creating Snapshot tree accessibility interface: */ 66 if (pObject && strClassname == QLatin1String("UISnapshotTree")) 67 return new UIAccessibilityInterfaceForUISnapshotTree(qobject_cast<QWidget*>(pObject)); 68 69 /* Null by default: */ 70 return 0; 71 } 72 73 /** Constructs an accessibility interface passing @a pWidget to the base-class. */ 74 UIAccessibilityInterfaceForUISnapshotTree(QWidget *pWidget) 75 : QAccessibleWidget(pWidget, QAccessible::List) 76 {} 77 78 /** Returns the number of children. */ 79 virtual int childCount() const /* override */; 80 /** Returns the child with the passed @a iIndex. */ 81 virtual QAccessibleInterface *child(int iIndex) const /* override */; 82 83 /** Returns a text for the passed @a enmTextRole. */ 84 virtual QString text(QAccessible::Text enmTextRole) const /* override */; 85 86 private: 87 88 /** Returns corresponding Snapshot tree. */ 89 UISnapshotTree *tree() const { return qobject_cast<UISnapshotTree*>(widget()); } 90 }; 91 92 56 93 /** QTreeWidgetItem subclass for snapshots items. */ 57 94 class UISnapshotItem : public QObject, public QTreeWidgetItem … … 175 212 UISnapshotItem *childSnapshotItem(int iIndex) const; 176 213 }; 214 215 216 /********************************************************************************************************************************* 217 * Class UIAccessibilityInterfaceForUISnapshotTree implementation. * 218 *********************************************************************************************************************************/ 219 220 int UIAccessibilityInterfaceForUISnapshotTree::childCount() const 221 { 222 /* Make sure tree still alive: */ 223 AssertPtrReturn(tree(), 0); 224 225 /* Return the number of children: */ 226 return tree()->childCount(); 227 } 228 229 QAccessibleInterface *UIAccessibilityInterfaceForUISnapshotTree::child(int iIndex) const 230 { 231 /* Make sure tree still alive: */ 232 AssertPtrReturn(tree(), 0); 233 /* Make sure index is valid: */ 234 // WORKAROUND: 235 // Usually I would assert here, but Qt5 accessibility code has 236 // a hard-coded architecture for a tree-views which we do not like 237 // but have to live with and this architecture enumerates children 238 // of all levels as children of level 0, so Qt5 can try to address 239 // our interface with index which surely out of bounds by our laws. 240 if (iIndex < 0 || iIndex >= childCount()) 241 return 0; 242 243 /* Return the child with the passed iIndex: */ 244 return QAccessible::queryAccessibleInterface(tree()->childSnapshotItem(iIndex)); 245 } 246 247 QString UIAccessibilityInterfaceForUISnapshotTree::text(QAccessible::Text /* enmTextRole */) const 248 { 249 /* Make sure tree still alive: */ 250 AssertPtrReturn(tree(), QString()); 251 252 /* Return tree tool-tip: */ 253 return tree()->toolTip(); 254 } 177 255 178 256 … … 505 583 : QTreeWidget(pParent) 506 584 { 585 /* Install Snapshot tree accessibility interface factory: */ 586 QAccessible::installFactory(UIAccessibilityInterfaceForUISnapshotTree::pFactory); 587 507 588 /* No header: */ 508 589 header()->hide();
Note:
See TracChangeset
for help on using the changeset viewer.