summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-28 11:18:11 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-28 14:57:40 -0300
commit363ecb3461c54451c4766202a2eaaf95326a9d39 (patch)
tree3d6a9e50bf2cda2caae2bbf4cf1801e5d0b1eb72 /libpyside
parentff03bd56ffd25c7f5f600772b393ce660494a351 (diff)
downloadpyside-363ecb3461c54451c4766202a2eaaf95326a9d39.tar.gz
pyside-363ecb3461c54451c4766202a2eaaf95326a9d39.tar.xz
pyside-363ecb3461c54451c4766202a2eaaf95326a9d39.zip
Implemented Signal constructor base on QMethod list.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/qsignal.cpp27
-rw-r--r--libpyside/qsignal.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp
index f3ecc4b..23ee7ff 100644
--- a/libpyside/qsignal.cpp
+++ b/libpyside/qsignal.cpp
@@ -608,6 +608,33 @@ bool signalConnect(PyObject* source, const char* signal, PyObject* callback)
return PyObject_CallObject(pyMethod, pyArgs);
}
+PyObject* signalNewFromMethod(PyObject* source, const QList<QMetaMethod>& methodList)
+{
+ PySideSignalInstanceData *root = 0;
+ PySideSignalInstanceData *previous = 0;
+ foreach(QMetaMethod m, methodList) {
+ PySideSignalInstanceData *item = PyObject_New(PySideSignalInstanceData, &PySideSignalInstanceType);
+ if (!root)
+ root = item;
+
+ if (previous)
+ previous->d->next = reinterpret_cast<PyObject*>(item);
+
+ item->d = new PySideSignalInstanceDataPrivate;
+ PySideSignalInstanceDataPrivate* selfPvt = item->d;
+ selfPvt->source = source;
+ const char* cppSignature = m.signature();
+ // separe SignalName
+ selfPvt->signalName = strdup(cppSignature);
+ char* endName = strchr(selfPvt->signalName, '(');
+ endName = '\0';
+ selfPvt->signature = strdup(cppSignature);
+ selfPvt->homonymousMethod = 0;
+ selfPvt->next = 0;
+ }
+ return reinterpret_cast<PyObject*>(root);
+}
+
PyObject* signalNew(const char* name, ...)
{
va_list listSignatures;
diff --git a/libpyside/qsignal.h b/libpyside/qsignal.h
index 9f17360..4bbf841 100644
--- a/libpyside/qsignal.h
+++ b/libpyside/qsignal.h
@@ -48,6 +48,7 @@ namespace PySide
{
PYSIDE_API PyObject* signalNew(const char* name, ...);
+PYSIDE_API PyObject* signalNewFromMethod(PyObject* source, const QList<QMetaMethod>& method);
PYSIDE_API void signalUpdateSource(PyObject* source);
PYSIDE_API void addSignalToWrapper(Shiboken::SbkBaseWrapperType* wrapperType, const char* signalName, PyObject* signal);
PYSIDE_API PyObject* getSignalSource(PySideSignalInstanceData* signal);