FluentUI/src/FluEventBus.cpp

24 lines
529 B
C++
Raw Normal View History

2023-09-11 18:10:50 +08:00
#include "FluEventBus.h"
2023-09-13 15:11:22 +08:00
FluEvent::FluEvent(QObject *parent):QObject{parent}{
2023-09-11 18:10:50 +08:00
}
2023-09-13 15:11:22 +08:00
FluEventBus::FluEventBus(QObject *parent):QObject{parent}{
2023-09-11 18:10:50 +08:00
}
void FluEventBus::registerEvent(FluEvent* event){
2023-09-13 15:11:22 +08:00
_eventData.append(event);
2023-09-11 18:10:50 +08:00
}
void FluEventBus::unRegisterEvent(FluEvent* event){
2023-09-13 15:11:22 +08:00
_eventData.removeOne(event);
2023-09-11 18:10:50 +08:00
}
void FluEventBus::post(const QString& name,const QMap<QString, QVariant>& data){
2023-09-13 15:11:22 +08:00
foreach (auto event, _eventData) {
2023-09-11 18:10:50 +08:00
if(event->name()==name){
Q_EMIT event->triggered(data);
}
}
}