3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "sig_mux.hpp"
25 SignalMultiplexer::SignalMultiplexer(QObject
*parent
) :
29 void SignalMultiplexer::connect(QObject
*sender
, const char *signal
, const char *slot
)
40 bool SignalMultiplexer::disconnect(QObject
*sender
, const char *signal
, const char *slot
)
42 QList
<Connection
>::Iterator it
;
43 for (it
= mConnections
.begin(); it
!= mConnections
.end(); ++it
) {
44 Connection conn
= *it
;
45 if ((QObject
*)conn
.sender
== sender
&&
46 qstrcmp(conn
.signal
, signal
) == 0 && qstrcmp(conn
.slot
, slot
) == 0) {
48 mConnections
.erase(it
);
55 void SignalMultiplexer::connect(const char *signal
, QObject
*receiver
, const char *slot
)
58 conn
.receiver
= receiver
;
66 bool SignalMultiplexer::disconnect(const char *signal
, QObject
*receiver
, const char *slot
)
68 QList
<Connection
>::Iterator it
;
69 for (it
= mConnections
.begin(); it
!= mConnections
.end(); ++it
) {
70 Connection conn
= *it
;
71 if ((QObject
*)conn
.receiver
== receiver
&&
72 qstrcmp(conn
.signal
, signal
) == 0 && qstrcmp(conn
.slot
, slot
) == 0) {
74 mConnections
.erase(it
);
81 void SignalMultiplexer::connect(const Connection
&conn
)
85 if (!conn
.sender
&& !conn
.receiver
)
89 QObject::connect((QObject
*)conn
.sender
, conn
.signal
, (QObject
*)mObject
, conn
.slot
);
91 QObject::connect((QObject
*)mObject
, conn
.signal
, (QObject
*)conn
.receiver
, conn
.slot
);
94 void SignalMultiplexer::disconnect(const Connection
&conn
)
98 if (!conn
.sender
&& !conn
.receiver
)
102 QObject::disconnect((QObject
*)conn
.sender
, conn
.signal
, (QObject
*)mObject
, conn
.slot
);
104 QObject::disconnect((QObject
*)mObject
, conn
.signal
, (QObject
*)conn
.receiver
, conn
.slot
);
108 void SignalMultiplexer::setCurrentObject(QObject
*newObject
)
110 if (newObject
== mObject
)
113 QList
<Connection
>::ConstIterator it
;
114 for (it
= mConnections
.begin(); it
!= mConnections
.end(); ++it
)
117 for (it
= mConnections
.begin(); it
!= mConnections
.end(); ++it
)