2021-02-08 11:37:51 +08:00
|
|
|
#ifndef DORICVIEWNODE_H
|
|
|
|
#define DORICVIEWNODE_H
|
|
|
|
|
2021-04-02 20:47:15 +08:00
|
|
|
#include <QJsonObject>
|
2021-04-06 11:19:48 +08:00
|
|
|
#include <QJsonValue>
|
|
|
|
#include <QQuickItem>
|
2021-02-09 15:54:22 +08:00
|
|
|
|
2021-02-08 11:37:51 +08:00
|
|
|
#include "../utils/DoricContextHolder.h"
|
2021-04-13 21:14:17 +08:00
|
|
|
#include "../utils/DoricLayouts.h"
|
2021-04-06 11:19:48 +08:00
|
|
|
|
2021-02-19 15:43:09 +08:00
|
|
|
class DoricSuperNode;
|
|
|
|
|
2021-02-08 11:37:51 +08:00
|
|
|
class DoricViewNode : public DoricContextHolder {
|
2021-02-09 15:54:22 +08:00
|
|
|
|
|
|
|
protected:
|
2021-02-19 10:04:54 +08:00
|
|
|
QQuickItem *mView;
|
2021-02-09 15:54:22 +08:00
|
|
|
|
2021-04-13 21:14:17 +08:00
|
|
|
DoricLayouts *mLayouts = nullptr;
|
|
|
|
|
2021-02-19 10:04:54 +08:00
|
|
|
virtual QQuickItem *build() = 0;
|
2021-02-09 15:54:22 +08:00
|
|
|
|
2021-04-13 21:14:17 +08:00
|
|
|
void createLayouts(QQuickItem *view);
|
|
|
|
|
|
|
|
DoricLayouts *getLayouts();
|
|
|
|
|
2021-04-02 20:47:15 +08:00
|
|
|
void setLayoutConfig(QJsonValue layoutConfig);
|
2021-02-19 15:43:09 +08:00
|
|
|
|
2021-02-09 15:54:22 +08:00
|
|
|
private:
|
|
|
|
QString mId;
|
2021-03-15 15:30:17 +08:00
|
|
|
|
2021-03-19 18:02:17 +08:00
|
|
|
QList<QString> getIdList();
|
|
|
|
|
|
|
|
QString clickFunction;
|
|
|
|
|
2021-02-08 11:37:51 +08:00
|
|
|
public:
|
2021-03-15 15:30:17 +08:00
|
|
|
QString mType;
|
|
|
|
|
2021-04-23 17:56:08 +08:00
|
|
|
DoricSuperNode *mSuperNode = nullptr;
|
|
|
|
|
2021-02-08 11:37:51 +08:00
|
|
|
using DoricContextHolder::DoricContextHolder;
|
2021-02-19 15:43:09 +08:00
|
|
|
|
|
|
|
void init(DoricSuperNode *superNode);
|
|
|
|
|
2021-02-22 16:42:19 +08:00
|
|
|
static DoricViewNode *create(DoricContext *context, QString type) {
|
|
|
|
bool classRegistered =
|
|
|
|
context->getDriver()->getRegistry()->acquireNodeInfo(type);
|
|
|
|
if (classRegistered) {
|
|
|
|
QObject *node =
|
|
|
|
context->getDriver()->getRegistry()->nodes.createObject(type);
|
|
|
|
DoricViewNode *castNode = dynamic_cast<DoricViewNode *>(node);
|
|
|
|
castNode->setContext(context);
|
|
|
|
castNode->mType = type;
|
|
|
|
return castNode;
|
|
|
|
} else {
|
2021-04-22 21:20:36 +08:00
|
|
|
qCritical() << "DoricViewNode create error: " + type;
|
2021-02-22 16:42:19 +08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-19 15:43:09 +08:00
|
|
|
QString getId();
|
|
|
|
|
|
|
|
void setId(QString id);
|
|
|
|
|
2021-02-22 16:42:19 +08:00
|
|
|
QString getType();
|
|
|
|
|
|
|
|
QQuickItem *getNodeView();
|
|
|
|
|
2021-04-02 20:47:15 +08:00
|
|
|
virtual void blend(QJsonValue jsValue);
|
2021-02-19 19:01:31 +08:00
|
|
|
|
2021-04-02 20:47:15 +08:00
|
|
|
virtual void blend(QQuickItem *view, QString name, QJsonValue prop);
|
2021-03-02 17:18:23 +08:00
|
|
|
|
2021-04-13 21:14:17 +08:00
|
|
|
virtual void afterBlended(QJsonValue prop);
|
|
|
|
|
2021-04-02 20:47:15 +08:00
|
|
|
virtual void blendLayoutConfig(QJsonValue jsObject);
|
2021-03-19 18:02:17 +08:00
|
|
|
|
2021-04-13 21:14:17 +08:00
|
|
|
virtual void requestLayout();
|
|
|
|
|
2021-03-19 18:02:17 +08:00
|
|
|
void onClick();
|
|
|
|
|
2021-05-12 11:08:40 +08:00
|
|
|
std::shared_ptr<DoricAsyncResult> callJSResponse(QString funcId,
|
|
|
|
QVariantList args);
|
2021-05-10 16:09:29 +08:00
|
|
|
|
2021-05-12 11:08:40 +08:00
|
|
|
std::shared_ptr<DoricAsyncResult> pureCallJSResponse(QString funcId,
|
|
|
|
QVariantList args);
|
2021-02-08 11:37:51 +08:00
|
|
|
};
|
|
|
|
#endif // DORICVIEWNODE_H
|