GUI: fix issue of text not displaying when jumping to table with Ctrl+0

This commit is contained in:
Jean-Francois Dockes 2021-04-13 09:50:35 +02:00
parent 2fe5490c39
commit ebcef6a1ff

View File

@ -834,6 +834,18 @@ void ResTable::setCurrentRowFromKbd(int row)
LOGDEB1("setCurrentRowFromKbd: " << row << "\n"); LOGDEB1("setCurrentRowFromKbd: " << row << "\n");
m_rowchangefromkbd = true; m_rowchangefromkbd = true;
tableView->setFocus(Qt::ShortcutFocusReason); tableView->setFocus(Qt::ShortcutFocusReason);
// After calling setCurrentIndex(), currentChanged() gets called
// twice, once with row 0 and no selection, once with the actual
// target row and selection set. It uses this fact to discriminate
// this from hovering. For some reason, when row is zero, there is
// only one call. So, in this case, we first select row 1, and
// this so pretty hack gets things working
if (row == 0) {
tableView->selectionModel()->setCurrentIndex(
m_model->index(1, 0),
QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows);
}
tableView->selectionModel()->setCurrentIndex( tableView->selectionModel()->setCurrentIndex(
m_model->index(row, 0), m_model->index(row, 0),
QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows); QItemSelectionModel::ClearAndSelect|QItemSelectionModel::Rows);