options players tab only show now when filled
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Syping 2020-08-25 14:07:42 +02:00
parent 6b2b18ed16
commit 2bf6bb5630
1 changed files with 22 additions and 13 deletions

View File

@ -136,24 +136,33 @@ OptionsDialog::~OptionsDialog()
void OptionsDialog::setupTreeWidget() void OptionsDialog::setupTreeWidget()
{ {
for (QString playerIDStr : profileDB->getPlayers()) const QStringList players = profileDB->getPlayers();
{ if (players.length() != 0) {
bool ok; QStringList::const_iterator it = players.constBegin();
int playerID = playerIDStr.toInt(&ok); QStringList::const_iterator end = players.constEnd();
if (ok) while (it != end)
{ {
QString playerName = profileDB->getPlayerName(playerID); bool ok;
int playerID = it->toInt(&ok);
if (ok)
{
QString playerName = profileDB->getPlayerName(playerID);
QStringList playerTreeViewList; QStringList playerTreeViewList;
playerTreeViewList += playerIDStr; playerTreeViewList += *it;
playerTreeViewList += playerName; playerTreeViewList += playerName;
QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList); QTreeWidgetItem *playerItem = new QTreeWidgetItem(playerTreeViewList);
ui->twPlayers->addTopLevelItem(playerItem); ui->twPlayers->addTopLevelItem(playerItem);
playerItems += playerItem; playerItems += playerItem;
}
it++;
} }
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
else {
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPlayers));
} }
ui->twPlayers->sortItems(1, Qt::AscendingOrder);
} }
void OptionsDialog::setupLanguageBox() void OptionsDialog::setupLanguageBox()