Also update InterfacesModel
This commit is contained in:
parent
748793b376
commit
6dad1dfb5f
@ -69,16 +69,15 @@ Engine *InterfacesModel::engine() const
|
|||||||
void InterfacesModel::setEngine(Engine *engine)
|
void InterfacesModel::setEngine(Engine *engine)
|
||||||
{
|
{
|
||||||
if (m_engine != engine) {
|
if (m_engine != engine) {
|
||||||
static QMetaObject::Connection countChangedConnection;
|
|
||||||
|
|
||||||
if (m_engine) {
|
if (m_engine) {
|
||||||
disconnect(countChangedConnection);
|
disconnect(m_thingClassesCountChangedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_engine = engine;
|
m_engine = engine;
|
||||||
emit engineChanged();
|
emit engineChanged();
|
||||||
|
|
||||||
countChangedConnection = connect(engine->deviceManager()->deviceClasses(), &DeviceClasses::countChanged, this, [this]() {
|
m_thingClassesCountChangedConnection = connect(engine->deviceManager()->deviceClasses(), &DeviceClasses::countChanged, this, [this]() {
|
||||||
syncInterfaces();
|
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) {
|
if (m_thingsProxy != things) {
|
||||||
static QMetaObject::Connection countChangedConnection;
|
if (m_thingsProxy) {
|
||||||
|
disconnect(m_thingsCountChangedConnection);
|
||||||
if (m_devicesProxy) {
|
|
||||||
disconnect(countChangedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devicesProxy = devices;
|
m_thingsProxy = things;
|
||||||
emit devicesChanged();
|
emit thingsChanged();
|
||||||
|
|
||||||
countChangedConnection = connect(devices, &DevicesProxy::countChanged, this, [this]() {
|
m_thingsCountChangedConnection = connect(things, &DevicesProxy::countChanged, this, [this]() {
|
||||||
syncInterfaces();
|
syncInterfaces();
|
||||||
});
|
});
|
||||||
syncInterfaces();
|
syncInterfaces();
|
||||||
@ -153,9 +150,9 @@ void InterfacesModel::syncInterfaces()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<DeviceClass*> deviceClasses;
|
QList<DeviceClass*> deviceClasses;
|
||||||
if (m_devicesProxy) {
|
if (m_thingsProxy) {
|
||||||
for (int i = 0; i < m_devicesProxy->rowCount(); i++) {
|
for (int i = 0; i < m_thingsProxy->rowCount(); i++) {
|
||||||
deviceClasses << m_engine->deviceManager()->deviceClasses()->getDeviceClass(m_devicesProxy->get(i)->deviceClassId());
|
deviceClasses << m_engine->deviceManager()->deviceClasses()->getDeviceClass(m_thingsProxy->get(i)->deviceClassId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < m_engine->deviceManager()->deviceClasses()->rowCount(); i++) {
|
for (int i = 0; i < m_engine->deviceManager()->deviceClasses()->rowCount(); i++) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class InterfacesModel : public QAbstractListModel
|
|||||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
|
|
||||||
// Optional filters
|
// 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(QStringList shownInterfaces READ shownInterfaces WRITE setShownInterfaces NOTIFY shownInterfacesChanged)
|
||||||
Q_PROPERTY(bool showUncategorized READ showUncategorized WRITE setShowUncategorized NOTIFY showUncategorizedChanged)
|
Q_PROPERTY(bool showUncategorized READ showUncategorized WRITE setShowUncategorized NOTIFY showUncategorizedChanged)
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public:
|
|||||||
Engine* engine() const;
|
Engine* engine() const;
|
||||||
void setEngine(Engine *engine);
|
void setEngine(Engine *engine);
|
||||||
|
|
||||||
DevicesProxy* devices() const;
|
DevicesProxy* things() const;
|
||||||
void setDevices(DevicesProxy *devices);
|
void setThings(DevicesProxy *things);
|
||||||
|
|
||||||
QStringList shownInterfaces() const;
|
QStringList shownInterfaces() const;
|
||||||
void setShownInterfaces(const QStringList &shownInterfaces);
|
void setShownInterfaces(const QStringList &shownInterfaces);
|
||||||
@ -84,7 +84,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void engineChanged();
|
void engineChanged();
|
||||||
void devicesChanged();
|
void thingsChanged();
|
||||||
void shownInterfacesChanged();
|
void shownInterfacesChanged();
|
||||||
bool onlyConfiguredDevicesChanged();
|
bool onlyConfiguredDevicesChanged();
|
||||||
void showUncategorizedChanged();
|
void showUncategorizedChanged();
|
||||||
@ -95,9 +95,13 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Engine *m_engine = nullptr;
|
Engine *m_engine = nullptr;
|
||||||
|
QMetaObject::Connection m_thingClassesCountChangedConnection;
|
||||||
|
|
||||||
QStringList m_interfaces;
|
QStringList m_interfaces;
|
||||||
|
|
||||||
DevicesProxy *m_devicesProxy = nullptr;
|
DevicesProxy *m_thingsProxy = nullptr;
|
||||||
|
QMetaObject::Connection m_thingsCountChangedConnection;
|
||||||
|
|
||||||
QStringList m_shownInterfaces;
|
QStringList m_shownInterfaces;
|
||||||
bool m_showUncategorized = false;
|
bool m_showUncategorized = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -60,7 +60,7 @@ Page {
|
|||||||
model: InterfacesSortModel {
|
model: InterfacesSortModel {
|
||||||
interfacesModel: InterfacesModel {
|
interfacesModel: InterfacesModel {
|
||||||
engine: _engine
|
engine: _engine
|
||||||
devices: devicesInGroup
|
things: devicesInGroup
|
||||||
shownInterfaces: app.supportedInterfaces
|
shownInterfaces: app.supportedInterfaces
|
||||||
showUncategorized: true
|
showUncategorized: true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ MainViewBase {
|
|||||||
id: mainModel
|
id: mainModel
|
||||||
interfacesModel: InterfacesModel {
|
interfacesModel: InterfacesModel {
|
||||||
engine: _engine
|
engine: _engine
|
||||||
devices: DevicesProxy {
|
things: DevicesProxy {
|
||||||
engine: _engine
|
engine: _engine
|
||||||
}
|
}
|
||||||
shownInterfaces: app.supportedInterfaces
|
shownInterfaces: app.supportedInterfaces
|
||||||
|
|||||||
Reference in New Issue
Block a user