mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Allow to save list of "other servers"
* load / save setting called * fixed handling in server form Follow up of refs #533, related to #545
This commit is contained in:
@@ -34,15 +34,32 @@ namespace BlackGui
|
||||
|
||||
void CServerListSelector::setItemStrings(const CServerList &servers)
|
||||
{
|
||||
QString currentlySelected(this->currentText());
|
||||
int index = -1;
|
||||
this->m_servers = servers;
|
||||
this->m_items.clear();
|
||||
foreach(CServer server, servers)
|
||||
for (const CServer &server : servers)
|
||||
{
|
||||
QString d(server.getName() + ": " + server.getDescription());
|
||||
m_items.append(d);
|
||||
if (!currentlySelected.isEmpty() && index < 0 && d == currentlySelected)
|
||||
{
|
||||
index = m_items.size() - 1;
|
||||
}
|
||||
}
|
||||
this->clear(); // ui
|
||||
this->addItems(m_items);
|
||||
|
||||
// reselect
|
||||
if (this->m_items.isEmpty()) { return; }
|
||||
if (this->m_items.size() == 1)
|
||||
{
|
||||
this->setCurrentIndex(0);
|
||||
}
|
||||
else if (index >= 0)
|
||||
{
|
||||
this->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user