MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / modelChange

Method modelChange

launcher/ui/instanceview/AccessibleInstanceView.cpp:467–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467void AccessibleInstanceView::modelChange(QAccessibleTableModelChangeEvent* event)
468{
469 // if there is no cache yet, we don't update anything
470 if (childToId.isEmpty())
471 return;
472
473 switch (event->modelChangeType()) {
474 case QAccessibleTableModelChangeEvent::ModelReset:
475 for (QAccessible::Id id : childToId)
476 QAccessible::deleteAccessibleInterface(id);
477 childToId.clear();
478 break;
479
480 // rows are inserted: move every row after that
481 case QAccessibleTableModelChangeEvent::RowsInserted:
482 case QAccessibleTableModelChangeEvent::ColumnsInserted: {
483 ChildCache newCache;
484 ChildCache::ConstIterator iter = childToId.constBegin();
485
486 while (iter != childToId.constEnd()) {
487 QAccessible::Id id = iter.value();
488 QAccessibleInterface* iface = QAccessible::accessibleInterface(id);
489 Q_ASSERT(iface);
490 if (indexOfChild(iface) >= 0) {
491 newCache.insert(indexOfChild(iface), id);
492 } else {
493 // ### This should really not happen,
494 // but it might if the view has a root index set.
495 // This needs to be fixed.
496 QAccessible::deleteAccessibleInterface(id);
497 }
498 ++iter;
499 }
500 childToId = newCache;
501 break;
502 }
503
504 case QAccessibleTableModelChangeEvent::ColumnsRemoved:
505 case QAccessibleTableModelChangeEvent::RowsRemoved: {
506 ChildCache newCache;
507 ChildCache::ConstIterator iter = childToId.constBegin();
508 while (iter != childToId.constEnd()) {
509 QAccessible::Id id = iter.value();
510 QAccessibleInterface* iface = QAccessible::accessibleInterface(id);
511 Q_ASSERT(iface);
512 if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
513 Q_ASSERT(iface->tableCellInterface());
514 AccessibleInstanceViewItem* cell = static_cast<AccessibleInstanceViewItem*>(iface->tableCellInterface());
515 // Since it is a QPersistentModelIndex, we only need to check if it is valid
516 if (cell->m_index.isValid())
517 newCache.insert(indexOfChild(cell), id);
518 else
519 QAccessible::deleteAccessibleInterface(id);
520 }
521 ++iter;
522 }
523 childToId = newCache;
524 break;

Callers

nothing calls this directly

Calls 6

valueMethod · 0.80
insertMethod · 0.80
roleMethod · 0.80
isEmptyMethod · 0.45
clearMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected