Changeset 64231 in vbox
- Timestamp:
- Oct 12, 2016 6:02:13 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 111240
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITableView.cpp
r64230 r64231 33 33 34 34 35 /** QAccessibleObject extension used as an accessibility interface for QITableViewCell. */ 36 class QIAccessibilityInterfaceForQITableViewCell : public QAccessibleObject 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 QITableViewCell accessibility interface: */ 44 if (pObject && strClassname == QLatin1String("QITableViewCell")) 45 return new QIAccessibilityInterfaceForQITableViewCell(pObject); 46 47 /* Null by default: */ 48 return 0; 49 } 50 51 /** Constructs an accessibility interface passing @a pObject to the base-class. */ 52 QIAccessibilityInterfaceForQITableViewCell(QObject *pObject) 53 : QAccessibleObject(pObject) 54 {} 55 56 /** Returns the parent. */ 57 virtual QAccessibleInterface *parent() const /* override */; 58 59 /** Returns the number of children. */ 60 virtual int childCount() const /* override */ { return 0; } 61 /** Returns the child with the passed @a iIndex. */ 62 virtual QAccessibleInterface *child(int iIndex) const /* override */ { return 0; } 63 /** Returns the index of the passed @a pChild. */ 64 virtual int indexOfChild(const QAccessibleInterface *pChild) const /* override */ { return -1; } 65 66 /** Returns the rect. */ 67 virtual QRect rect() const /* override */; 68 /** Returns a text for the passed @a enmTextRole. */ 69 virtual QString text(QAccessible::Text enmTextRole) const /* override */; 70 71 /** Returns the role. */ 72 virtual QAccessible::Role role() const /* override */; 73 /** Returns the state. */ 74 virtual QAccessible::State state() const /* override */; 75 76 private: 77 78 /** Returns corresponding QITableViewCell. */ 79 QITableViewCell *cell() const { return qobject_cast<QITableViewCell*>(object()); } 80 }; 81 82 35 83 /** QAccessibleObject extension used as an accessibility interface for QITableViewRow. */ 36 84 class QIAccessibilityInterfaceForQITableViewRow : public QAccessibleObject … … 117 165 QITableView *table() const { return qobject_cast<QITableView*>(widget()); } 118 166 }; 167 168 169 /********************************************************************************************************************************* 170 * Class QIAccessibilityInterfaceForQITableViewCell implementation. * 171 *********************************************************************************************************************************/ 172 173 QAccessibleInterface *QIAccessibilityInterfaceForQITableViewCell::parent() const 174 { 175 /* Make sure cell still alive: */ 176 AssertPtrReturn(cell(), 0); 177 178 /* Return the parent: */ 179 return QAccessible::queryAccessibleInterface(cell()->row()); 180 } 181 182 QRect QIAccessibilityInterfaceForQITableViewCell::rect() const 183 { 184 /* Make sure cell still alive: */ 185 AssertPtrReturn(cell(), QRect()); 186 AssertPtrReturn(cell()->row(), QRect()); 187 AssertPtrReturn(cell()->row()->table(), QRect()); 188 189 /* Calculate local item coordinates: */ 190 const int iIndexInParent = parent()->indexOfChild(this); 191 const int iParentIndexInParent = parent()->parent()->indexOfChild(parent()); 192 const int iX = cell()->row()->table()->columnViewportPosition(iIndexInParent); 193 const int iY = cell()->row()->table()->rowViewportPosition(iParentIndexInParent); 194 const int iWidth = cell()->row()->table()->columnWidth(iIndexInParent); 195 const int iHeight = cell()->row()->table()->rowHeight(iParentIndexInParent); 196 197 /* Map local item coordinates to global: */ 198 const QPoint itemPosInScreen = cell()->row()->table()->viewport()->mapToGlobal(QPoint(iX, iY)); 199 200 /* Return item rectangle: */ 201 return QRect(itemPosInScreen, QSize(iWidth, iHeight)); 202 } 203 204 QString QIAccessibilityInterfaceForQITableViewCell::text(QAccessible::Text enmTextRole) const 205 { 206 /* Make sure cell still alive: */ 207 AssertPtrReturn(cell(), QString()); 208 209 /* Return a text for the passed enmTextRole: */ 210 switch (enmTextRole) 211 { 212 case QAccessible::Name: return cell()->text(); 213 default: break; 214 } 215 216 /* Null-string by default: */ 217 return QString(); 218 } 219 220 QAccessible::Role QIAccessibilityInterfaceForQITableViewCell::role() const 221 { 222 /* Cell by default: */ 223 return QAccessible::Cell; 224 } 225 226 QAccessible::State QIAccessibilityInterfaceForQITableViewCell::state() const 227 { 228 /* Make sure cell still alive: */ 229 AssertPtrReturn(cell(), QAccessible::State()); 230 231 /* Empty state by default: */ 232 return QAccessible::State(); 233 } 119 234 120 235 … … 316 431 void QITableView::prepare() 317 432 { 433 /* Install QITableViewCell accessibility interface factory: */ 434 QAccessible::installFactory(QIAccessibilityInterfaceForQITableViewCell::pFactory); 318 435 /* Install QITableViewRow accessibility interface factory: */ 319 436 QAccessible::installFactory(QIAccessibilityInterfaceForQITableViewRow::pFactory);
Note:
See TracChangeset
for help on using the changeset viewer.