| 49 | } |
| 50 | |
| 51 | ElaEventBusType::EventBusReturnType ElaEventBus::post(const QString& eventName, const QVariantMap& data) |
| 52 | { |
| 53 | Q_D(ElaEventBus); |
| 54 | if (eventName.isEmpty()) |
| 55 | { |
| 56 | return ElaEventBusType::EventBusReturnType::EventNameInvalid; |
| 57 | } |
| 58 | if (d->_eventMap.contains(eventName)) |
| 59 | { |
| 60 | QList<ElaEvent*> eventList = d->_eventMap.value(eventName); |
| 61 | foreach (auto event, eventList) |
| 62 | { |
| 63 | if (event->parent()) |
| 64 | { |
| 65 | QMetaObject::invokeMethod(event->parent(), event->getFunctionName().toLocal8Bit().constData(), event->getConnectionType(), Q_ARG(QVariantMap, data)); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | return ElaEventBusType::EventBusReturnType::Success; |
| 70 | } |
| 71 | |
| 72 | QStringList ElaEventBus::getRegisteredEventsName() const |
| 73 | { |