MCPcopy Create free account
hub / github.com/MultiMC/Launcher / modelChange

Method modelChange

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

Source from the content-addressed store, hash-verified

464}
465
466void AccessibleInstanceView::modelChange(QAccessibleTableModelChangeEvent *event)
467{
468 // if there is no cache yet, we don't update anything
469 if (childToId.isEmpty())
470 return;
471
472 switch (event->modelChangeType()) {
473 case QAccessibleTableModelChangeEvent::ModelReset:
474 for (QAccessible::Id id : childToId)
475 QAccessible::deleteAccessibleInterface(id);
476 childToId.clear();
477 break;
478
479 // rows are inserted: move every row after that
480 case QAccessibleTableModelChangeEvent::RowsInserted:
481 case QAccessibleTableModelChangeEvent::ColumnsInserted: {
482
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;

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected