fix some on properties and signal connection

This commit is contained in:
AndreaRigoni
2026-03-26 09:50:52 +00:00
parent 2c5d6842c3
commit e0ffeff5b7
22 changed files with 578 additions and 62 deletions

View File

@@ -14,10 +14,25 @@ void ContextModel::setContext(uLib::ObjectsContext* context) {
beginResetModel();
m_rootContext = context;
if (m_rootContext) {
uLib::Object::connect(m_rootContext, &uLib::Object::Updated, [this]() {
auto refresh = [this]() {
this->beginResetModel();
this->endResetModel();
};
uLib::Object::connect(m_rootContext, &uLib::Object::Updated, refresh);
uLib::Object::connect(m_rootContext, &uLib::ObjectsContext::ObjectAdded, [this, refresh](uLib::Object* obj) {
uLib::Object::connect(obj, &uLib::Object::Updated, refresh);
refresh();
});
uLib::Object::connect(m_rootContext, &uLib::ObjectsContext::ObjectRemoved, [this, refresh](uLib::Object* obj) {
// Disconnect would be good here but not strictly required if refresh handles it
refresh();
});
// Connect existing objects
for (auto* obj : m_rootContext->GetObjects()) {
uLib::Object::connect(obj, &uLib::Object::Updated, refresh);
}
}
endResetModel();
}