MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / setSelectedAndExpanded

Method setSelectedAndExpanded

src/document/UBDocumentController.cpp:1494–1524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1492}
1493
1494void UBDocumentTreeView::setSelectedAndExpanded(const QModelIndex &pIndex, bool pExpand, bool pEdit)
1495{
1496 if (!pIndex.isValid()) {
1497 return;
1498 }
1499
1500 QModelIndex indexCurrentDoc = pIndex;
1501 clearSelection();
1502
1503 UBSortFilterProxyModel *proxy = dynamic_cast<UBSortFilterProxyModel*>(model());
1504
1505 QItemSelectionModel::SelectionFlags sel = pExpand
1506 ? QItemSelectionModel::Select
1507 : QItemSelectionModel::Deselect;
1508
1509 setCurrentIndex(proxy->mapFromSource(indexCurrentDoc));
1510
1511 selectionModel()->setCurrentIndex(proxy->mapFromSource(indexCurrentDoc), QItemSelectionModel::SelectCurrent);
1512
1513 selectionModel()->select(proxy->mapFromSource(indexCurrentDoc), QItemSelectionModel::Rows | sel);
1514
1515 while (indexCurrentDoc.parent().isValid()) {
1516 setExpanded(indexCurrentDoc.parent(), pExpand);
1517 indexCurrentDoc = indexCurrentDoc.parent();
1518 }
1519
1520 scrollTo(proxy->mapFromSource(pIndex));
1521
1522 if (pEdit)
1523 edit(proxy->mapFromSource(pIndex));
1524}
1525
1526void UBDocumentTreeView::onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex)
1527{

Callers 3

selectDocumentMethod · 0.80
sortDocumentsMethod · 0.80

Calls 4

mapFromSourceMethod · 0.80
setCurrentIndexMethod · 0.80
isValidMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected