Update the AWS device name when it changes in the cloud
This commit is contained in:
parent
583cd927b8
commit
2fd9382675
@ -970,7 +970,7 @@ void AWSClient::fetchDevices()
|
|||||||
QString deviceId = entry.toMap().value("deviceId").toString();
|
QString deviceId = entry.toMap().value("deviceId").toString();
|
||||||
QString name = entry.toMap().value("name").toString();
|
QString name = entry.toMap().value("name").toString();
|
||||||
bool online = entry.toMap().value("online").toBool();
|
bool online = entry.toMap().value("online").toBool();
|
||||||
// qDebug() << "Have cloud device:" << deviceId << name << "online:" << online;
|
qDebug() << "Have cloud device:" << deviceId << name << "online:" << online;
|
||||||
|
|
||||||
AWSDevice *d = m_devices->getDevice(deviceId);
|
AWSDevice *d = m_devices->getDevice(deviceId);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
@ -978,6 +978,7 @@ void AWSClient::fetchDevices()
|
|||||||
m_devices->insert(d);
|
m_devices->insert(d);
|
||||||
}
|
}
|
||||||
d->setOnline(online);
|
d->setOnline(online);
|
||||||
|
d->setName(name);
|
||||||
actualDevices.append(d->id());
|
actualDevices.append(d->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1144,6 +1145,21 @@ void AWSDevices::insert(AWSDevice *device)
|
|||||||
device->setParent(this);
|
device->setParent(this);
|
||||||
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
|
||||||
m_list.append(device);
|
m_list.append(device);
|
||||||
|
|
||||||
|
connect(device, &AWSDevice::onlineChanged, this, [this, device](){
|
||||||
|
int idx = m_list.indexOf(device);
|
||||||
|
if (idx >= 0) {
|
||||||
|
emit dataChanged(index(idx), index(idx), {RoleOnline});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(device, &AWSDevice::nameChanged, this, [this, device](){
|
||||||
|
int idx = m_list.indexOf(device);
|
||||||
|
if (idx >= 0) {
|
||||||
|
emit dataChanged(index(idx), index(idx), {RoleName});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
@ -1196,6 +1212,14 @@ QString AWSDevice::name() const
|
|||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AWSDevice::setName(const QString &name)
|
||||||
|
{
|
||||||
|
if (m_name != name) {
|
||||||
|
m_name = name;
|
||||||
|
emit nameChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AWSDevice::online() const
|
bool AWSDevice::online() const
|
||||||
{
|
{
|
||||||
return m_online;
|
return m_online;
|
||||||
|
|||||||
@ -12,18 +12,20 @@ class QNetworkAccessManager;
|
|||||||
class AWSDevice: public QObject {
|
class AWSDevice: public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString id READ id CONSTANT)
|
Q_PROPERTY(QString id READ id CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(bool online READ online NOTIFY onlineChanged)
|
Q_PROPERTY(bool online READ online NOTIFY onlineChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWSDevice(const QString &id, const QString &name, bool online = false, QObject *parent = nullptr);
|
AWSDevice(const QString &id, const QString &name, bool online = false, QObject *parent = nullptr);
|
||||||
QString id() const;
|
QString id() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
void setName(const QString &name);
|
||||||
bool online() const;
|
bool online() const;
|
||||||
void setOnline(bool online);
|
void setOnline(bool online);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onlineChanged();
|
void onlineChanged();
|
||||||
|
void nameChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QString m_id;
|
||||||
|
|||||||
@ -275,6 +275,9 @@ void NymeaConnection::onError(QAbstractSocket::SocketError error)
|
|||||||
transport->deleteLater();
|
transport->deleteLater();
|
||||||
}
|
}
|
||||||
qDebug() << "A transport error happened for" << transport->url() << error << "(Still trying on" << m_transportCandidates.count() << "connections)";
|
qDebug() << "A transport error happened for" << transport->url() << error << "(Still trying on" << m_transportCandidates.count() << "connections)";
|
||||||
|
foreach (Connection *c, m_transportCandidates) {
|
||||||
|
qDebug() << "Connection candidate:" << c->url();
|
||||||
|
}
|
||||||
if (m_transportCandidates.isEmpty()) {
|
if (m_transportCandidates.isEmpty()) {
|
||||||
m_connectionStatus = errorStatus;
|
m_connectionStatus = errorStatus;
|
||||||
emit connectionStatusChanged();
|
emit connectionStatusChanged();
|
||||||
|
|||||||
@ -214,7 +214,7 @@ Page {
|
|||||||
errorLabel.text = qsTr("Failed to connect to the login server. Please mase sure your network connection is working.")
|
errorLabel.text = qsTr("Failed to connect to the login server. Please mase sure your network connection is working.")
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errorLabel.text = qsTr("An unexpected error happened. Please report this isse. Error code:").arg(error)
|
errorLabel.text = qsTr("An unexpected error happened. Please report this isse. Error code: %1").arg(error)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
errorLabel.visible = (error !== AWSClient.LoginErrorNoError)
|
errorLabel.visible = (error !== AWSClient.LoginErrorNoError)
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit eacffb695f8870c75b027a701277f6ec4455d327
|
Subproject commit 9c7075192b2b799feb302b48618eb4ef4d942172
|
||||||
Reference in New Issue
Block a user