Changeset 105063 in vbox
- Timestamp:
- Jun 27, 2024 2:04:43 PM (5 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITableView.cpp
r103987 r105063 28 28 /* Qt includes: */ 29 29 #include <QAccessibleWidget> 30 #include <QSortFilterProxyModel> 30 31 31 32 /* GUI includes: */ … … 260 261 } 261 262 262 QAccessibleInterface *QIAccessibilityInterfaceForQITableViewRow::child(int iIndex) const /* override */263 QAccessibleInterface *QIAccessibilityInterfaceForQITableViewRow::child(int iIndex) const 263 264 { 264 265 /* Make sure row still alive: */ … … 271 272 } 272 273 273 int QIAccessibilityInterfaceForQITableViewRow::indexOfChild(const QAccessibleInterface *pChild) const /* override */274 int QIAccessibilityInterfaceForQITableViewRow::indexOfChild(const QAccessibleInterface *pChild) const 274 275 { 275 276 /* Search for corresponding child: */ … … 345 346 /* Make sure table still alive: */ 346 347 AssertPtrReturn(table(), 0); 348 /* Make sure model still alive: */ 349 AssertPtrReturn(table()->model(), 0); 347 350 348 351 /* Return the number of children: */ 349 return table()-> childCount();352 return table()->model()->rowCount(); 350 353 } 351 354 … … 353 356 { 354 357 /* Make sure table still alive: */ 355 AssertPtrReturn(table(), 0); 358 QITableView *pTable = table(); 359 AssertPtrReturn(pTable, 0); 360 /* Make sure model still alive: */ 361 QAbstractItemModel *pModel = pTable->model(); 362 AssertPtrReturn(pModel, 0); 356 363 /* Make sure index is valid: */ 357 364 AssertReturn(iIndex >= 0, 0); 358 if (iIndex >= childCount()) 359 { 360 // WORKAROUND: 361 // Normally I would assert here, but Qt5 accessibility code has 362 // a hard-coded architecture for a table-views which we do not like 363 // but have to live with and this architecture enumerates cells 364 // including header column and row, so Qt5 can try to address 365 // our interface with index which surely out of bounds by our laws. 366 // So let's assume that's exactly such case and try to enumerate 367 // table cells including header column and row. 368 // printf("Invalid index: %d\n", iIndex); 369 365 366 /* Real index might be different: */ 367 int iRealRowIndex = iIndex; 368 369 // WORKAROUND: 370 // For a table-views Qt accessibility code has a hard-coded architecture which we do not like 371 // but have to live with, this architecture enumerates cells including header column and row, 372 // so Qt can try to address our interface with index which surely out of bounds by our laws. 373 // Let's assume that's exactly the case and try to enumerate cells including header column and row. 374 if (iRealRowIndex >= childCount()) 375 { 370 376 // Split delimeter is overall column count, including vertical header: 371 const int iColumnCount = table()->model()->columnCount() + 1 /* v_header */;377 const int iColumnCount = pModel->columnCount() + 1 /* v_header */; 372 378 // Real index is zero-based, incoming is 1-based: 373 379 const int iRealIndex = iIndex - 1; 374 380 // Real row index, excluding horizontal header: 375 const int iRealRowIndex = iRealIndex / iColumnCount - 1 /* h_header */; 376 // printf("Actual row index: %d\n", iRealRowIndex); 377 378 // Return what we found: 379 return iRealRowIndex >= 0 && iRealRowIndex < childCount() ? 380 QAccessible::queryAccessibleInterface(table()->childItem(iRealRowIndex)) : 0; 381 } 382 383 /* Return the child with the passed iIndex: */ 384 return QAccessible::queryAccessibleInterface(table()->childItem(iIndex)); 381 iRealRowIndex = iRealIndex / iColumnCount - 1 /* h_header */; 382 // printf("Invalid index: %d, Actual index: %d\n", iIndex, iRealRowIndex); 383 } 384 385 /* Make sure index fits the bounds finally: */ 386 if (iRealRowIndex >= childCount()) 387 return 0; 388 389 /* Acquire child-index: */ 390 const QModelIndex childIndex = pModel->index(iRealRowIndex, 0); 391 /* Check whether we have proxy model set or source one otherwise: */ 392 const QSortFilterProxyModel *pProxyModel = qobject_cast<const QSortFilterProxyModel*>(pModel); 393 /* Acquire source-model child-index (can be the same as original if there is no proxy model): */ 394 const QModelIndex sourceChildIndex = pProxyModel ? pProxyModel->mapToSource(childIndex) : childIndex; 395 396 /* Acquire row item: */ 397 QITableViewRow *pRow = static_cast<QITableViewRow*>(sourceChildIndex.internalPointer()); 398 /* Return row's accessibility interface: */ 399 return QAccessible::queryAccessibleInterface(pRow); 385 400 } 386 401 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITableView.h
r104897 r105063 117 117 virtual ~QITableView() RT_OVERRIDE; 118 118 119 /** Returns the number of children. */120 virtual int childCount() const { return 0; }121 /** Returns the child item with @a iIndex. */122 virtual QITableViewRow *childItem(int /* iIndex */) const { return 0; }123 124 119 /** Makes sure current editor data committed. */ 125 120 void makeSureEditorDataCommitted();
Note:
See TracChangeset
for help on using the changeset viewer.