-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_group.cpp
More file actions
34 lines (28 loc) · 772 Bytes
/
object_group.cpp
File metadata and controls
34 lines (28 loc) · 772 Bytes
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
#include <QApplication>
#include "object_group.h"
#include "debug.h"
void object_group::add_to_group(QObject *object)
{
group.append(object);
connect(object, &QObject::destroyed, this, &object_group::remove_from_group);
if(object->metaObject()->indexOfSignal(QMetaObject::normalizedSignature("send_event(QEvent *)")) != -1){
connect(object, SIGNAL(send_event(QEvent *)), this, SLOT(distribute_event(QEvent *)));
}
}
void object_group::remove_from_group(QObject *object)
{
group.removeOne(object);
}
void object_group::distribute_static_result_event(QEvent *e)
{
if(group.size() > 0){
QApplication::sendEvent(group.first(), e);
}
}
bool object_group::event(QEvent *e)
{
for(auto &object : group){
QApplication::sendEvent(object, e);
}
return true;
}