MCPcopy Create free account
hub / github.com/KDE/kdevelop / selectIndex

Method selectIndex

plugins/problemreporter/problemsview.cpp:288–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void ItemViewWalker::selectIndex(Direction direction)
289{
290 if (!m_selectionModel) {
291 return;
292 }
293
294 const QModelIndexList list = m_selectionModel->selectedRows();
295
296 constexpr auto selectionCommand = QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows;
297
298 const QModelIndex currentIndex = list.value(0);
299 if (!currentIndex.isValid()) {
300 /// no selection yet, just select the first
301 const QModelIndex firstIndex = m_selectionModel->model()->index(0, 0);
302 m_selectionModel->setCurrentIndex(firstIndex, selectionCommand);
303 return;
304 }
305
306 const int nextRow = currentIndex.row() + (direction == NextIndex ? 1 : -1);
307 const QModelIndex nextIndex = currentIndex.sibling(nextRow, 0);
308 if (!nextIndex.isValid()) {
309 return; /// never invalidate the selection
310 }
311
312 m_selectionModel->setCurrentIndex(nextIndex, selectionCommand);
313}
314
315ProblemsView::ProblemsView(QWidget* parent)
316 : QWidget(parent)

Callers

nothing calls this directly

Calls 7

setCurrentIndexMethod · 0.80
siblingMethod · 0.80
valueMethod · 0.45
isValidMethod · 0.45
indexMethod · 0.45
modelMethod · 0.45
rowMethod · 0.45

Tested by

no test coverage detected