|
|
@ -10,6 +10,8 @@ |
|
|
|
#include <QQmlEngine> |
|
|
|
#include <QQmlEngine> |
|
|
|
#include <QtGlobal> |
|
|
|
#include <QtGlobal> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <ranges> |
|
|
|
|
|
|
|
|
|
|
|
// privat qt headers to access required properties
|
|
|
|
// privat qt headers to access required properties
|
|
|
|
#include <QtQml/private/qqmlincubator_p.h> |
|
|
|
#include <QtQml/private/qqmlincubator_p.h> |
|
|
|
#include <QtQml/private/qqmlobjectcreator_p.h> |
|
|
|
#include <QtQml/private/qqmlobjectcreator_p.h> |
|
|
@ -133,7 +135,7 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
nhlog::ui()->debug("Querying data for id {}", currentId.toStdString()); |
|
|
|
// nhlog::ui()->debug("Querying data for id {}", currentId.toStdString());
|
|
|
|
chooser.room_->multiData(currentId, forReply ? chooser.eventId_ : QString(), roles); |
|
|
|
chooser.room_->multiData(currentId, forReply ? chooser.eventId_ : QString(), roles); |
|
|
|
|
|
|
|
|
|
|
|
Qt::beginPropertyUpdateGroup(); |
|
|
|
Qt::beginPropertyUpdateGroup(); |
|
|
@ -169,7 +171,7 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
forReply ? chooser.eventId_ : QString()) |
|
|
|
forReply ? chooser.eventId_ : QString()) |
|
|
|
.toInt(); |
|
|
|
.toInt(); |
|
|
|
if (type != oldType) { |
|
|
|
if (type != oldType) { |
|
|
|
nhlog::ui()->debug("Type changed!"); |
|
|
|
// nhlog::ui()->debug("Type changed!");
|
|
|
|
reset(currentId); |
|
|
|
reset(currentId); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -178,7 +180,8 @@ EventDelegateChooser::DelegateIncubator::setInitialState(QObject *obj) |
|
|
|
std::vector<QModelRoleData> rolesToRequest; |
|
|
|
std::vector<QModelRoleData> rolesToRequest; |
|
|
|
|
|
|
|
|
|
|
|
if (changedRoles.empty()) { |
|
|
|
if (changedRoles.empty()) { |
|
|
|
for (auto role : roleToPropIdx.keys()) |
|
|
|
for (const auto role : |
|
|
|
|
|
|
|
std::ranges::subrange(roleToPropIdx.keyBegin(), roleToPropIdx.keyEnd())) |
|
|
|
rolesToRequest.emplace_back(role); |
|
|
|
rolesToRequest.emplace_back(role); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for (auto role : changedRoles) { |
|
|
|
for (auto role : changedRoles) { |
|
|
@ -229,7 +232,7 @@ EventDelegateChooser::DelegateIncubator::reset(QString id) |
|
|
|
if (!chooser.room_ || id.isEmpty()) |
|
|
|
if (!chooser.room_ || id.isEmpty()) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
nhlog::ui()->debug("Reset with id {}, reply {}", id.toStdString(), forReply); |
|
|
|
// nhlog::ui()->debug("Reset with id {}, reply {}", id.toStdString(), forReply);
|
|
|
|
|
|
|
|
|
|
|
|
this->currentId = id; |
|
|
|
this->currentId = id; |
|
|
|
|
|
|
|
|
|
|
@ -242,8 +245,8 @@ EventDelegateChooser::DelegateIncubator::reset(QString id) |
|
|
|
for (const auto choice : qAsConst(chooser.choices_)) { |
|
|
|
for (const auto choice : qAsConst(chooser.choices_)) { |
|
|
|
const auto &choiceValue = choice->roleValues(); |
|
|
|
const auto &choiceValue = choice->roleValues(); |
|
|
|
if (choiceValue.contains(role) || choiceValue.empty()) { |
|
|
|
if (choiceValue.contains(role) || choiceValue.empty()) { |
|
|
|
nhlog::ui()->debug( |
|
|
|
// nhlog::ui()->debug(
|
|
|
|
"Instantiating type: {}, c {}", (int)role, choiceValue.contains(role)); |
|
|
|
// "Instantiating type: {}, c {}", (int)role, choiceValue.contains(role));
|
|
|
|
|
|
|
|
|
|
|
|
if (auto child = qobject_cast<QQuickItem *>(object())) { |
|
|
|
if (auto child = qobject_cast<QQuickItem *>(object())) { |
|
|
|
child->setParentItem(nullptr); |
|
|
|
child->setParentItem(nullptr); |
|
|
@ -296,7 +299,7 @@ EventDelegateChooser::updatePolish() |
|
|
|
auto mainChild = qobject_cast<QQuickItem *>(eventIncubator.object()); |
|
|
|
auto mainChild = qobject_cast<QQuickItem *>(eventIncubator.object()); |
|
|
|
auto replyChild = qobject_cast<QQuickItem *>(replyIncubator.object()); |
|
|
|
auto replyChild = qobject_cast<QQuickItem *>(replyIncubator.object()); |
|
|
|
|
|
|
|
|
|
|
|
nhlog::ui()->critical("POLISHING {}", (void *)this); |
|
|
|
// nhlog::ui()->trace("POLISHING {}", (void *)this);
|
|
|
|
|
|
|
|
|
|
|
|
auto layoutItem = [this](QQuickItem *item, int inset) { |
|
|
|
auto layoutItem = [this](QQuickItem *item, int inset) { |
|
|
|
if (item) { |
|
|
|
if (item) { |
|
|
@ -331,8 +334,6 @@ EventDelegateChooser::updatePolish() |
|
|
|
item->setHeight(height); |
|
|
|
item->setHeight(height); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
nhlog::ui()->debug( |
|
|
|
|
|
|
|
"Made event delegate width: {}, {}", width, item->metaObject()->className()); |
|
|
|
|
|
|
|
item->setWidth(width); |
|
|
|
item->setWidth(width); |
|
|
|
item->ensurePolished(); |
|
|
|
item->ensurePolished(); |
|
|
|
} |
|
|
|
} |
|
|
|