-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notificator.cpp
37 lines (30 loc) · 929 Bytes
/
Notificator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "Notificator.hpp"
Notificator::Notificator() {
}
Notificator::~Notificator() {
for (Module* temp : this->modules) {
delete temp;
temp = nullptr;
}
}
Notificator* Notificator::getInstance() {
if (Notificator::instance == nullptr) {
Notificator::instance = new Notificator;
}
return Notificator::instance;
}
void Notificator::registerModule(Module* module) {
this->modules.push_back(module);
this->connections.insert({module, QObject::connect(module, &Module::emitting, this, &Notificator::notifyOnEvent)});
}
void Notificator::unregisterModule(Module* module) {
if (this->connections.count(module)) {
QObject::disconnect(this->connections[module]);
}
}
void Notificator::notifyOnEvent(Actions action) {
for (Module* module : this->modules) {
module->actionOnModuleEmitting(action);
}
emit notificatorRegisteredEmit(action);
}