| 1492 | } |
| 1493 | |
| 1494 | void 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 | |
| 1526 | void UBDocumentTreeView::onModelIndexChanged(const QModelIndex &pNewIndex, const QModelIndex &pOldIndex) |
| 1527 | { |
no test coverage detected