mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-02-05 08:48:28 +01:00
Arbitration: restore properly the focused player
This commit is contained in:
parent
56028c8651
commit
f4b78e09b1
1 changed files with 12 additions and 2 deletions
|
@ -163,6 +163,10 @@ void ArbitAssignments::updatePlayersModel()
|
|||
{
|
||||
// Save the ID of the selected players
|
||||
QSet<unsigned int> playersIdSet = getSelectedPlayers();
|
||||
// Save the currently focused player (to be able to restore the focus properly)
|
||||
int currProxyRow = treeViewPlayers->selectionModel()->currentIndex().row();
|
||||
QModelIndex currProxyIdx = m_proxyPlayersModel->index(currProxyRow, 0);
|
||||
unsigned currPlayerId = m_proxyPlayersModel->data(currProxyIdx, Qt::UserRole).toUInt();
|
||||
|
||||
m_playersModel->removeRows(0, m_playersModel->rowCount());
|
||||
if (m_game == NULL)
|
||||
|
@ -220,8 +224,14 @@ void ArbitAssignments::updatePlayersModel()
|
|||
if (playersIdSet.contains(player.getId()))
|
||||
{
|
||||
LOG_DEBUG("selecting player " << player.getId());
|
||||
treeViewPlayers->selectionModel()->select(m_playersModel->index(rowNum, 0),
|
||||
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
QModelIndex proxyIndex = m_proxyPlayersModel->mapFromSource(m_playersModel->index(rowNum, 0));
|
||||
treeViewPlayers->selectionModel()->select(proxyIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
// Restore the focus
|
||||
if (player.getId() == currPlayerId)
|
||||
{
|
||||
QModelIndex proxyIndex = m_proxyPlayersModel->mapFromSource(m_playersModel->index(rowNum, 0));
|
||||
treeViewPlayers->selectionModel()->setCurrentIndex(proxyIndex, QItemSelectionModel::Current | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue