41 lines
857 B
C
41 lines
857 B
C
|
#pragma once
|
|||
|
|
|||
|
#include <QObject>
|
|||
|
#include <unordered_map>
|
|||
|
#include <string>
|
|||
|
#include "EventModule.h"
|
|||
|
/**
|
|||
|
* @brief 消息分发器
|
|||
|
*/
|
|||
|
class WEBQT_EXPORT WebEventDispatch : public QObject
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
|
|||
|
public:
|
|||
|
/**
|
|||
|
* @brief WebEngineView 消息分发器
|
|||
|
* @param parent原生父类对象
|
|||
|
*/
|
|||
|
WebEventDispatch(QObject* parent);
|
|||
|
~WebEventDispatch();
|
|||
|
|
|||
|
signals:
|
|||
|
void signalToWeb(const QString& json); // QT给JS发送数据
|
|||
|
public slots:
|
|||
|
QString msgToQt(const QString& msg);
|
|||
|
/**
|
|||
|
* @brief 添加事件处理模块
|
|||
|
* @param eventModule 事件处理模块
|
|||
|
*/
|
|||
|
void addEventModule(EventModule* eventModule, bool deleted = true);
|
|||
|
private:
|
|||
|
struct EventData {
|
|||
|
EventModule* eventModule;
|
|||
|
bool deleted;
|
|||
|
};
|
|||
|
static void brostcastToWeb(const QString& json);
|
|||
|
std::unordered_map<std::string, EventData> _events;
|
|||
|
friend class EventModule;
|
|||
|
|
|||
|
};
|