connect data change refresh for component sources
This commit is contained in:
parent
7c53a1d9ca
commit
7039696807
|
@ -221,22 +221,39 @@ void MultiverseModel::insert(const QModelIndex &parent,
|
|||
auto index = QPersistentModelIndex(createIndex(item->childCount() - 1, 0,
|
||||
child));
|
||||
|
||||
auto refreshRow = [this] (QPersistentModelIndex index) {
|
||||
auto begin = index.sibling(index.row(), 0);
|
||||
auto end = begin.siblingAtColumn(columnCount() - 1);
|
||||
emit dataChanged(begin, end);
|
||||
};
|
||||
|
||||
connect(universe, &QSacnUniverse::changed,
|
||||
this, [this, index] () {
|
||||
auto begin = index.sibling(index.row(), 0);
|
||||
auto end = begin.siblingAtColumn(columnCount() - 1);
|
||||
emit dataChanged(begin, end);
|
||||
});
|
||||
this, [refreshRow, index](){ refreshRow(index); });
|
||||
|
||||
connect(universe, &QSacnUniverse::sourceListChanged,
|
||||
this, [=]() {
|
||||
this, [this, universe, child, index, refreshRow]() {
|
||||
// remove the old children
|
||||
beginRemoveRows(index, 0, child->childCount() - 1);
|
||||
child->removeChildren();
|
||||
endRemoveRows();
|
||||
|
||||
// add the new children
|
||||
beginInsertRows(index, 0, universe->sources().size() - 1);
|
||||
child->createChildren();
|
||||
endInsertRows();
|
||||
|
||||
// refresh row of new child when data arrives
|
||||
for (int i = 0; i < child->childCount(); i++)
|
||||
{
|
||||
auto grandchild = child->child(i);
|
||||
auto index = QPersistentModelIndex(createIndex(i, 0, grandchild));
|
||||
auto data = grandchild->data(Column::Universe, Qt::EditRole);
|
||||
if (data.metaType().id() != qMetaTypeId<QSacnUniverse*>())
|
||||
return;
|
||||
auto universe = data.value<QSacnUniverse*>();
|
||||
connect(universe, &QSacnUniverse::changed,
|
||||
this, [refreshRow, index](){ refreshRow(index); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue