2024-01-25 12:33:02 +00:00
|
|
|
#include "shell.hpp"
|
2024-02-01 09:29:45 +00:00
|
|
|
#include <utility>
|
2024-01-25 12:33:02 +00:00
|
|
|
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <qqmllist.h>
|
|
|
|
|
2024-02-01 09:29:45 +00:00
|
|
|
void QtShell::earlyInit(QObject* old) {
|
|
|
|
auto* oldshell = qobject_cast<QtShell*>(old);
|
|
|
|
|
|
|
|
if (oldshell != nullptr) {
|
|
|
|
this->scavengeableChildren = std::move(oldshell->children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QObject* QtShell::scavengeTargetFor(QObject* /* child */) {
|
|
|
|
if (this->scavengeableChildren.length() > this->children.length()) {
|
|
|
|
return this->scavengeableChildren[this->children.length()];
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
2024-02-01 01:43:18 +00:00
|
|
|
}
|
|
|
|
|
2024-02-01 02:35:51 +00:00
|
|
|
QQmlListProperty<QObject> QtShell::components() {
|
|
|
|
return QQmlListProperty<QObject>(
|
2024-01-25 12:33:02 +00:00
|
|
|
this,
|
|
|
|
nullptr,
|
|
|
|
&QtShell::appendComponent,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-02-01 02:35:51 +00:00
|
|
|
void QtShell::appendComponent(QQmlListProperty<QObject>* list, QObject* component) {
|
|
|
|
auto* shell = static_cast<QtShell*>(list->object); // NOLINT
|
|
|
|
component->setParent(shell);
|
2024-02-01 09:29:45 +00:00
|
|
|
shell->children.append(component);
|
2024-01-25 12:33:02 +00:00
|
|
|
}
|