mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-29 20:34:56 +01:00
Start editing the name directly after adding a player
This commit is contained in:
parent
03f20dd7be
commit
33814ef058
4 changed files with 17 additions and 12 deletions
|
@ -47,15 +47,8 @@ FavPlayersDialog::FavPlayersDialog(QWidget *iParent)
|
|||
|
||||
void FavPlayersDialog::addRow()
|
||||
{
|
||||
m_helper->addPlayer(PlayerDef(_q("New player"), _q(PlayersTableHelper::kHUMAN), ""));
|
||||
|
||||
// Give focus to the newly created cell containing the player name,
|
||||
// to allow fast edition
|
||||
tablePlayers->setFocus();
|
||||
tablePlayers->setCurrentCell(tablePlayers->rowCount() - 1, 0,
|
||||
QItemSelectionModel::ClearAndSelect |
|
||||
QItemSelectionModel::Current |
|
||||
QItemSelectionModel::Rows);
|
||||
m_helper->addPlayer(PlayerDef(_q("New player"), _q(PlayersTableHelper::kHUMAN), ""),
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ void NewGame::on_pushButtonAdd_clicked()
|
|||
comboBoxType->currentText(),
|
||||
spinBoxLevel->isEnabled() ?
|
||||
QString("%1").arg(spinBoxLevel->value()) : "");
|
||||
m_helper->addPlayer(def);
|
||||
m_helper->addPlayer(def, true);
|
||||
|
||||
// Increment the player ID
|
||||
static int currPlayer = 2;
|
||||
|
|
|
@ -223,11 +223,23 @@ void PlayersTableHelper::addPlayers(const QList<PlayerDef> &iList)
|
|||
}
|
||||
|
||||
|
||||
void PlayersTableHelper::addPlayer(const PlayerDef &iPlayer)
|
||||
void PlayersTableHelper::addPlayer(const PlayerDef &iPlayer, bool selectAndEdit)
|
||||
{
|
||||
QList<PlayerDef> tmpList;
|
||||
tmpList.push_back(iPlayer);
|
||||
addPlayers(tmpList);
|
||||
|
||||
if (selectAndEdit)
|
||||
{
|
||||
int row = m_tablePlayers->rowCount() - 1;
|
||||
// Give focus to the newly created cell containing the player name
|
||||
m_tablePlayers->setCurrentCell(row, 0,
|
||||
QItemSelectionModel::ClearAndSelect |
|
||||
QItemSelectionModel::Current |
|
||||
QItemSelectionModel::Rows);
|
||||
// Edit the name
|
||||
m_tablePlayers->editItem(m_tablePlayers->item(row, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
QList<PlayerDef> getPlayers(bool onlySelected) const;
|
||||
void addPlayers(const QList<PlayerDef> &iList);
|
||||
void addPlayer(const PlayerDef &iPlayer);
|
||||
void addPlayer(const PlayerDef &iPlayer, bool selectAndEdit = false);
|
||||
|
||||
static QList<PlayerDef> getFavPlayers();
|
||||
static void saveFavPlayers(const QList<PlayerDef> &iFavPlayers);
|
||||
|
|
Loading…
Add table
Reference in a new issue