MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / modelChange

Method modelChange

launcher/ui/instanceview/AccessibleInstanceView.cpp:472–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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