options players tab only show now when filled
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Syping 2020-08-25 14:07:42 +02:00
parent 6b2b18ed16
commit 2bf6bb5630

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) {
QStringList::const_iterator it = players.constBegin();
QStringList::const_iterator end = players.constEnd();
while (it != end)
{ {
bool ok; bool ok;
int playerID = playerIDStr.toInt(&ok); int playerID = it->toInt(&ok);
if (ok) if (ok)
{ {
QString playerName = profileDB->getPlayerName(playerID); 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); ui->twPlayers->sortItems(1, Qt::AscendingOrder);
}
else {
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabPlayers));
}
} }
void OptionsDialog::setupLanguageBox() void OptionsDialog::setupLanguageBox()