MCPcopy Create free account
hub / github.com/benapetr/TuxManager / selectProcessInTable

Method selectProcessInTable

src/processeswidget.cpp:102–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102bool 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
133bool ProcessesWidget::selectProcessInTree(pid_t pid)
134{

Callers 1

SelectProcessByPidMethod · 0.95

Calls 3

indexMethod · 0.80
rowCountMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected