| 131 | } |
| 132 | |
| 133 | bool ProcessesWidget::selectProcessInTree(pid_t pid) |
| 134 | { |
| 135 | if (pid <= 0) |
| 136 | return false; |
| 137 | |
| 138 | const QModelIndex sourceIdx = this->m_treeModel->IndexForPid(pid); |
| 139 | if (!sourceIdx.isValid()) |
| 140 | return false; |
| 141 | |
| 142 | const QModelIndex proxyIdx = this->m_treeProxy->mapFromSource(sourceIdx); |
| 143 | if (!proxyIdx.isValid()) |
| 144 | return false; |
| 145 | |
| 146 | QItemSelectionModel *selectionModel = this->m_treeView->selectionModel(); |
| 147 | if (!selectionModel) |
| 148 | return false; |
| 149 | |
| 150 | selectionModel->clearSelection(); |
| 151 | selectionModel->select(proxyIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); |
| 152 | selectionModel->setCurrentIndex(proxyIdx, QItemSelectionModel::NoUpdate); |
| 153 | this->m_treeView->scrollTo(proxyIdx, QAbstractItemView::PositionAtCenter); |
| 154 | this->m_treeView->expand(proxyIdx.parent()); |
| 155 | return true; |
| 156 | } |
| 157 | |
| 158 | // ── Private setup ───────────────────────────────────────────────────────────── |
| 159 |
no test coverage detected