%PYARG_0 = %CONVERTTOPYTHON[double](qAbs(%1)); namespace PySide { static QStack<PyObject*> globalPostRoutineFunctions; void globalPostRoutineCallback() { foreach(PyObject* callback, globalPostRoutineFunctions) { Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL)); Py_DECREF(callback); } globalPostRoutineFunctions.clear(); } void addPostRoutine(PyObject* callback) { if (PyCallable_Check(callback)) { globalPostRoutineFunctions << callback; Py_INCREF(callback); } else { PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object."); } } } // namespace PySide::addPostRoutine(%1); qAddPostRoutine(PySide::globalPostRoutineCallback); PySide::runCleanupFunctions(); Shiboken::TypeResolver::createValueTypeResolver<QString>("unicode"); Shiboken::TypeResolver::createValueTypeResolver<QString>("str"); PySide::init(module); Py_AtExit(QtCoreModuleExit); #include <pyside.h> // Define a global variable to handle qInstallMsgHandler callback static PyObject* qtmsghandler = 0; static void msgHandlerCallback(QtMsgType type, const char* msg) { Shiboken::GilState state; Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg)); Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); } static void QtCoreModuleExit() { PySide::SignalManager::instance().clear(); } if (%PYARG_1 == Py_None) { qInstallMsgHandler(0); %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; qtmsghandler = 0; } else if (!PyCallable_Check(%PYARG_1)) { PyErr_SetString(PyExc_TypeError, "parameter must be callable"); } else { %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; Py_INCREF(%PYARG_1); qtmsghandler = %PYARG_1; qInstallMsgHandler(msgHandlerCallback); } if (%PYARG_0 == Py_None) Py_INCREF(%PYARG_0); namespace PySide { template<> inline uint hash(const QLine& v) { return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2()))); } }; QPointF p; %RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, &p); %PYARG_0 = Shiboken::makeTuple(retval, p); Returns a read only buffer object pointing to the segment of data that this resource represents. If the resource is compressed the data returns is compressed and qUncompress() must be used to access the data. If the resource is a directory None is returned. const uchar* d = %CPPSELF.%FUNCTION_NAME(); if (d) { %PYARG_0 = PyBuffer_FromMemory(const_cast<uchar*>(d), %CPPSELF.size()); } else { Py_INCREF(Py_None); %PYARG_0 = Py_None; } int year, month, day; %CPPSELF.%FUNCTION_NAME(&year, &month, &day); %PYARG_0 = Shiboken::makeTuple(year, month, day); int yearNumber; int week = %CPPSELF.%FUNCTION_NAME(&yearNumber); %PYARG_0 = Shiboken::makeTuple(week, yearNumber); QDate date(%1, %2, %3); QTime time(%4, %5, %6, %7); %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); namespace PySide { template<> inline uint hash(const QPoint& v) { return qHash(qMakePair(v.x(), v.y())); } }; namespace PySide { template<> inline uint hash(const QRect& v) { return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height()))); } }; int a, b, c, d; %CPPSELF.%FUNCTION_NAME(&a, &b, &c, &d); %PYARG_0 = Shiboken::makeTuple(a, b, c, d); int a, b, c, d; %CPPSELF.%FUNCTION_NAME(&a, &b, &c, &d); %PYARG_0 = Shiboken::makeTuple(a, b, c, d); qreal a, b, c, d; %CPPSELF.%FUNCTION_NAME(&a, &b, &c, &d); %PYARG_0 = Shiboken::makeTuple(a, b, c, d); qreal a, b, c, d; %CPPSELF.%FUNCTION_NAME(&a, &b, &c, &d); %PYARG_0 = Shiboken::makeTuple(a, b, c, d); namespace PySide { template<> inline uint hash(const QSize& v) { return qHash(qMakePair(v.width(), v.height())); } }; %PYARG_0 = (PyObject*)%CPPSELF.%FUNCTION_NAME(); if (!%PYARG_0) %PYARG_0 = Py_None; Py_XINCREF(%PYARG_0); return %CPPSELF.size(); if (_i < 0 || _i >= %CPPSELF.size()) { PyErr_SetString(PyExc_IndexError, "index out of bounds"); return 0; } return %CONVERTTOPYTHON[bool](%CPPSELF.at(_i)); PyObject* args = Py_BuildValue("(iiO)", _i, 1, _value); PyObject* result = Sbk_QBitArrayFunc_setBit(self, args); Py_DECREF(args); Py_XDECREF(result); return !result ? -1 : 0; %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3)); Creates a model index for the given row and column with the internal pointer ptr. When using a QSortFilterProxyModel, its indexes have their own internal pointer. It is not advisable to access this internal pointer outside of the model. Use the data() function instead. This function provides a consistent interface that model subclasses must use to create model indexes. .. warning:: Because of some Qt/Python itegration rules, the ptr argument do not get the reference incremented during the QModelIndex life time. So it is necessary to keep the object used on ptr argument alive during the whole process. Do not destroy the object if you are not sure about that. %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %CPPSELF, %3, %4)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %3, %4, %5)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnectCallback(%1, %2, %PYARG_3, %4)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnectCallback(%CPPSELF, %1, %PYARG_2, %3)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%CPPSELF, %1, %2, %3, %4)); %PYARG_0 = %CONVERTTOPYTHON[bool](PySide::SignalManager::instance().emitSignal(%CPPSELF, %1, %PYARG_2)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectDisconnectCallback(%CPPSELF, %1, %2)); // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectDisconnectCallback(%1, %2, %3)); static bool qobjectInheritsInternal(PyTypeObject *objType, const char *class_name) { if (strcmp(objType->tp_name, class_name) == 0) return true; PyTypeObject* base = (objType)->tp_base; if (base == 0) return false; return qobjectInheritsInternal(base, class_name); } bool retval = qobjectInheritsInternal(self->ob_type, %1) ? true : %CPPSELF.%FUNCTION_NAME(%1); %PYARG_0 = %CONVERTTOPYTHON[bool](retval); %PYARG_0 = %CONVERTTOPYTHON[QObject*](_findChildHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1)); %PYARG_0 = PyList_New(0); _findChildrenHelper(%CPPSELF, %2, (PyTypeObject*)%PYARG_1, %PYARG_0); QString result; if (QCoreApplication::instance()) { PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); PyObject *cname = PyObject_GetAttrString(klass, "__name__"); result = QString(QCoreApplication::instance()->translate(PyString_AsString(cname), %1, %2, QCoreApplication::CodecForTr, %3)); Py_DECREF(klass); Py_DECREF(cname); } else { result = QString(QString::fromLatin1(%1)); } %PYARG_0 = %CONVERTTOPYTHON[QString](result); QString result; if (QCoreApplication::instance()) { PyObject *klass = PyObject_GetAttrString(%PYSELF, "__class__"); PyObject *cname = PyObject_GetAttrString(klass, "__name__"); result = QString(QCoreApplication::instance()->translate(PyString_AsString(cname), %1, %2, QCoreApplication::UnicodeUTF8, %3)); Py_DECREF(klass); Py_DECREF(cname); } else { result = QString(QString::fromLatin1(%1)); } %PYARG_0 = %CONVERTTOPYTHON[QString](result); // Avoid return +1 because SignalManager connect to "destroyed()" signal to control object timelife int ret = %CPPSELF.%FUNCTION_NAME(%1); if (ret > 0 && ((strcmp(%1, SIGNAL(destroyed())) == 0) || (strcmp(%1, SIGNAL(destroyed(QObject*))) == 0))) { if (PySide::SignalManager::instance().hasConnectionWith(%CPPSELF)) ret--; } %PYARG_0 = %CONVERTTOPYTHON[int](ret); <para>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL "http://bühler.example.com" would be sent to the server as "http://xn--bhler-kva.example.com/List%20of%20applicants.xml".</para> Replaces every occurrence of the regular expression in *sourceString* with *after*. Returns a new Python string with the modified contents. For example: :: s = "Banana" re = QRegExp("a[mn]") s = re.replace(s, "ox") # s == "Boxoxa" For regular expressions containing capturing parentheses, occurrences of \1, \2, ..., in *after* are replaced with rx.cap(1), cap(2), ... :: t = "A <i>bon mot</i>." re = QRegExp("<i>([^<]*)</i>") t = re.replace(t, "\\emph{\\1}") # t == "A \\emph{bon mot}." %1.replace(*%CPPSELF, %2); %PYARG_0 = %CONVERTTOPYTHON[QString](%1); PyObject* str = PyString_FromStringAndSize(%CPPSELF.constData(), %CPPSELF.size()); Py_DECREF(str); int size = PyString_GET_SIZE(pyargs[0]); %0 = new QByteArray(%1, size); #if PY_VERSION_HEX < 0x03000000 Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; #endif %PYARG_0 = PyString_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size()); char c = PyString_AS_STRING(%PYARG_1)[0]; if (c) { %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME(c)); } // %FUNCTION_NAME() - avoid generation of default function call %PYARG_0 = %CONVERTTOPYTHON[QByteArray](QByteArray(%1)); %PYARG_0 = PyString_FromString(%CPPSELF.data()); return %CPPSELF.count(); if (_i < 0 || _i >= %CPPSELF.size()) { PyErr_SetString(PyExc_IndexError, "index out of bounds"); return 0; } else { char res[2]; res[0] = %CPPSELF.at(_i); res[1] = 0; return PyString_FromString(res); } %CPPSELF.remove(_i, 1); PyObject* args = Py_BuildValue("(nO)", _i, _value); PyObject* result = Sbk_QByteArrayFunc_insert(self, args); Py_DECREF(args); Py_XDECREF(result); return !result ? -1 : 0; Py_ssize_t max = %CPPSELF.count(); _i1 = qBound(Py_ssize_t(0), _i1, max); _i2 = qBound(Py_ssize_t(0), _i2, max); if (_i1 >= _i2) return %CONVERTTOPYTHON[QByteArray](QByteArray()); return %CONVERTTOPYTHON[QByteArray](%CPPSELF.mid(_i1, _i2 - _i1)); QByteArray ba; ba.resize(%2); %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); memcpy(%1, ba.data(), ba.size()); long long %out = ba.size(); QByteArray ba; ba.resize(%2); %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); memcpy(data, ba.data(), ba.size()); long long %out = ba.size(); %CPPSELF.%FUNCTION_NAME(PyString_AS_STRING(%PYARG_1), PyString_GET_SIZE(%PYARG_1)); PyTypeObject* pyType = %PYARG_1->ob_type; if (pyType->tp_as_buffer && pyType->tp_as_buffer->bf_getreadbuffer && pyType->tp_as_buffer->bf_getsegcount(%PYARG_1, 0) == 1) { void* ptr; Py_ssize_t size = pyType->tp_as_buffer->bf_getreadbuffer(%PYARG_1, 0, &ptr); %PYARG_0 = %CONVERTTOPYTHON[bool](%CPPSELF.%FUNCTION_NAME(const_cast<const uchar*>((uchar*)ptr), size)); } else { PyErr_SetString(PyExc_TypeError, "The object must support buffer protocol with just one segment."); } // %FUNCTION_NAME() - disable generation of c++ function call (void) %2; // remove warning about unused variable Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); Shiboken::AutoDecRef result( PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsOs"), pyTimer, SIGNAL(timeout()), %PYARG_2, %3) ); Shiboken::Object::invalidate((SbkObject*)pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); timer->start(%1); // %FUNCTION_NAME() - disable generation of c++ function call Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); PyObject *pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); QTimer* timer = %CONVERTTOCPP[QTimer*](pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); if (PyObject_TypeCheck(%2, &PySideSignalInstanceType)) { PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%2); Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", PySide::Signal::getSignature(signalInstance))); Shiboken::AutoDecRef result( PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsOO"), pyTimer, SIGNAL(timeout()), PySide::Signal::getObject(signalInstance), signalSignature.object()) ); } else { Shiboken::AutoDecRef result( PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsO"), pyTimer, SIGNAL(timeout()), pyargs[1]) ); } Shiboken::Object::invalidate((SbkObject*)pyTimer); timer->start(%1); qint64 pid; %RETURN_TYPE retval = %TYPE::%FUNCTION_NAME(%1, %2, %3, &pid); %PYARG_0 = Shiboken::makeTuple(retval, pid); .. class:: QCoreApplication(args) Constructs a Qt kernel application. Kernel applications are applications without a graphical user interface. These type of applications are used at the console or as server processes. The *args* argument is processed by the application, and made available in a more convenient form by the :meth:`~QCoreApplication.arguments()` method. *(%CPPSELF) << %1; %RETURN_TYPE val; *(%CPPSELF) >> val; %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); *(%CPPSELF) << %1; %RETURN_TYPE val; *(%CPPSELF) >> val; %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); *(%CPPSELF) << %1; %RETURN_TYPE val; *(%CPPSELF) >> val; %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); *(%CPPSELF) << %1; %RETURN_TYPE val; *(%CPPSELF) >> val; %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); QByteArray data; data.resize(%2); int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size()); if (result == -1) { Py_INCREF(Py_None); %PYARG_0 = Py_None; } else { %PYARG_0 = PyString_FromStringAndSize(data.data(), result); } int r = %CPPSELF.%FUNCTION_NAME(%1, PyString_GET_SIZE(%PYARG_1)); %PYARG_0 = %CONVERTTOPYTHON[int](r); %PYARG_0 = (PyObject*)%CPPSELF.%FUNCTION_NAME(); if (!%PYARG_0) %PYARG_0 = Py_None; Py_XINCREF(%PYARG_0); for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](%CPPSELF.animationAt(counter)); Shiboken::Object::setParent(NULL, obj); Py_DECREF(obj); } %CPPSELF.clear(); if (PyObject_TypeCheck(%1, &PySideSignalInstanceType)) { PyObject* dataSource = PySide::Signal::getObject((PySideSignalInstance*) %PYARG_1); Shiboken::AutoDecRef obType(PyObject_Type(dataSource)); QObject* sender = %CONVERTTOCPP[QObject*](dataSource); if (sender) { const char* dataSignature = PySide::Signal::getSignature((PySideSignalInstance*) %PYARG_1); QByteArray signature(dataSignature); // Append SIGNAL flag (2) %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2); } } QString signalName(%2); if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toAscii().data(), QMetaMethod::Signal)) { %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->addTransition(%1, %2, %3)); } else { %PYARG_0 = Py_None; } // Obviously the label used by the following goto is a very awkward solution, // since it refers to a name very tied to the generator implementation. // Check bug #362 for more information on this // http://bugs.openbossa.org/show_bug.cgi?id=362 if (!PyObject_TypeCheck(%1, &PySideSignalInstanceType)) goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError; PySideSignalInstance* signalInstance = reinterpret_cast<PySideSignalInstance*>(%1); QObject* sender = %CONVERTTOCPP[QObject*](PySide::Signal::getObject(signalInstance)); %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition*](%CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance), %2)); %PYARG_0 = PySet_New(0); foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); Shiboken::Object::setParent(self, obj); PySet_Add(%PYARG_0, obj); } %PYARG_0 = PyList_New(0); foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); Shiboken::Object::setParent(self, obj); PyList_Append(%PYARG_0, obj); } %PYARG_0 = PyString_FromFormat("2%s", QMetaObject::normalizedSignature(%1).constData()); %PYARG_0 = PyString_FromFormat("1%s", QMetaObject::normalizedSignature(%1).constData()); extern bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); extern bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); %PYARG_0 = %CONVERTTOPYTHON[bool](%FUNCTION_NAME(%1, (uchar*)%2, (uchar*)%3, (uchar*)%4)); %PYARG_0 = %CONVERTTOPYTHON[bool](%FUNCTION_NAME(%1, (uchar*)%2, (uchar*)%3, (uchar*)%4));