Fix changed signal when new hosts are discovered

pull/538/head
Michael Zanetti 2021-02-19 17:39:31 +01:00
parent bef59fbdd7
commit e42fe6f331
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -71,6 +71,14 @@ void NymeaHosts::addHost(NymeaHost *host)
}
}
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);
beginInsertRows(QModelIndex(), m_hosts.count(), m_hosts.count());