| 100 | } |
| 101 | |
| 102 | bool ProcessesWidget::selectProcessInTable(pid_t pid) |
| 103 | { |
| 104 | if (pid <= 0) |
| 105 | return false; |
| 106 | |
| 107 | for (int row = 0; row < this->m_model->rowCount(); ++row) |
| 108 | { |
| 109 | const QModelIndex sourceIdx = this->m_model->index(row, OS::ProcessModel::ColPid); |
| 110 | if (!sourceIdx.isValid()) |
| 111 | continue; |
| 112 | if (static_cast<pid_t>(this->m_model->data(sourceIdx, Qt::UserRole).toLongLong()) != pid) |
| 113 | continue; |
| 114 | |
| 115 | const QModelIndex proxyIdx = this->m_proxy->mapFromSource(sourceIdx); |
| 116 | if (!proxyIdx.isValid()) |
| 117 | return false; |
| 118 | |
| 119 | QItemSelectionModel *selectionModel = this->ui->tableView->selectionModel(); |
| 120 | if (!selectionModel) |
| 121 | return false; |
| 122 | |
| 123 | selectionModel->clearSelection(); |
| 124 | selectionModel->select(proxyIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); |
| 125 | selectionModel->setCurrentIndex(proxyIdx, QItemSelectionModel::NoUpdate); |
| 126 | this->ui->tableView->scrollTo(proxyIdx, QAbstractItemView::PositionAtCenter); |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | bool ProcessesWidget::selectProcessInTree(pid_t pid) |
| 134 | { |
no test coverage detected