@@ -1,156 +1,304 | |||||
1 | /* |
|
1 | /* | |
2 | * |
|
2 | * | |
3 | * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved. |
|
3 | * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved. | |
4 | * |
|
4 | * | |
5 | * This library is free software; you can redistribute it and/or |
|
5 | * This library is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU Lesser General Public |
|
6 | * modify it under the terms of the GNU Lesser General Public | |
7 | * License as published by the Free Software Foundation; either |
|
7 | * License as published by the Free Software Foundation; either | |
8 | * version 2.1 of the License, or (at your option) any later version. |
|
8 | * version 2.1 of the License, or (at your option) any later version. | |
9 | * |
|
9 | * | |
10 | * This library is distributed in the hope that it will be useful, |
|
10 | * This library is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. |
|
13 | * Lesser General Public License for more details. | |
14 | * |
|
14 | * | |
15 | * Further, this software is distributed without any warranty that it is |
|
15 | * Further, this software is distributed without any warranty that it is | |
16 | * free of the rightful claim of any third person regarding infringement |
|
16 | * free of the rightful claim of any third person regarding infringement | |
17 | * or the like. Any license provided herein, whether implied or |
|
17 | * or the like. Any license provided herein, whether implied or | |
18 | * otherwise, applies only to this software file. Patent licenses, if |
|
18 | * otherwise, applies only to this software file. Patent licenses, if | |
19 | * any, provided herein do not apply to combinations of this program with |
|
19 | * any, provided herein do not apply to combinations of this program with | |
20 | * other software, or any other product whatsoever. |
|
20 | * other software, or any other product whatsoever. | |
21 | * |
|
21 | * | |
22 | * You should have received a copy of the GNU Lesser General Public |
|
22 | * You should have received a copy of the GNU Lesser General Public | |
23 | * License along with this library; if not, write to the Free Software |
|
23 | * License along with this library; if not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
25 | * |
|
25 | * | |
26 | * Contact information: MeVis Research GmbH, Universitaetsallee 29, |
|
26 | * Contact information: MeVis Research GmbH, Universitaetsallee 29, | |
27 | * 28359 Bremen, Germany or: |
|
27 | * 28359 Bremen, Germany or: | |
28 | * |
|
28 | * | |
29 | * http://www.mevis.de |
|
29 | * http://www.mevis.de | |
30 | * |
|
30 | * | |
31 | */ |
|
31 | */ | |
32 |
|
32 | |||
33 | //---------------------------------------------------------------------------------- |
|
33 | //---------------------------------------------------------------------------------- | |
34 | /*! |
|
34 | /*! | |
35 | // \file PythonQtStdDecorators.cpp |
|
35 | // \file PythonQtStdDecorators.cpp | |
36 | // \author Florian Link |
|
36 | // \author Florian Link | |
37 | // \author Last changed by $Author: florian $ |
|
37 | // \author Last changed by $Author: florian $ | |
38 | // \date 2007-04 |
|
38 | // \date 2007-04 | |
39 | */ |
|
39 | */ | |
40 | //---------------------------------------------------------------------------------- |
|
40 | //---------------------------------------------------------------------------------- | |
41 |
|
41 | |||
42 | #include "PythonQtStdDecorators.h" |
|
42 | #include "PythonQtStdDecorators.h" | |
43 | #include "PythonQt.h" |
|
43 | #include "PythonQt.h" | |
44 | #include "PythonQtClassInfo.h" |
|
44 | #include "PythonQtClassInfo.h" | |
45 | #include <QCoreApplication> |
|
45 | #include <QCoreApplication> | |
46 |
|
46 | |||
47 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable) |
|
47 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable) | |
48 | { |
|
48 | { | |
49 | QByteArray signalTmp; |
|
49 | QByteArray signalTmp; | |
50 | char first = signal.at(0); |
|
50 | char first = signal.at(0); | |
51 | if (first>='0' && first<='9') { |
|
51 | if (first>='0' && first<='9') { | |
52 | signalTmp = signal; |
|
52 | signalTmp = signal; | |
53 | } else { |
|
53 | } else { | |
54 | signalTmp = "2" + signal; |
|
54 | signalTmp = "2" + signal; | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | if (sender) { |
|
57 | if (sender) { | |
58 | return PythonQt::self()->addSignalHandler(sender, signalTmp, callable); |
|
58 | return PythonQt::self()->addSignalHandler(sender, signalTmp, callable); | |
59 | } else { |
|
59 | } else { | |
60 | return false; |
|
60 | return false; | |
61 | } |
|
61 | } | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) |
|
64 | bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) | |
65 | { |
|
65 | { | |
66 | bool r = false; |
|
66 | bool r = false; | |
67 | if (sender && receiver) { |
|
67 | if (sender && receiver) { | |
68 | QByteArray signalTmp; |
|
68 | QByteArray signalTmp; | |
69 | char first = signal.at(0); |
|
69 | char first = signal.at(0); | |
70 | if (first>='0' && first<='9') { |
|
70 | if (first>='0' && first<='9') { | |
71 | signalTmp = signal; |
|
71 | signalTmp = signal; | |
72 | } else { |
|
72 | } else { | |
73 | signalTmp = "2" + signal; |
|
73 | signalTmp = "2" + signal; | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | QByteArray slotTmp; |
|
76 | QByteArray slotTmp; | |
77 | first = slot.at(0); |
|
77 | first = slot.at(0); | |
78 | if (first>='0' && first<='9') { |
|
78 | if (first>='0' && first<='9') { | |
79 | slotTmp = slot; |
|
79 | slotTmp = slot; | |
80 | } else { |
|
80 | } else { | |
81 | slotTmp = "1" + slot; |
|
81 | slotTmp = "1" + slot; | |
82 | } |
|
82 | } | |
83 | r = QObject::connect(sender, signalTmp, receiver, slotTmp); |
|
83 | r = QObject::connect(sender, signalTmp, receiver, slotTmp); | |
84 | } |
|
84 | } | |
85 | return r; |
|
85 | return r; | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable) |
|
88 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, PyObject* callable) | |
89 | { |
|
89 | { | |
90 | QByteArray signalTmp; |
|
90 | QByteArray signalTmp; | |
91 | char first = signal.at(0); |
|
91 | char first = signal.at(0); | |
92 | if (first>='0' && first<='9') { |
|
92 | if (first>='0' && first<='9') { | |
93 | signalTmp = signal; |
|
93 | signalTmp = signal; | |
94 | } else { |
|
94 | } else { | |
95 | signalTmp = "2" + signal; |
|
95 | signalTmp = "2" + signal; | |
96 | } |
|
96 | } | |
97 | if (sender) { |
|
97 | if (sender) { | |
98 | return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable); |
|
98 | return PythonQt::self()->removeSignalHandler(sender, signalTmp, callable); | |
99 | } else { |
|
99 | } else { | |
100 | return false; |
|
100 | return false; | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 |
|
103 | |||
104 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) |
|
104 | bool PythonQtStdDecorators::disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot) | |
105 | { |
|
105 | { | |
106 | bool r = false; |
|
106 | bool r = false; | |
107 | if (sender && receiver) { |
|
107 | if (sender && receiver) { | |
108 | QByteArray signalTmp; |
|
108 | QByteArray signalTmp; | |
109 | char first = signal.at(0); |
|
109 | char first = signal.at(0); | |
110 | if (first>='0' && first<='9') { |
|
110 | if (first>='0' && first<='9') { | |
111 | signalTmp = signal; |
|
111 | signalTmp = signal; | |
112 | } else { |
|
112 | } else { | |
113 | signalTmp = "2" + signal; |
|
113 | signalTmp = "2" + signal; | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | QByteArray slotTmp; |
|
116 | QByteArray slotTmp; | |
117 | first = slot.at(0); |
|
117 | first = slot.at(0); | |
118 | if (first>='0' && first<='9') { |
|
118 | if (first>='0' && first<='9') { | |
119 | slotTmp = slot; |
|
119 | slotTmp = slot; | |
120 | } else { |
|
120 | } else { | |
121 | slotTmp = "1" + slot; |
|
121 | slotTmp = "1" + slot; | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | r = QObject::disconnect(sender, signalTmp, receiver, slotTmp); |
|
124 | r = QObject::disconnect(sender, signalTmp, receiver, slotTmp); | |
125 | } |
|
125 | } | |
126 | return r; |
|
126 | return r; | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | #undef emit |
|
129 | #undef emit | |
130 | void PythonQtStdDecorators::emit(QObject* sender, const QByteArray& signal, PyObject* arg1 ,PyObject* arg2 , |
|
130 | void PythonQtStdDecorators::emit(QObject* sender, const QByteArray& signal, PyObject* arg1 ,PyObject* arg2 , | |
131 | PyObject* arg3 ,PyObject* arg4 ,PyObject* arg5 ,PyObject* arg6 ,PyObject* arg7 ) |
|
131 | PyObject* arg3 ,PyObject* arg4 ,PyObject* arg5 ,PyObject* arg6 ,PyObject* arg7 ) | |
132 | { |
|
132 | { | |
133 | // TODO xxx |
|
133 | // TODO xxx | |
134 | // use normal PythonQtSlot calling code, add "allowSignal" to member lookup?! |
|
134 | // use normal PythonQtSlot calling code, add "allowSignal" to member lookup?! | |
135 | } |
|
135 | } | |
136 | #define emit |
|
136 | #define emit | |
137 |
|
137 | |||
138 | QObject* PythonQtStdDecorators::parent(QObject* o) { |
|
138 | QObject* PythonQtStdDecorators::parent(QObject* o) { | |
139 | return o->parent(); |
|
139 | return o->parent(); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | void PythonQtStdDecorators::setParent(QObject* o, QObject* parent) |
|
142 | void PythonQtStdDecorators::setParent(QObject* o, QObject* parent) | |
143 | { |
|
143 | { | |
144 | o->setParent(parent); |
|
144 | o->setParent(parent); | |
145 | } |
|
145 | } | |
146 |
|
146 | |||
147 | const QObjectList* PythonQtStdDecorators::children(QObject* o) |
|
147 | const QObjectList* PythonQtStdDecorators::children(QObject* o) | |
148 | { |
|
148 | { | |
149 | return &o->children(); |
|
149 | return &o->children(); | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 | QString PythonQtStdDecorators::tr(QObject* obj, const QByteArray& text, const QByteArray& ambig, int n) |
|
152 | QString PythonQtStdDecorators::tr(QObject* obj, const QByteArray& text, const QByteArray& ambig, int n) | |
153 | { |
|
153 | { | |
154 | return QCoreApplication::translate(obj->metaObject()->className(), text.constData(), ambig.constData(), QCoreApplication::CodecForTr, n); |
|
154 | return QCoreApplication::translate(obj->metaObject()->className(), text.constData(), ambig.constData(), QCoreApplication::CodecForTr, n); | |
155 | } |
|
155 | } | |
156 |
|
156 | |||
|
157 | QObject* PythonQtStdDecorators::findChild(QObject* parent, PyObject* type, const QString& name) | |||
|
158 | { | |||
|
159 | const QMetaObject* meta = NULL; | |||
|
160 | const char* typeName = NULL; | |||
|
161 | ||||
|
162 | if (PyObject_TypeCheck(type, &PythonQtClassWrapper_Type)) { | |||
|
163 | meta = ((PythonQtClassWrapper*)type)->classInfo()->metaObject(); | |||
|
164 | } else if (PyObject_TypeCheck(type, &PythonQtInstanceWrapper_Type)) { | |||
|
165 | meta = ((PythonQtInstanceWrapper*)type)->classInfo()->metaObject(); | |||
|
166 | } else if (PyString_Check(type)) { | |||
|
167 | typeName = PyString_AsString(type); | |||
|
168 | } | |||
|
169 | ||||
|
170 | if (!typeName && !meta) | |||
|
171 | return NULL; | |||
|
172 | ||||
|
173 | return findChild(parent, typeName, meta, name); | |||
|
174 | } | |||
|
175 | ||||
|
176 | QList<QObject*> PythonQtStdDecorators::findChildren(QObject* parent, PyObject* type, const QString& name) | |||
|
177 | { | |||
|
178 | const QMetaObject* meta = NULL; | |||
|
179 | const char* typeName = NULL; | |||
|
180 | ||||
|
181 | if (PyObject_TypeCheck(type, &PythonQtClassWrapper_Type)) { | |||
|
182 | meta = ((PythonQtClassWrapper*)type)->classInfo()->metaObject(); | |||
|
183 | } else if (PyObject_TypeCheck(type, &PythonQtInstanceWrapper_Type)) { | |||
|
184 | meta = ((PythonQtInstanceWrapper*)type)->classInfo()->metaObject(); | |||
|
185 | } else if (PyString_Check(type)) { | |||
|
186 | typeName = PyString_AsString(type); | |||
|
187 | } | |||
|
188 | ||||
|
189 | QList<QObject*> list; | |||
|
190 | ||||
|
191 | if (!typeName && !meta) | |||
|
192 | return list; | |||
|
193 | ||||
|
194 | findChildren(parent, typeName, meta, name, list); | |||
|
195 | ||||
|
196 | return list; | |||
|
197 | } | |||
|
198 | ||||
|
199 | QList<QObject*> PythonQtStdDecorators::findChildren(QObject* parent, PyObject* type, const QRegExp& regExp) | |||
|
200 | { | |||
|
201 | const QMetaObject* meta = NULL; | |||
|
202 | const char* typeName = NULL; | |||
|
203 | ||||
|
204 | if (PyObject_TypeCheck(type, &PythonQtClassWrapper_Type)) { | |||
|
205 | meta = ((PythonQtClassWrapper*)type)->classInfo()->metaObject(); | |||
|
206 | } else if (PyObject_TypeCheck(type, &PythonQtInstanceWrapper_Type)) { | |||
|
207 | meta = ((PythonQtInstanceWrapper*)type)->classInfo()->metaObject(); | |||
|
208 | } else if (PyString_Check(type)) { | |||
|
209 | typeName = PyString_AsString(type); | |||
|
210 | } | |||
|
211 | ||||
|
212 | QList<QObject*> list; | |||
|
213 | ||||
|
214 | if (!typeName && !meta) | |||
|
215 | return list; | |||
|
216 | ||||
|
217 | findChildren(parent, typeName, meta, regExp, list); | |||
|
218 | ||||
|
219 | return list; | |||
|
220 | } | |||
|
221 | ||||
|
222 | QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name) | |||
|
223 | { | |||
|
224 | const QObjectList &children = parent->children(); | |||
|
225 | ||||
|
226 | int i; | |||
|
227 | for (i = 0; i < children.size(); ++i) { | |||
|
228 | QObject* obj = children.at(i); | |||
|
229 | ||||
|
230 | if (!obj) | |||
|
231 | return NULL; | |||
|
232 | ||||
|
233 | // Skip if the name doesn't match. | |||
|
234 | if (!name.isNull() && obj->objectName() != name) | |||
|
235 | continue; | |||
|
236 | ||||
|
237 | if ((typeName && obj->inherits(typeName)) || | |||
|
238 | (meta && meta->cast(obj))) | |||
|
239 | return obj; | |||
|
240 | } | |||
|
241 | ||||
|
242 | for (i = 0; i < children.size(); ++i) { | |||
|
243 | QObject* obj = findChild(children.at(i), typeName, meta, name); | |||
|
244 | ||||
|
245 | if (obj != NULL) | |||
|
246 | return obj; | |||
|
247 | } | |||
|
248 | ||||
|
249 | return NULL; | |||
|
250 | } | |||
|
251 | ||||
|
252 | int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, QList<QObject*>& list) | |||
|
253 | { | |||
|
254 | const QObjectList& children = parent->children(); | |||
|
255 | int i; | |||
|
256 | ||||
|
257 | for (i = 0; i < children.size(); ++i) { | |||
|
258 | QObject* obj = children.at(i); | |||
|
259 | ||||
|
260 | if (!obj) | |||
|
261 | return -1; | |||
|
262 | ||||
|
263 | // Skip if the name doesn't match. | |||
|
264 | if (!name.isNull() && obj->objectName() != name) | |||
|
265 | continue; | |||
|
266 | ||||
|
267 | if ((typeName && obj->inherits(typeName)) || | |||
|
268 | (meta && meta->cast(obj))) { | |||
|
269 | list += obj; | |||
|
270 | } | |||
|
271 | ||||
|
272 | if (findChildren(obj, typeName, meta, name, list) < 0) | |||
|
273 | return -1; | |||
|
274 | } | |||
|
275 | ||||
|
276 | return 0; | |||
|
277 | } | |||
|
278 | ||||
|
279 | int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList<QObject*>& list) | |||
|
280 | { | |||
|
281 | const QObjectList& children = parent->children(); | |||
|
282 | int i; | |||
|
283 | ||||
|
284 | for (i = 0; i < children.size(); ++i) { | |||
|
285 | QObject* obj = children.at(i); | |||
|
286 | ||||
|
287 | if (!obj) | |||
|
288 | return -1; | |||
|
289 | ||||
|
290 | // Skip if the name doesn't match. | |||
|
291 | if (regExp.indexIn(obj->objectName()) == -1) | |||
|
292 | continue; | |||
|
293 | ||||
|
294 | if ((typeName && obj->inherits(typeName)) || | |||
|
295 | (meta && meta->cast(obj))) { | |||
|
296 | list += obj; | |||
|
297 | } | |||
|
298 | ||||
|
299 | if (findChildren(obj, typeName, meta, regExp, list) < 0) | |||
|
300 | return -1; | |||
|
301 | } | |||
|
302 | ||||
|
303 | return 0; | |||
|
304 | } |
@@ -1,103 +1,109 | |||||
1 | #ifndef _PYTHONQTSTDDECORATORS_H |
|
1 | #ifndef _PYTHONQTSTDDECORATORS_H | |
2 | #define _PYTHONQTSTDDECORATORS_H |
|
2 | #define _PYTHONQTSTDDECORATORS_H | |
3 |
|
3 | |||
4 | /* |
|
4 | /* | |
5 | * |
|
5 | * | |
6 | * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved. |
|
6 | * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved. | |
7 | * |
|
7 | * | |
8 | * This library is free software; you can redistribute it and/or |
|
8 | * This library is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public |
|
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either |
|
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. |
|
11 | * version 2.1 of the License, or (at your option) any later version. | |
12 | * |
|
12 | * | |
13 | * This library is distributed in the hope that it will be useful, |
|
13 | * This library is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * Lesser General Public License for more details. |
|
16 | * Lesser General Public License for more details. | |
17 | * |
|
17 | * | |
18 | * Further, this software is distributed without any warranty that it is |
|
18 | * Further, this software is distributed without any warranty that it is | |
19 | * free of the rightful claim of any third person regarding infringement |
|
19 | * free of the rightful claim of any third person regarding infringement | |
20 | * or the like. Any license provided herein, whether implied or |
|
20 | * or the like. Any license provided herein, whether implied or | |
21 | * otherwise, applies only to this software file. Patent licenses, if |
|
21 | * otherwise, applies only to this software file. Patent licenses, if | |
22 | * any, provided herein do not apply to combinations of this program with |
|
22 | * any, provided herein do not apply to combinations of this program with | |
23 | * other software, or any other product whatsoever. |
|
23 | * other software, or any other product whatsoever. | |
24 | * |
|
24 | * | |
25 | * You should have received a copy of the GNU Lesser General Public |
|
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 |
|
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 |
|
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
28 | * |
|
28 | * | |
29 | * Contact information: MeVis Research GmbH, Universitaetsallee 29, |
|
29 | * Contact information: MeVis Research GmbH, Universitaetsallee 29, | |
30 | * 28359 Bremen, Germany or: |
|
30 | * 28359 Bremen, Germany or: | |
31 | * |
|
31 | * | |
32 | * http://www.mevis.de |
|
32 | * http://www.mevis.de | |
33 | * |
|
33 | * | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | //---------------------------------------------------------------------------------- |
|
36 | //---------------------------------------------------------------------------------- | |
37 | /*! |
|
37 | /*! | |
38 | // \file PythonQtStdDecorators.h |
|
38 | // \file PythonQtStdDecorators.h | |
39 | // \author Florian Link |
|
39 | // \author Florian Link | |
40 | // \author Last changed by $Author: florian $ |
|
40 | // \author Last changed by $Author: florian $ | |
41 | // \date 2007-04 |
|
41 | // \date 2007-04 | |
42 | */ |
|
42 | */ | |
43 | //---------------------------------------------------------------------------------- |
|
43 | //---------------------------------------------------------------------------------- | |
44 |
|
44 | |||
45 | #include "PythonQtSystem.h" |
|
45 | #include "PythonQtSystem.h" | |
46 | #include <Python.h> |
|
46 | #include <Python.h> | |
47 | #include <QObject> |
|
47 | #include <QObject> | |
48 | #include <QVariantList> |
|
48 | #include <QVariantList> | |
49 | #include <QTextDocument> |
|
49 | #include <QTextDocument> | |
50 | #include <QColor> |
|
50 | #include <QColor> | |
51 | #include <QDateTime> |
|
51 | #include <QDateTime> | |
52 | #include <QDate> |
|
52 | #include <QDate> | |
53 | #include <QTime> |
|
53 | #include <QTime> | |
54 |
|
54 | |||
55 | class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject |
|
55 | class PYTHONQT_EXPORT PythonQtStdDecorators : public QObject | |
56 | { |
|
56 | { | |
57 | Q_OBJECT |
|
57 | Q_OBJECT | |
58 |
|
58 | |||
59 | public slots: |
|
59 | public slots: | |
60 | bool connect(QObject* sender, const QByteArray& signal, PyObject* callable); |
|
60 | bool connect(QObject* sender, const QByteArray& signal, PyObject* callable); | |
61 | bool connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot); |
|
61 | bool connect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot); | |
62 | bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable); |
|
62 | bool disconnect(QObject* sender, const QByteArray& signal, PyObject* callable); | |
63 | bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot); |
|
63 | bool disconnect(QObject* sender, const QByteArray& signal, QObject* receiver, const QByteArray& slot); | |
64 |
|
64 | |||
65 | #undef emit |
|
65 | #undef emit | |
66 | void emit(QObject* sender, const QByteArray& signal, PyObject* arg1 = NULL,PyObject* arg2 = NULL, |
|
66 | void emit(QObject* sender, const QByteArray& signal, PyObject* arg1 = NULL,PyObject* arg2 = NULL, | |
67 | PyObject* arg3 = NULL,PyObject* arg4 = NULL,PyObject* arg5 = NULL,PyObject* arg6 = NULL,PyObject* arg7 = NULL); |
|
67 | PyObject* arg3 = NULL,PyObject* arg4 = NULL,PyObject* arg5 = NULL,PyObject* arg6 = NULL,PyObject* arg7 = NULL); | |
68 | #define emit |
|
68 | #define emit | |
69 |
|
69 | |||
70 | QObject* parent(QObject* o); |
|
70 | QObject* parent(QObject* o); | |
71 | void setParent(QObject* o, QObject* parent); |
|
71 | void setParent(QObject* o, QObject* parent); | |
72 |
|
72 | |||
73 | const QObjectList* children(QObject* o); |
|
73 | const QObjectList* children(QObject* o); | |
|
74 | QObject* findChild(QObject* parent, PyObject* type, const QString& name = QString()); | |||
|
75 | QList<QObject*> findChildren(QObject* parent, PyObject* type, const QString& name= QString()); | |||
|
76 | QList<QObject*> findChildren(QObject* parent, PyObject* type, const QRegExp& regExp); | |||
74 |
|
77 | |||
75 | double static_Qt_qAbs(double a) { return qAbs(a); } |
|
78 | double static_Qt_qAbs(double a) { return qAbs(a); } | |
76 | double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); } |
|
79 | double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); } | |
77 | void static_Qt_qDebug(const QByteArray& msg) { qDebug(msg.constData()); } |
|
80 | void static_Qt_qDebug(const QByteArray& msg) { qDebug(msg.constData()); } | |
78 | // TODO: multi arg qDebug... |
|
81 | // TODO: multi arg qDebug... | |
79 | void static_Qt_qWarning(const QByteArray& msg) { qWarning(msg.constData()); } |
|
82 | void static_Qt_qWarning(const QByteArray& msg) { qWarning(msg.constData()); } | |
80 | // TODO: multi arg qWarning... |
|
83 | // TODO: multi arg qWarning... | |
81 | void static_Qt_qCritical(const QByteArray& msg) { qCritical(msg.constData()); } |
|
84 | void static_Qt_qCritical(const QByteArray& msg) { qCritical(msg.constData()); } | |
82 | // TODO: multi arg qCritical... |
|
85 | // TODO: multi arg qCritical... | |
83 | void static_Qt_qFatal(const QByteArray& msg) { qFatal(msg.constData()); } |
|
86 | void static_Qt_qFatal(const QByteArray& msg) { qFatal(msg.constData()); } | |
84 | // TODO: multi arg qFatal... |
|
87 | // TODO: multi arg qFatal... | |
85 | bool static_Qt_qFuzzyCompare(double a, double b) { return qFuzzyCompare(a, b); } |
|
88 | bool static_Qt_qFuzzyCompare(double a, double b) { return qFuzzyCompare(a, b); } | |
86 | double static_Qt_qMax(double a, double b) { return qMax(a, b); } |
|
89 | double static_Qt_qMax(double a, double b) { return qMax(a, b); } | |
87 | double static_Qt_qMin(double a, double b) { return qMin(a, b); } |
|
90 | double static_Qt_qMin(double a, double b) { return qMin(a, b); } | |
88 | int static_Qt_qRound(double a) { return qRound(a); } |
|
91 | int static_Qt_qRound(double a) { return qRound(a); } | |
89 | qint64 static_Qt_qRound64(double a) { return qRound64(a); } |
|
92 | qint64 static_Qt_qRound64(double a) { return qRound64(a); } | |
90 | const char* static_Qt_qVersion() { return qVersion(); } |
|
93 | const char* static_Qt_qVersion() { return qVersion(); } | |
91 | int static_Qt_qrand() { return qrand(); } |
|
94 | int static_Qt_qrand() { return qrand(); } | |
92 | void static_Qt_qsrand(uint a) { qsrand(a); } |
|
95 | void static_Qt_qsrand(uint a) { qsrand(a); } | |
93 |
|
96 | |||
94 | QString tr(QObject* obj, const QByteArray& text, const QByteArray& ambig = QByteArray(), int n = -1); |
|
97 | QString tr(QObject* obj, const QByteArray& text, const QByteArray& ambig = QByteArray(), int n = -1); | |
95 |
|
98 | |||
96 | QByteArray static_Qt_SIGNAL(const QByteArray& s) { return QByteArray("2") + s; } |
|
99 | QByteArray static_Qt_SIGNAL(const QByteArray& s) { return QByteArray("2") + s; } | |
97 | QByteArray static_Qt_SLOT(const QByteArray& s) { return QByteArray("1") + s; } |
|
100 | QByteArray static_Qt_SLOT(const QByteArray& s) { return QByteArray("1") + s; } | |
98 |
|
101 | |||
99 | //TODO: add findChild/findChildren/children/... |
|
102 | private: | |
|
103 | QObject* findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name); | |||
|
104 | int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name, QList<QObject*>& list); | |||
|
105 | int findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList<QObject*>& list); | |||
100 | }; |
|
106 | }; | |
101 |
|
107 | |||
102 |
|
108 | |||
103 | #endif |
|
109 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now