24
24
#include "pyside.h"
25
25
#include "signalmanager.h"
26
26
#include "qproperty.h"
28
#include <basewrapper.h>
29
#include <conversions.h>
28
34
extern "C" void init_signal(PyObject* module);
29
35
extern "C" void init_slot(PyObject* module);
30
36
extern "C" void init_qproperty(PyObject* module);
38
static QStack<PySide::CleanupFunction> cleanupFunctionList;
41
49
SignalManager::instance();
52
bool fillQtProperties(PyObject* qObj, const QMetaObject* metaObj, PyObject* kwds, const char** blackList, unsigned int blackListSize)
55
PyObject *key, *value;
58
while (PyDict_Next(kwds, &pos, &key, &value)) {
59
if (!blackListSize || !std::binary_search(blackList, blackList + blackListSize, std::string(PyString_AS_STRING(key)))) {
60
QByteArray propName(PyString_AS_STRING(key));
61
if (metaObj->indexOfProperty(propName) != -1) {
62
propName[0] = std::toupper(propName[0]);
63
propName.prepend("set");
65
Shiboken::AutoDecRef propSetter(PyObject_GetAttrString(qObj, propName.constData()));
66
if (!propSetter.isNull()) {
67
Shiboken::AutoDecRef args(PyTuple_Pack(1, value));
68
Shiboken::AutoDecRef retval(PyObject_CallObject(propSetter, args));
70
PyObject* attr = PyObject_GenericGetAttr(qObj, key);
71
if (isQPropertyType(attr))
72
PySide::qproperty_set(attr, qObj, value);
75
propName.append("()");
76
if (metaObj->indexOfSignal(propName) != -1) {
77
propName.prepend('2');
78
PySide::signal_connect(qObj, propName, value);
80
PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", propName.constData());
89
void registerCleanupFunction(CleanupFunction func)
91
cleanupFunctionList.push(func);
94
void runCleanupFunctions()
96
while (!cleanupFunctionList.isEmpty()) {
97
CleanupFunction f = cleanupFunctionList.pop();
44
102
} //namespace PySide