Merge PR #538: Fix changed signal when new hosts are discovered

This commit is contained in:
Jenkins nymea 2021-02-25 23:50:58 +01:00
commit 0a442d56cc
2 changed files with 9 additions and 1 deletions

View File

@ -137,7 +137,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
if (!host) { if (!host) {
host = new NymeaHost(m_nymeaHosts); host = new NymeaHost(m_nymeaHosts);
host->setUuid(uuid); host->setUuid(uuid);
// qDebug() << "ZeroConf: Adding new host:" << serverName << uuid; qDebug() << "ZeroConf: Adding new host:" << serverName << uuid;
m_nymeaHosts->addHost(host); m_nymeaHosts->addHost(host);
} }
host->setName(serverName); host->setName(serverName);

View File

@ -71,6 +71,14 @@ void NymeaHosts::addHost(NymeaHost *host)
} }
} }
host->setParent(this); host->setParent(this);
connect(host, &NymeaHost::nameChanged, this, [=](){
int idx = m_hosts.indexOf(host);
emit dataChanged(index(idx), index(idx), {NameRole});
});
connect(host, &NymeaHost::versionChanged, this, [=](){
int idx = m_hosts.indexOf(host);
emit dataChanged(index(idx), index(idx), {VersionRole});
});
connect(host, &NymeaHost::connectionChanged, this, &NymeaHosts::hostChanged); connect(host, &NymeaHost::connectionChanged, this, &NymeaHosts::hostChanged);
beginInsertRows(QModelIndex(), m_hosts.count(), m_hosts.count()); beginInsertRows(QModelIndex(), m_hosts.count(), m_hosts.count());