18
#include "SignalMultiplexer.h"
20
#include "core/Global.h"
22
SignalMultiplexer::SignalMultiplexer() = default;
24
SignalMultiplexer::~SignalMultiplexer()
27
setCurrentObject(nullptr);
30
QObject* SignalMultiplexer::currentObject() const
32
return m_currentObject;
35
void SignalMultiplexer::setCurrentObject(QObject* object)
38
QMutableListIterator<Connection> i = m_connections;
40
const Connection& con = i.next();
42
if (!con.sender && !con.receiver) {
47
if (m_currentObject) {
48
for (const Connection& con : asConst(m_connections)) {
53
m_currentObject = object;
56
for (const Connection& con : asConst(m_connections)) {
62
void SignalMultiplexer::connect(QObject* sender, const char* signal, const char* slot)
72
if (m_currentObject) {
77
void SignalMultiplexer::connect(const char* signal, QObject* receiver, const char* slot)
82
con.receiver = receiver;
87
if (m_currentObject) {
92
void SignalMultiplexer::disconnect(QObject* sender, const char* signal, const char* slot)
96
QMutableListIterator<Connection> i = m_connections;
98
const Connection& con = i.next();
100
if (con.sender == sender && qstrcmp(con.signal, signal) == 0 && qstrcmp(con.slot, slot) == 0) {
101
if (m_currentObject) {
109
void SignalMultiplexer::disconnect(const char* signal, QObject* receiver, const char* slot)
113
QMutableListIterator<Connection> i = m_connections;
114
while (i.hasNext()) {
115
const Connection& con = i.next();
117
if (con.receiver == receiver && qstrcmp(con.signal, signal) == 0 && qstrcmp(con.slot, slot) == 0) {
118
if (m_currentObject) {
126
void SignalMultiplexer::connect(const Connection& con)
128
Q_ASSERT(con.sender || con.receiver);
131
QObject::connect(con.sender, con.signal, m_currentObject, con.slot);
133
QObject::connect(m_currentObject, con.signal, con.receiver, con.slot);
137
void SignalMultiplexer::disconnect(const Connection& con)
139
Q_ASSERT(con.sender || con.receiver);
142
QObject::disconnect(con.sender, con.signal, m_currentObject, con.slot);
144
QObject::disconnect(m_currentObject, con.signal, con.receiver, con.slot);