PythonQt
PythonQtSignalReceiver.h
Go to the documentation of this file.
1#ifndef _PYTHONQTSIGNALRECEIVER_H
2#define _PYTHONQTSIGNALRECEIVER_H
3
4/*
5 *
6 * Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36//----------------------------------------------------------------------------------
42//----------------------------------------------------------------------------------
43
45
46#include "PythonQtSystem.h"
47#include "PythonQtObjectPtr.h"
48
51
53
56{
57public:
58 PythonQtSignalTarget() { _methodInfo = nullptr; }
59
61 {
62 _methodInfo = methodInfo;
63 _callable = callable;
64 };
65
67
69 const PythonQtMethodInfo* methodInfo() const { return _methodInfo; }
70
72 void call(void** arguments) const;
73
75 bool isSame(PyObject* callable) const;
76
78 static PyObject* call(PyObject* callable, const PythonQtMethodInfo* methodInfo, void** arguments,
80
81private:
82 const PythonQtMethodInfo* _methodInfo;
83 PythonQtSafeObjectPtr _callable;
84};
85
87
89class PythonQtSignalReceiverBase : public QObject
90{
92public:
94};
95
97
100{
101
102public:
105
107 QObject* sender() const { return _sender; }
108
110 int signalId() const { return _signalId; }
111
114
117
119 int qt_metacall(QMetaObject::Call c, int id, void** arguments) override;
120
122 static int getSignalIndex(QObject* sender, const char* signal);
123
124private:
125 static int _slotCount;
126 QObject* _sender;
127 int _signalId;
128 bool _alreadyRemoved;
129 PythonQtSignalTarget _target;
130};
131
132#endif
PyObject * PythonQtConvertPairToPython(const void *inPair, int metaTypeId)
struct _object PyObject
#define PYTHONQT_EXPORT
a class that stores all required information about a Qt object (and an optional associated C++ class ...
stores information about a specific signal/slot/method
a smart pointer that stores a PyObject pointer and that handles reference counting automatically
base class for signal receivers
PythonQtSignalReceiverBase()=default
connects a signal to a callable
bool isSameCallable(PyObject *callable) const
Check if this object targets the callable given as argument.
void markAsRemoved()
Mark this object as already removed from the global list of signal receivers.
~PythonQtSignalReceiver() override
int qt_metacall(QMetaObject::Call c, int id, void **arguments) override
We implement this method to either call the callable, or react to the fact that the sender was destro...
static int getSignalIndex(QObject *sender, const char *signal)
Get the index of a sender's signal.
QObject * sender() const
Returns the signal sender for which this receiver was created.
int signalId() const
Returns the signal ID for which this receiver was created.
PythonQtSignalReceiver(QObject *sender, int signalId, PyObject *callable)
stores information about a signal target
PythonQtSignalTarget(const PythonQtMethodInfo *methodInfo, PyObject *callable)
bool isSame(PyObject *callable) const
check if this targets the same callable
static PyObject * call(PyObject *callable, const PythonQtMethodInfo *methodInfo, void **arguments, bool skipFirstArgumentOfMethodInfo=false)
call the given callable with arguments described by PythonQtMethodInfo, returns a new reference as re...
void call(void **arguments) const
call the python callable with the given arguments (as defined in methodInfo)
const PythonQtMethodInfo * methodInfo() const
get the signals parameter info