|
|
|
@ -162,10 +162,13 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
|
|
|
|
|
|
// setInitialProperties(rolesToSet);
|
|
|
|
|
|
|
|
|
|
auto update = |
|
|
|
|
[this, obj, roleToPropIdx = std::move(roleToPropIdx)](const QList<int> &changedRoles) { |
|
|
|
|
auto update = [this, obj, roleToPropIdx = std::move(roleToPropIdx)]( |
|
|
|
|
const QList<int> &changedRoles, TimelineModel *room) { |
|
|
|
|
if (!room) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (changedRoles.empty() || changedRoles.contains(TimelineModel::Roles::Type)) { |
|
|
|
|
int type = chooser.room_ |
|
|
|
|
int type = room |
|
|
|
|
->dataById(currentId, |
|
|
|
|
TimelineModel::Roles::Type, |
|
|
|
|
forReply ? chooser.eventId_ : QString()) |
|
|
|
@ -195,8 +198,7 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
auto mo = obj->metaObject(); |
|
|
|
|
chooser.room_->multiData( |
|
|
|
|
currentId, forReply ? chooser.eventId_ : QString(), rolesToRequest); |
|
|
|
|
room->multiData(currentId, forReply ? chooser.eventId_ : QString(), rolesToRequest); |
|
|
|
|
|
|
|
|
|
Qt::beginPropertyUpdateGroup(); |
|
|
|
|
for (const auto &role : rolesToRequest) { |
|
|
|
@ -211,18 +213,27 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
|
chooser.room_, |
|
|
|
|
&QAbstractItemModel::dataChanged, |
|
|
|
|
obj, |
|
|
|
|
[row, update](const QModelIndex &topLeft, |
|
|
|
|
[row, update, room = chooser.room_](const QModelIndex &topLeft, |
|
|
|
|
const QModelIndex &bottomRight, |
|
|
|
|
const QList<int> &changedRoles) { |
|
|
|
|
if (row < topLeft.row() || row > bottomRight.row()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
update(changedRoles); |
|
|
|
|
update(changedRoles, room); |
|
|
|
|
}, |
|
|
|
|
Qt::QueuedConnection); |
|
|
|
|
connect(&this->chooser, &EventDelegateChooser::destroyed, obj, [connection]() { |
|
|
|
|
QObject::disconnect(connection); |
|
|
|
|
}); |
|
|
|
|
connect( |
|
|
|
|
&this->chooser, |
|
|
|
|
&EventDelegateChooser::destroyed, |
|
|
|
|
obj, |
|
|
|
|
[connection]() { QObject::disconnect(connection); }, |
|
|
|
|
Qt::SingleShotConnection); |
|
|
|
|
connect( |
|
|
|
|
&this->chooser, |
|
|
|
|
&EventDelegateChooser::roomChanged, |
|
|
|
|
obj, |
|
|
|
|
[connection]() { QObject::disconnect(connection); }, |
|
|
|
|
Qt::SingleShotConnection); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|