1// qobject.sip generated by MetaSIP
2//
3// This file is part of the QtCore Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23typedef QList<QObject *> QObjectList;
24
25class QObject /Supertype=sip.wrapper/
26{
27%TypeHeaderCode
28#include <qobject.h>
29%End
30
31%TypeCode
32// This is needed by the tr() handwritten implementation.
33#include <qcoreapplication.h>
34
35
36// These are the helper functions for QObject::findChild() and
37// QObject::findChildren.
38
39// Wrap the given type in a 1-tuple.
40static PyObject *qtcore_type_to_tuple(PyObject *type)
41{
42    PyObject *tuple = PyTuple_New(1);
43
44    if (tuple)
45    {
46        Py_INCREF(type);
47        PyTuple_SetItem(tuple, 0, type);
48    }
49
50    return tuple;
51}
52
53
54// Check all elements of a given tuple are type objects and return a new
55// reference to the tuple if so.
56static PyObject *qtcore_check_tuple_types(PyObject *types)
57{
58    for (Py_ssize_t i = 0; i < PyTuple_Size(types); ++i)
59        if (!PyObject_TypeCheck(PyTuple_GetItem(types, i), &PyType_Type))
60        {
61            PyErr_SetString(PyExc_TypeError,
62                    "all elements of the types argument must be type objects");
63            return 0;
64        }
65
66    Py_INCREF(types);
67    return types;
68}
69
70
71// Do the main work of finding a child.
72static PyObject *qtcore_do_find_child(const QObject *parent, PyObject *types, const QString &name, Qt::FindChildOptions options)
73{
74    const QObjectList &children = parent->children();
75    int i;
76
77    for (i = 0; i < children.size(); ++i)
78    {
79        QObject *obj = children.at(i);
80        PyObject *pyo = sipConvertFromType(obj, sipType_QObject, 0);
81
82        if (!pyo)
83            return 0;
84
85        // Allow for proxies.
86        QObject *resolved = reinterpret_cast<QObject *>(sipGetAddress((sipSimpleWrapper *)pyo));
87
88        if (name.isNull() || resolved->objectName() == name)
89            for (Py_ssize_t t = 0; t < PyTuple_Size(types); ++t)
90                if (PyType_IsSubtype(Py_TYPE(pyo), (PyTypeObject *)PyTuple_GetItem(types, t)))
91                    return pyo;
92
93        Py_DECREF(pyo);
94    }
95
96    if (options == Qt::FindChildrenRecursively)
97        for (i = 0; i < children.size(); ++i)
98        {
99            PyObject *pyo = qtcore_do_find_child(children.at(i), types, name, options);
100
101            if (pyo != Py_None)
102                return pyo;
103
104            Py_DECREF(pyo);
105        }
106
107    Py_INCREF(Py_None);
108    return Py_None;
109}
110
111
112// Find a child that is one of a number of types and with an optional name.
113static PyObject *qtcore_FindChild(const QObject *parent, PyObject *types, const QString &name, Qt::FindChildOptions options)
114{
115    // Check that the types checking was successful.
116    if (!types)
117        return 0;
118
119    PyObject *child = qtcore_do_find_child(parent, types, name, options);
120
121    Py_DECREF(types);
122
123    return child;
124}
125
126
127// Do the main work of finding the children with a string name.
128static bool qtcore_do_find_children(const QObject *parent, PyObject *types, const QString &name, Qt::FindChildOptions options, PyObject *list)
129{
130    const QObjectList &children = parent->children();
131    int i;
132
133    for (i = 0; i < children.size(); ++i)
134    {
135        QObject *obj = children.at(i);
136        PyObject *pyo = sipConvertFromType(obj, sipType_QObject, 0);
137
138        if (!pyo)
139            return false;
140
141        // Allow for proxies.
142        QObject *resolved = reinterpret_cast<QObject *>(sipGetAddress((sipSimpleWrapper *)pyo));
143
144        if (name.isNull() || resolved->objectName() == name)
145            for (Py_ssize_t t = 0; t < PyTuple_Size(types); ++t)
146                if (PyType_IsSubtype(Py_TYPE(pyo), (PyTypeObject *)PyTuple_GetItem(types, t)))
147                    if (PyList_Append(list, pyo) < 0)
148                    {
149                        Py_DECREF(pyo);
150                        return false;
151                    }
152
153        Py_DECREF(pyo);
154
155        if (options == Qt::FindChildrenRecursively)
156        {
157            bool ok = qtcore_do_find_children(obj, types, name, options, list);
158
159            if (!ok)
160                return false;
161        }
162    }
163
164    return true;
165}
166
167
168// Find a child that is one of a number of types and with an optional string
169// name.
170static PyObject *qtcore_FindChildren(const QObject *parent, PyObject *types, const QString &name, Qt::FindChildOptions options)
171{
172    // Check that the types checking was successful.
173    if (!types)
174        return 0;
175
176    PyObject *list = PyList_New(0);
177
178    if (list)
179        if (!qtcore_do_find_children(parent, types, name, options, list))
180            Py_DECREF(list);
181
182    Py_DECREF(types);
183
184    return list;
185}
186
187
188// Do the main work of finding the children with a QRegExp name.
189static bool qtcore_do_find_children(const QObject *parent, PyObject *types, const QRegExp &re, Qt::FindChildOptions options, PyObject *list)
190{
191    const QObjectList &children = parent->children();
192    int i;
193
194    for (i = 0; i < children.size(); ++i)
195    {
196        QObject *obj = children.at(i);
197        PyObject *pyo = sipConvertFromType(obj, sipType_QObject, 0);
198
199        if (!pyo)
200            return false;
201
202        if (re.indexIn(obj->objectName()) >= 0)
203            for (Py_ssize_t t = 0; t < PyTuple_Size(types); ++t)
204                if (PyType_IsSubtype(Py_TYPE(pyo), (PyTypeObject *)PyTuple_GetItem(types, t)))
205                    if (PyList_Append(list, pyo) < 0)
206                    {
207                        Py_DECREF(pyo);
208                        return false;
209                    }
210
211        Py_DECREF(pyo);
212
213        if (options == Qt::FindChildrenRecursively)
214        {
215            bool ok = qtcore_do_find_children(obj, types, re, options, list);
216
217            if (!ok)
218                return false;
219        }
220    }
221
222    return true;
223}
224
225
226// Find a child that is one of a number of types and with an optional QRegExp
227// name.
228static PyObject *qtcore_FindChildren(const QObject *parent, PyObject *types, const QRegExp &re, Qt::FindChildOptions options)
229{
230    // Check that the types checking was successful.
231    if (!types)
232        return 0;
233
234    PyObject *list = PyList_New(0);
235
236    if (list)
237        if (!qtcore_do_find_children(parent, types, re, options, list))
238            Py_DECREF(list);
239
240    Py_DECREF(types);
241
242    return list;
243}
244
245
246// Do the main work of finding the children with a QRegularExpression name.
247static bool qtcore_do_find_children(const QObject *parent, PyObject *types, const QRegularExpression &re, Qt::FindChildOptions options, PyObject *list)
248{
249    const QObjectList &children = parent->children();
250    int i;
251
252    for (i = 0; i < children.size(); ++i)
253    {
254        QObject *obj = children.at(i);
255        PyObject *pyo = sipConvertFromType(obj, sipType_QObject, 0);
256
257        if (!pyo)
258            return false;
259
260        QRegularExpressionMatch m = re.match(obj->objectName());
261
262        if (m.hasMatch())
263            for (Py_ssize_t t = 0; t < PyTuple_Size(types); ++t)
264                if (PyType_IsSubtype(Py_TYPE(pyo), (PyTypeObject *)PyTuple_GetItem(types, t)))
265                    if (PyList_Append(list, pyo) < 0)
266                    {
267                        Py_DECREF(pyo);
268                        return false;
269                    }
270
271        Py_DECREF(pyo);
272
273        if (options == Qt::FindChildrenRecursively)
274        {
275            bool ok = qtcore_do_find_children(obj, types, re, options, list);
276
277            if (!ok)
278                return false;
279        }
280    }
281
282    return true;
283}
284
285
286// Find a child that is one of a number of types and with an optional
287// QRegularExpression name.
288static PyObject *qtcore_FindChildren(const QObject *parent, PyObject *types, const QRegularExpression &re, Qt::FindChildOptions options)
289{
290    // Check that the types checking was successful.
291    if (!types)
292        return 0;
293
294    PyObject *list = PyList_New(0);
295
296    if (list)
297        if (!qtcore_do_find_children(parent, types, re, options, list))
298            Py_DECREF(list);
299
300    Py_DECREF(types);
301
302    return list;
303}
304%End
305
306%FinalisationCode
307    return qpycore_qobject_finalisation(sipSelf, sipCpp, sipKwds, sipUnused);
308%End
309
310%ConvertToSubClassCode
311    static struct class_graph {
312        const char *name;
313        sipTypeDef **type;
314        int yes, no;
315    } graph[] = {
316        {sipName_QAbstractAnimation, &sipType_QAbstractAnimation, 25, 1},
317        {sipName_QAbstractEventDispatcher, &sipType_QAbstractEventDispatcher, -1, 2},
318        {sipName_QAbstractItemModel, &sipType_QAbstractItemModel, 31, 3},
319        {sipName_QAbstractState, &sipType_QAbstractState, 39, 4},
320        {sipName_QAbstractTransition, &sipType_QAbstractTransition, 43, 5},
321        {sipName_QIODevice, &sipType_QIODevice, 45, 6},
322        {sipName_QCoreApplication, &sipType_QCoreApplication, -1, 7},
323        {sipName_QEventLoop, &sipType_QEventLoop, -1, 8},
324    #if QT_VERSION >= 0x050200
325        {sipName_QFileSelector, &sipType_QFileSelector, -1, 9},
326    #else
327        {0, 0, -1, 9},
328    #endif
329        {sipName_QFileSystemWatcher, &sipType_QFileSystemWatcher, -1, 10},
330        {sipName_QItemSelectionModel, &sipType_QItemSelectionModel, -1, 11},
331        {sipName_QLibrary, &sipType_QLibrary, -1, 12},
332        {sipName_QMimeData, &sipType_QMimeData, -1, 13},
333        {sipName_QObjectCleanupHandler, &sipType_QObjectCleanupHandler, -1, 14},
334        {sipName_QPluginLoader, &sipType_QPluginLoader, -1, 15},
335        {sipName_QSettings, &sipType_QSettings, -1, 16},
336        {sipName_QSharedMemory, &sipType_QSharedMemory, -1, 17},
337        {sipName_QSignalMapper, &sipType_QSignalMapper, -1, 18},
338        {sipName_QSocketNotifier, &sipType_QSocketNotifier, -1, 19},
339        {sipName_QThread, &sipType_QThread, -1, 20},
340        {sipName_QThreadPool, &sipType_QThreadPool, -1, 21},
341        {sipName_QTimeLine, &sipType_QTimeLine, -1, 22},
342        {sipName_QTimer, &sipType_QTimer, -1, 23},
343        {sipName_QTranslator, &sipType_QTranslator, -1, 24},
344    #if defined(Q_OS_WIN)
345        {sipName_QWinEventNotifier, &sipType_QWinEventNotifier, -1, -1},
346    #else
347        {0, 0, -1, -1},
348    #endif
349        {sipName_QAnimationGroup, &sipType_QAnimationGroup, 28, 26},
350        {sipName_QPauseAnimation, &sipType_QPauseAnimation, -1, 27},
351        {sipName_QVariantAnimation, &sipType_QVariantAnimation, 30, -1},
352        {sipName_QParallelAnimationGroup, &sipType_QParallelAnimationGroup, -1, 29},
353        {sipName_QSequentialAnimationGroup, &sipType_QSequentialAnimationGroup, -1, -1},
354        {sipName_QPropertyAnimation, &sipType_QPropertyAnimation, -1, -1},
355        {sipName_QAbstractListModel, &sipType_QAbstractListModel, 35, 32},
356        {sipName_QAbstractProxyModel, &sipType_QAbstractProxyModel, 36, 33},
357        {sipName_QAbstractTableModel, &sipType_QAbstractTableModel, -1, 34},
358    #if QT_VERSION >= 0x050d00
359        {sipName_QConcatenateTablesProxyModel, &sipType_QConcatenateTablesProxyModel, -1, -1},
360    #else
361        {0, 0, -1, -1},
362    #endif
363        {sipName_QStringListModel, &sipType_QStringListModel, -1, -1},
364        {sipName_QIdentityProxyModel, &sipType_QIdentityProxyModel, -1, 37},
365        {sipName_QSortFilterProxyModel, &sipType_QSortFilterProxyModel, -1, 38},
366    #if QT_VERSION >= 0x050d00
367        {sipName_QTransposeProxyModel, &sipType_QTransposeProxyModel, -1, -1},
368    #else
369        {0, 0, -1, -1},
370    #endif
371        {sipName_QFinalState, &sipType_QFinalState, -1, 40},
372        {sipName_QHistoryState, &sipType_QHistoryState, -1, 41},
373        {sipName_QState, &sipType_QState, 42, -1},
374        {sipName_QStateMachine, &sipType_QStateMachine, -1, -1},
375        {sipName_QEventTransition, &sipType_QEventTransition, -1, 44},
376        {sipName_QSignalTransition, &sipType_QSignalTransition, -1, -1},
377        {sipName_QBuffer, &sipType_QBuffer, -1, 46},
378        {sipName_QFileDevice, &sipType_QFileDevice, 48, 47},
379    #if !defined(QT_NO_PROCESS)
380        {sipName_QProcess, &sipType_QProcess, -1, -1},
381    #else
382        {0, 0, -1, -1},
383    #endif
384        {sipName_QFile, &sipType_QFile, 50, 49},
385    #if QT_VERSION >= 0x050100
386        {sipName_QSaveFile, &sipType_QSaveFile, -1, -1},
387    #else
388        {0, 0, -1, -1},
389    #endif
390        {sipName_QTemporaryFile, &sipType_QTemporaryFile, -1, -1},
391    };
392
393    int i = 0;
394
395    sipType = NULL;
396
397    do
398    {
399        struct class_graph *cg = &graph[i];
400
401        if (cg->name != NULL && sipCpp->inherits(cg->name))
402        {
403            sipType = *cg->type;
404            i = cg->yes;
405        }
406        else
407            i = cg->no;
408    }
409    while (i >= 0);
410%End
411
412%GCTraverseCode
413    // Traverse any saved slots we might be connected to.
414    sipRes = qpycore_visitSlotProxies(sipCpp, sipVisit, sipArg);
415%End
416
417%GCClearCode
418    // Clear any saved slots we might be connected to.
419    sipRes = qpycore_clearSlotProxies(sipCpp);
420%End
421
422public:
423    static const QMetaObject staticMetaObject {
424%GetCode
425        sipPy = qpycore_qobject_staticmetaobject(sipPyType);
426%End
427
428    };
429    const QMetaObject *metaObject() const;
430    explicit QObject(QObject *parent /TransferThis/ = 0);
431    virtual ~QObject();
432    void pyqtConfigure(SIP_PYOBJECT) /NoArgParser/;
433%Docstring
434QObject.pyqtConfigure(...)
435
436Each keyword argument is either the name of a Qt property or a Qt signal.
437For properties the property is set to the given value which should be of an
438appropriate type.
439For signals the signal is connected to the given value which should be a
440callable.
441%End
442
443%MethodCode
444        return qpycore_pyqtconfigure(sipSelf, sipArgs, sipKwds);
445%End
446
447    SIP_PYOBJECT __getattr__(const char *name /Encoding="UTF-8"/) const;
448%MethodCode
449        sipRes = qpycore_qobject_getattr(sipCpp, sipSelf, a0);
450%End
451
452    virtual bool event(QEvent *);
453    virtual bool eventFilter(QObject *, QEvent *);
454    QString tr(const char *sourceText /Encoding="UTF-8"/, const char *disambiguation = 0, int n = -1) const;
455%MethodCode
456        // Note that tr() is really a static method.  We pretend it isn't so we can use
457        // self to get hold of the class name.
458
459        sipRes = new QString(QCoreApplication::translate(sipPyTypeName(Py_TYPE(sipSelf)), a0, a1, a2));
460%End
461
462    SIP_PYOBJECT findChild(SIP_PYTYPE type, const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="QObject"/;
463%MethodCode
464        sipRes = qtcore_FindChild(sipCpp, qtcore_type_to_tuple(a0), *a1, *a2);
465
466        if (!sipRes)
467            sipIsErr = 1;
468%End
469
470    SIP_PYOBJECT findChild(SIP_PYTUPLE types /TypeHintValue="()"/, const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="QObject"/;
471%MethodCode
472        sipRes = qtcore_FindChild(sipCpp, qtcore_check_tuple_types(a0), *a1, *a2);
473
474        if (!sipRes)
475            sipIsErr = 1;
476%End
477
478    SIP_PYLIST findChildren(SIP_PYTYPE type, const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
479%MethodCode
480        sipRes = qtcore_FindChildren(sipCpp, qtcore_type_to_tuple(a0), *a1, *a2);
481
482        if (!sipRes)
483            sipIsErr = 1;
484%End
485
486    SIP_PYLIST findChildren(SIP_PYTUPLE types /TypeHintValue="()"/, const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
487%MethodCode
488        sipRes = qtcore_FindChildren(sipCpp, qtcore_check_tuple_types(a0), *a1, *a2);
489
490        if (!sipRes)
491            sipIsErr = 1;
492%End
493
494    SIP_PYLIST findChildren(SIP_PYTYPE type, const QRegExp &regExp, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
495%MethodCode
496        sipRes = qtcore_FindChildren(sipCpp, qtcore_type_to_tuple(a0), *a1, *a2);
497
498        if (!sipRes)
499            sipIsErr = 1;
500%End
501
502    SIP_PYLIST findChildren(SIP_PYTUPLE types /TypeHintValue="()"/, const QRegExp &regExp, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
503%MethodCode
504        sipRes = qtcore_FindChildren(sipCpp, qtcore_check_tuple_types(a0), *a1, *a2);
505
506        if (!sipRes)
507            sipIsErr = 1;
508%End
509
510    SIP_PYLIST findChildren(SIP_PYTYPE type, const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
511%MethodCode
512        sipRes = qtcore_FindChildren(sipCpp, qtcore_type_to_tuple(a0), *a1, *a2);
513
514        if (!sipRes)
515            sipIsErr = 1;
516%End
517
518    SIP_PYLIST findChildren(SIP_PYTUPLE types /TypeHintValue="()"/, const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const /TypeHint="List[QObject]"/;
519%MethodCode
520        sipRes = qtcore_FindChildren(sipCpp, qtcore_check_tuple_types(a0), *a1, *a2);
521
522        if (!sipRes)
523            sipIsErr = 1;
524%End
525
526    QString objectName() const;
527    void setObjectName(const QString &name);
528    bool isWidgetType() const;
529    bool isWindowType() const;
530    bool signalsBlocked() const;
531    bool blockSignals(bool b);
532    QThread *thread() const;
533    void moveToThread(QThread *thread);
534    int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
535    void killTimer(int id);
536    const QObjectList &children() const;
537    void setParent(QObject * /TransferThis/);
538    void installEventFilter(QObject *);
539    void removeEventFilter(QObject *);
540%If (Qt_5_9_0 -)
541    void dumpObjectInfo() const;
542%End
543%If (- Qt_5_9_0)
544    void dumpObjectInfo();
545%End
546%If (Qt_5_9_0 -)
547    void dumpObjectTree() const;
548%End
549%If (- Qt_5_9_0)
550    void dumpObjectTree();
551%End
552    QList<QByteArray> dynamicPropertyNames() const;
553    bool setProperty(const char *name, const QVariant &value);
554    QVariant property(const char *name) const;
555
556signals:
557    void destroyed(QObject *object = 0);
558    void objectNameChanged(const QString &objectName);
559
560public:
561    QObject *parent() const;
562    bool inherits(const char *classname) const;
563
564public slots:
565    void deleteLater() /TransferThis/;
566
567protected:
568    QObject *sender() const /ReleaseGIL/;
569%MethodCode
570        // sender() must be called without the GIL to avoid possible deadlocks between
571        // the GIL and Qt's internal thread data mutex.
572
573        Py_BEGIN_ALLOW_THREADS
574
575        #if defined(SIP_PROTECTED_IS_PUBLIC)
576        sipRes = sipCpp->sender();
577        #else
578        sipRes = sipCpp->sipProtect_sender();
579        #endif
580
581        Py_END_ALLOW_THREADS
582
583        if (!sipRes)
584        {
585            typedef QObject *(*qtcore_qobject_sender_t)();
586
587            static qtcore_qobject_sender_t qtcore_qobject_sender = 0;
588
589            if (!qtcore_qobject_sender)
590            {
591                qtcore_qobject_sender = (qtcore_qobject_sender_t)sipImportSymbol("qtcore_qobject_sender");
592                Q_ASSERT(qtcore_qobject_sender);
593            }
594
595            sipRes = qtcore_qobject_sender();
596        }
597%End
598
599    int receivers(SIP_PYOBJECT signal /TypeHint="PYQT_SIGNAL"/) const [int (const char *signal)];
600%MethodCode
601        // We need to handle the signal object.  Import the helper if it hasn't already
602        // been done.
603        typedef sipErrorState (*pyqt5_get_signal_signature_t)(PyObject *, const QObject *, const QByteArray &);
604
605        static pyqt5_get_signal_signature_t pyqt5_get_signal_signature = 0;
606
607        if (!pyqt5_get_signal_signature)
608        {
609            pyqt5_get_signal_signature = (pyqt5_get_signal_signature_t)sipImportSymbol("pyqt5_get_signal_signature");
610            Q_ASSERT(pyqt5_get_signal_signature);
611        }
612
613        QByteArray signal_signature;
614
615        #if defined(SIP_PROTECTED_IS_PUBLIC)
616        if ((sipError = pyqt5_get_signal_signature(a0, sipCpp, signal_signature)) == sipErrorNone)
617        {
618            sipRes = sipCpp->receivers(signal_signature.constData());
619        }
620        #else
621        if ((sipError = pyqt5_get_signal_signature(a0, static_cast<const QObject *>(sipCpp), signal_signature)) == sipErrorNone)
622        {
623            sipRes = sipCpp->sipProtect_receivers(signal_signature.constData());
624        }
625        #endif
626        else if (sipError == sipErrorContinue)
627        {
628            sipError = sipBadCallableArg(0, a0);
629        }
630%End
631
632    virtual void timerEvent(QTimerEvent *);
633    virtual void childEvent(QChildEvent *);
634    virtual void customEvent(QEvent *);
635    virtual void connectNotify(const QMetaMethod &signal);
636    virtual void disconnectNotify(const QMetaMethod &signal);
637    int senderSignalIndex() const;
638    bool isSignalConnected(const QMetaMethod &signal) const;
639
640public:
641    static bool disconnect(const QMetaObject::Connection &);
642    SIP_PYOBJECT disconnect() const /TypeHint=""/;
643%MethodCode
644        sipRes = qpycore_qobject_disconnect(sipCpp);
645%End
646
647private:
648    QObject(const QObject &);
649};
650
651SIP_PYOBJECT Q_CLASSINFO(const char *name, const char *value) /TypeHint=""/;
652%MethodCode
653    sipRes = qpycore_ClassInfo(a0, a1);
654%End
655
656SIP_PYOBJECT Q_ENUM(SIP_PYOBJECT /TypeHint="Union[type, enum.Enum]"/) /TypeHint=""/;
657%MethodCode
658    sipRes = qpycore_Enum(a0);
659%End
660
661SIP_PYOBJECT Q_ENUMS(...) /TypeHint=""/;
662%MethodCode
663    sipRes = qpycore_Enums(a0);
664%End
665
666SIP_PYOBJECT Q_FLAG(SIP_PYOBJECT /TypeHint="Union[type, enum.Enum]"/) /TypeHint=""/;
667%MethodCode
668    sipRes = qpycore_Flag(a0);
669%End
670
671SIP_PYOBJECT Q_FLAGS(...) /TypeHint=""/;
672%MethodCode
673    sipRes = qpycore_Flags(a0);
674%End
675
676SIP_PYOBJECT QT_TR_NOOP(SIP_PYOBJECT /TypeHint="str"/) /TypeHint="str"/;
677%MethodCode
678    Py_INCREF(a0);
679    sipRes = a0;
680%End
681
682SIP_PYOBJECT QT_TR_NOOP_UTF8(SIP_PYOBJECT /TypeHint="str"/) /TypeHint="str"/;
683%MethodCode
684    Py_INCREF(a0);
685    sipRes = a0;
686%End
687
688SIP_PYOBJECT QT_TRANSLATE_NOOP(SIP_PYOBJECT /TypeHint="str"/, SIP_PYOBJECT /TypeHint="str"/) /TypeHint="str"/;
689%MethodCode
690    Py_INCREF(a1);
691    sipRes = a1;
692%End
693
694SIP_PYOBJECT pyqtSlot(... types, const char *name = 0, const char *result = 0) /NoArgParser, TypeHint="Callable[..., Optional[str]]"/;
695%Docstring
696@pyqtSlot(*types, name: Optional[str], result: Optional[str])
697
698This is a decorator applied to Python methods of a QObject that marks them
699as Qt slots.
700The non-keyword arguments are the types of the slot arguments and each may
701be a Python type object or a string specifying a C++ type.
702name is the name of the slot and defaults to the name of the method.
703result is type of the value returned by the slot.
704%End
705
706%MethodCode
707    return qpycore_pyqtslot(sipArgs, sipKwds);
708%End
709
710%If (Qt_5_3_0 -)
711
712class QSignalBlocker
713{
714%TypeHeaderCode
715#include <qobject.h>
716%End
717
718public:
719    explicit QSignalBlocker(QObject *o);
720    ~QSignalBlocker();
721    void reblock();
722    void unblock();
723    SIP_PYOBJECT __enter__();
724%MethodCode
725        // Just return a reference to self.
726        sipRes = sipSelf;
727        Py_INCREF(sipRes);
728%End
729
730    void __exit__(SIP_PYOBJECT type, SIP_PYOBJECT value, SIP_PYOBJECT traceback);
731%MethodCode
732        sipCpp->unblock();
733%End
734
735private:
736    QSignalBlocker(const QSignalBlocker &);
737};
738
739%End
740
741%ModuleHeaderCode
742#include "qpycore_api.h"
743%End
744
745%ModuleCode
746// Disable the (supposedly) compulsory parts of the Qt support API.
747#define sipQtCreateUniversalSlot    0
748#define sipQtDestroyUniversalSlot   0
749#define sipQtFindSlot               0
750#define sipQtConnect                0
751#define sipQtDisconnect             0
752#define sipQtSameSignalSlotName     0
753#define sipQtFindSipslot            0
754%End
755
756%PreInitialisationCode
757#if defined(Q_OS_DARWIN)
758    // This works around a problem (possibly a clash between Qt and Python)
759    // began with Qt v5.11 that causes missed paint events.  Only set the
760    // variable if it hasn't already been given a value.
761    if (qgetenv("QT_MAC_WANTS_LAYER").isNull())
762        qputenv("QT_MAC_WANTS_LAYER", "1");
763#endif
764%End
765
766%InitialisationCode
767qpycore_init();
768%End
769
770%PostInitialisationCode
771qpycore_post_init(sipModuleDict);
772%End
773