summaryrefslogtreecommitdiffstats
path: root/src/script/qscriptextqobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-25 15:25:48 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-25 15:32:13 (GMT)
commit47c9e7b1b3551ff6dbe71590461a45ae398a9501 (patch)
treef965ed1cb23bbdb2116dfba945e44b1d2dfc2532 /src/script/qscriptextqobject.cpp
parent3984253ac58e0cca1c0b94fad1549dd4e0e3c2e1 (diff)
downloadQt-47c9e7b1b3551ff6dbe71590461a45ae398a9501.zip
Qt-47c9e7b1b3551ff6dbe71590461a45ae398a9501.tar.gz
Qt-47c9e7b1b3551ff6dbe71590461a45ae398a9501.tar.bz2
make it possible to support queued connections in qtscript
This change doesn't actually add public API for it, but makes it trivial to add. On the C++ side, qScriptConnect() would get an overload that takes an additional argument, the connection type (d'oh, it should have had a default argument to begin with!). On the script side, it's a bit more tricky to "overload" the existing connect(), since it's already "overloaded" (can have either one or two parameters). Plus, I'd like connect() to be able to support bind-like functionality so you can pass additional arguments to it that will be passed to the signal handler at signal emission time. Oh well, we'll see.
Diffstat (limited to 'src/script/qscriptextqobject.cpp')
-rw-r--r--src/script/qscriptextqobject.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp
index 00963a7..a3cb4e6 100644
--- a/src/script/qscriptextqobject.cpp
+++ b/src/script/qscriptextqobject.cpp
@@ -1420,7 +1420,8 @@ public:
bool addSignalHandler(QObject *sender, int signalIndex,
const QScriptValueImpl &receiver,
const QScriptValueImpl &slot,
- const QScriptValueImpl &senderWrapper = QScriptValueImpl());
+ const QScriptValueImpl &senderWrapper,
+ Qt::ConnectionType type);
bool removeSignalHandler(
QObject *sender, int signalIndex,
const QScriptValueImpl &receiver,
@@ -1741,13 +1742,14 @@ void QScript::QObjectConnectionManager::mark(int generation)
bool QScript::QObjectConnectionManager::addSignalHandler(
QObject *sender, int signalIndex, const QScriptValueImpl &receiver,
- const QScriptValueImpl &function, const QScriptValueImpl &senderWrapper)
+ const QScriptValueImpl &function, const QScriptValueImpl &senderWrapper,
+ Qt::ConnectionType type)
{
if (connections.size() <= signalIndex)
connections.resize(signalIndex+1);
QVector<QObjectConnection> &cs = connections[signalIndex];
int absSlotIndex = m_slotCounter + metaObject()->methodOffset();
- bool ok = QMetaObject::connect(sender, signalIndex, this, absSlotIndex);
+ bool ok = QMetaObject::connect(sender, signalIndex, this, absSlotIndex, type);
if (ok) {
cs.append(QScript::QObjectConnection(m_slotCounter++, receiver, function, senderWrapper));
QMetaMethod signal = sender->metaObject()->method(signalIndex);
@@ -2176,12 +2178,13 @@ bool QScriptQObjectData::addSignalHandler(QObject *sender,
int signalIndex,
const QScriptValueImpl &receiver,
const QScriptValueImpl &slot,
- const QScriptValueImpl &senderWrapper)
+ const QScriptValueImpl &senderWrapper,
+ Qt::ConnectionType type)
{
if (!m_connectionManager)
m_connectionManager = new QScript::QObjectConnectionManager();
return m_connectionManager->addSignalHandler(
- sender, signalIndex, receiver, slot, senderWrapper);
+ sender, signalIndex, receiver, slot, senderWrapper, type);
}
bool QScriptQObjectData::removeSignalHandler(QObject *sender,