This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/doric/widget/flex/FlexLayoutService.cpp

36 lines
1021 B
C++
Raw Normal View History

2021-03-01 16:24:40 +08:00
#include "FlexLayoutService.h"
FlexLayoutService::FlexLayoutService(QObject *parent) : QObject(parent) {
config = new FlexLayoutConfig(this);
}
FlexLayoutService::~FlexLayoutService() {}
QVariant FlexLayoutService::createNode(QVariant config) {
FlexLayoutConfig *object = qvariant_cast<FlexLayoutConfig *>(config);
QVariant result;
if (object == nullptr) {
qCritical() << "FlexLayoutService createNode config not FlexLayoutConfig*";
} else {
result = QVariant::fromValue(new FlexLayout(object, this));
}
return result;
}
void FlexLayoutService::collectGarbage(QVariant rootNode) {
FlexLayout *node = qvariant_cast<FlexLayout *>(rootNode);
if (node == nullptr) {
qCritical() << "FlexLayoutService collectGarbage node to FlexLayout*";
} else {
node->deleteLater();
}
}
QVariant FlexLayoutService::createConfig() {
return QVariant::fromValue(new FlexLayoutConfig(this));
}
QVariant FlexLayoutService::createNode() {
return QVariant::fromValue(new FlexLayout(config, this));
}