diff --git a/libnymea-app/interfacesmodel.cpp b/libnymea-app/interfacesmodel.cpp index 5aac5972..f73faa13 100644 --- a/libnymea-app/interfacesmodel.cpp +++ b/libnymea-app/interfacesmodel.cpp @@ -69,16 +69,15 @@ Engine *InterfacesModel::engine() const void InterfacesModel::setEngine(Engine *engine) { if (m_engine != engine) { - static QMetaObject::Connection countChangedConnection; if (m_engine) { - disconnect(countChangedConnection); + disconnect(m_thingClassesCountChangedConnection); } m_engine = engine; emit engineChanged(); - countChangedConnection = connect(engine->deviceManager()->deviceClasses(), &DeviceClasses::countChanged, this, [this]() { + m_thingClassesCountChangedConnection = connect(engine->deviceManager()->deviceClasses(), &DeviceClasses::countChanged, this, [this]() { syncInterfaces(); }); @@ -86,24 +85,22 @@ void InterfacesModel::setEngine(Engine *engine) } } -DevicesProxy *InterfacesModel::devices() const +DevicesProxy *InterfacesModel::things() const { - return m_devicesProxy; + return m_thingsProxy; } -void InterfacesModel::setDevices(DevicesProxy *devices) +void InterfacesModel::setThings(DevicesProxy *things) { - if (m_devicesProxy != devices) { - static QMetaObject::Connection countChangedConnection; - - if (m_devicesProxy) { - disconnect(countChangedConnection); + if (m_thingsProxy != things) { + if (m_thingsProxy) { + disconnect(m_thingsCountChangedConnection); } - m_devicesProxy = devices; - emit devicesChanged(); + m_thingsProxy = things; + emit thingsChanged(); - countChangedConnection = connect(devices, &DevicesProxy::countChanged, this, [this]() { + m_thingsCountChangedConnection = connect(things, &DevicesProxy::countChanged, this, [this]() { syncInterfaces(); }); syncInterfaces(); @@ -153,9 +150,9 @@ void InterfacesModel::syncInterfaces() return; } QList deviceClasses; - if (m_devicesProxy) { - for (int i = 0; i < m_devicesProxy->rowCount(); i++) { - deviceClasses << m_engine->deviceManager()->deviceClasses()->getDeviceClass(m_devicesProxy->get(i)->deviceClassId()); + if (m_thingsProxy) { + for (int i = 0; i < m_thingsProxy->rowCount(); i++) { + deviceClasses << m_engine->deviceManager()->deviceClasses()->getDeviceClass(m_thingsProxy->get(i)->deviceClassId()); } } else { for (int i = 0; i < m_engine->deviceManager()->deviceClasses()->rowCount(); i++) { diff --git a/libnymea-app/interfacesmodel.h b/libnymea-app/interfacesmodel.h index 28714c00..e6fca2e9 100644 --- a/libnymea-app/interfacesmodel.h +++ b/libnymea-app/interfacesmodel.h @@ -48,7 +48,7 @@ class InterfacesModel : public QAbstractListModel Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged) // Optional filters - Q_PROPERTY(DevicesProxy* devices READ devices WRITE setDevices NOTIFY devicesChanged) + Q_PROPERTY(DevicesProxy* things READ things WRITE setThings NOTIFY thingsChanged) Q_PROPERTY(QStringList shownInterfaces READ shownInterfaces WRITE setShownInterfaces NOTIFY shownInterfacesChanged) Q_PROPERTY(bool showUncategorized READ showUncategorized WRITE setShowUncategorized NOTIFY showUncategorizedChanged) @@ -67,8 +67,8 @@ public: Engine* engine() const; void setEngine(Engine *engine); - DevicesProxy* devices() const; - void setDevices(DevicesProxy *devices); + DevicesProxy* things() const; + void setThings(DevicesProxy *things); QStringList shownInterfaces() const; void setShownInterfaces(const QStringList &shownInterfaces); @@ -84,7 +84,7 @@ public: signals: void countChanged(); void engineChanged(); - void devicesChanged(); + void thingsChanged(); void shownInterfacesChanged(); bool onlyConfiguredDevicesChanged(); void showUncategorizedChanged(); @@ -95,9 +95,13 @@ private slots: private: Engine *m_engine = nullptr; + QMetaObject::Connection m_thingClassesCountChangedConnection; + QStringList m_interfaces; - DevicesProxy *m_devicesProxy = nullptr; + DevicesProxy *m_thingsProxy = nullptr; + QMetaObject::Connection m_thingsCountChangedConnection; + QStringList m_shownInterfaces; bool m_showUncategorized = false; }; diff --git a/nymea-app/ui/grouping/GroupInterfacesPage.qml b/nymea-app/ui/grouping/GroupInterfacesPage.qml index d89f419b..435c6ef2 100644 --- a/nymea-app/ui/grouping/GroupInterfacesPage.qml +++ b/nymea-app/ui/grouping/GroupInterfacesPage.qml @@ -60,7 +60,7 @@ Page { model: InterfacesSortModel { interfacesModel: InterfacesModel { engine: _engine - devices: devicesInGroup + things: devicesInGroup shownInterfaces: app.supportedInterfaces showUncategorized: true } diff --git a/nymea-app/ui/mainviews/ThingsView.qml b/nymea-app/ui/mainviews/ThingsView.qml index 12b92e39..55aca788 100644 --- a/nymea-app/ui/mainviews/ThingsView.qml +++ b/nymea-app/ui/mainviews/ThingsView.qml @@ -43,7 +43,7 @@ MainViewBase { id: mainModel interfacesModel: InterfacesModel { engine: _engine - devices: DevicesProxy { + things: DevicesProxy { engine: _engine } shownInterfaces: app.supportedInterfaces