2021-02-04 16:59:58 +08:00
|
|
|
#ifndef CONTEXT_H
|
|
|
|
#define CONTEXT_H
|
|
|
|
|
2021-06-09 16:46:33 +08:00
|
|
|
#include <QQmlApplicationEngine>
|
2021-02-04 16:59:58 +08:00
|
|
|
#include <QVariant>
|
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
#include "DoricExport.h"
|
|
|
|
|
2021-02-04 16:59:58 +08:00
|
|
|
#include "DoricInterfaceDriver.h"
|
2021-02-09 17:42:11 +08:00
|
|
|
|
2021-02-23 18:26:00 +08:00
|
|
|
class DoricViewNode;
|
2021-02-09 17:42:11 +08:00
|
|
|
class DoricRootNode;
|
2021-02-04 16:59:58 +08:00
|
|
|
|
2021-05-18 16:15:28 +08:00
|
|
|
class DORIC_EXPORT DoricContext {
|
2021-02-04 16:59:58 +08:00
|
|
|
private:
|
|
|
|
QString mContextId;
|
|
|
|
QMap<QString, QObject *> mPluginMap;
|
|
|
|
DoricRootNode *mRootNode;
|
|
|
|
QString source;
|
|
|
|
QString script;
|
|
|
|
QString extra;
|
|
|
|
QVariant initParams;
|
|
|
|
DoricInterfaceDriver *driver = NULL;
|
2021-06-09 16:46:33 +08:00
|
|
|
QQmlApplicationEngine *mQmlEngine;
|
2021-02-04 16:59:58 +08:00
|
|
|
|
2021-04-22 20:46:00 +08:00
|
|
|
QMap<QString, QMap<QString, DoricViewNode *>> mHeadNodes;
|
|
|
|
|
2021-02-04 16:59:58 +08:00
|
|
|
public:
|
|
|
|
DoricContext(QString contextId, QString source, QString extra);
|
|
|
|
|
2021-04-09 16:39:43 +08:00
|
|
|
~DoricContext();
|
|
|
|
|
2021-02-04 16:59:58 +08:00
|
|
|
static DoricContext *create(QString script, QString source, QString extra);
|
|
|
|
|
|
|
|
void init(QString initData);
|
|
|
|
|
|
|
|
void build(int width, int height);
|
|
|
|
|
2021-05-12 11:08:40 +08:00
|
|
|
std::shared_ptr<DoricAsyncResult> callEntity(QString methodName,
|
|
|
|
QVariantList args);
|
2021-02-04 16:59:58 +08:00
|
|
|
|
|
|
|
DoricInterfaceDriver *getDriver();
|
|
|
|
|
2021-02-09 10:38:27 +08:00
|
|
|
DoricRootNode *getRootNode();
|
|
|
|
|
2021-02-04 16:59:58 +08:00
|
|
|
QObject *obtainPlugin(QString name);
|
2021-02-23 14:28:08 +08:00
|
|
|
|
2021-06-09 16:46:33 +08:00
|
|
|
void setQmlEngine(QQmlApplicationEngine *engine);
|
2021-02-23 14:28:08 +08:00
|
|
|
|
2021-06-09 16:46:33 +08:00
|
|
|
QQmlApplicationEngine *getQmlEngine();
|
2021-02-23 18:26:00 +08:00
|
|
|
|
|
|
|
DoricViewNode *targetViewNode(QString id);
|
2021-04-09 16:39:43 +08:00
|
|
|
|
|
|
|
QString getContextId();
|
2021-04-22 20:46:00 +08:00
|
|
|
|
|
|
|
QList<DoricViewNode *> allHeadNodes(QString type);
|
|
|
|
|
|
|
|
void addHeadNode(QString type, DoricViewNode *viewNode);
|
|
|
|
|
|
|
|
void removeHeadNode(QString type, DoricViewNode *viewNode);
|
|
|
|
|
|
|
|
void clearHeadNodes(QString type);
|
2021-02-04 16:59:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONTEXT_H
|