void TestLevelTreeView::selection(void) { QStack<QPair<int, int>> selections = _model->getSelections(); if (selections.isEmpty()) { qDebug() << "No no no, it can't be."; return; } int lineRow = selections.last().first; int vertexRow = selections.last().second; QModelIndex currIndex; if (lineRow == -1 && vertexRow != -1) { qDebug() << "Impossiburu"; return; } else if (lineRow == -1 && vertexRow == -1) { qDebug() << "No line here."; return; } else if (lineRow != -1 && vertexRow == -1) { currIndex = _model->index(lineRow, 0); } else { currIndex = _model->index(vertexRow, 0, _model->index(lineRow, 0)); } if (currIndex.isValid()) { selectionModel()->setCurrentIndex(currIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } else { qDebug() << "currIndex is still not valid!"; } }