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

Method selectProcessInTree

src/processeswidget.cpp:133–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133bool 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

Callers 1

SelectProcessByPidMethod · 0.95

Calls 2

IndexForPidMethod · 0.80
parentMethod · 0.80

Tested by

no test coverage detected