Mercurial > projects > qtd
annotate qt/core/QMetaObject.d @ 336:b0a7819153bb
fixed signal branch merge problems
author | maxter@maxter |
---|---|
date | Thu, 11 Feb 2010 12:59:25 +0200 |
parents | 24ebea513d66 |
children | 5896535a03cd |
rev | line source |
---|---|
253 | 1 module qt.core.QMetaObject; |
2 | |
3 import qt.QGlobal; | |
4 import qt.core.QObject; | |
5 import qt.QtdObject; | |
6 | |
288 | 7 import std.algorithm; |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
8 import std.string; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
9 import std.stdio; |
288 | 10 |
11 class Meta | |
12 { | |
13 string name; | |
14 } | |
15 | |
16 class MetaType : Meta | |
17 { | |
18 this() | |
19 { | |
20 } | |
21 } | |
22 | |
23 class MetaVariable : Meta | |
24 { | |
25 MetaType type; | |
26 } | |
27 | |
28 class MetaCallable : Meta { } | |
29 | |
30 class MetaMethod : Meta { } | |
31 | |
32 class QMetaArgument : MetaVariable { } | |
33 | |
34 class QMetaMethod : MetaMethod | |
35 { | |
36 // QMetaArgument[] arguments; | |
37 string signature; | |
38 int indexOfMethod; | |
39 | |
40 this(string signature_, int indexOfMethod_) | |
41 { | |
42 signature = signature_; | |
43 indexOfMethod = indexOfMethod_; | |
44 } | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
45 |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
46 string args() const |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
47 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
48 int openBracket = indexOf(signature, '('); |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
49 if(signature.length - openBracket - 2 > 0) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
50 return signature[openBracket + 1 .. $-1]; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
51 else |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
52 return ""; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
53 } |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
54 |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
55 string name() const |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
56 { |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
57 int openBracket = indexOf(signature, '('); |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
58 return signature[0..openBracket]; |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
59 } |
288 | 60 } |
61 | |
62 class QMetaSignal : QMetaMethod | |
63 { | |
64 this(string signature_, int indexOfMethod_) | |
65 { | |
66 super(signature_, indexOfMethod_); | |
67 } | |
68 } | |
69 | |
70 class QMetaSlot : QMetaMethod | |
71 { | |
72 this(string signature_, int indexOfMethod_) | |
73 { | |
74 super(signature_, indexOfMethod_); | |
75 } | |
76 } | |
77 | |
78 class MetaObject : MetaType | |
79 { | |
80 MetaObject _base; | |
81 } | |
82 | |
83 struct QMetaObjectNative | |
84 { | |
85 QMetaObjectNative *superdata; | |
86 immutable(char) *stringdata; | |
87 const(uint) *data; | |
88 void *extradata; | |
89 } | |
90 | |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
91 class QMetaException : Exception { this(string msg) { super(msg); } } |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
92 |
253 | 93 final class QMetaObject |
94 { | |
288 | 95 enum Call |
96 { | |
97 InvokeMetaMethod, | |
98 ReadProperty, | |
99 WriteProperty, | |
100 ResetProperty, | |
101 QueryPropertyDesignable, | |
102 QueryPropertyScriptable, | |
103 QueryPropertyStored, | |
104 QueryPropertyEditable, | |
105 QueryPropertyUser, | |
106 CreateInstance | |
107 } | |
108 | |
253 | 109 private |
110 { | |
288 | 111 QMetaObjectNative* _nativeId; |
253 | 112 QMetaObject _base; // super class |
113 QMetaObject _firstDerived; // head of the linked list of derived classes | |
114 QMetaObject _next; // next sibling on this derivation level | |
288 | 115 QMetaMethod[] _methods; |
253 | 116 ClassInfo _classInfo; |
117 | |
118 QObject function(void* nativeId) _createWrapper; | |
119 } | |
120 | |
121 private void addDerived(QMetaObject mo) | |
122 { | |
123 mo._next = _firstDerived; | |
124 _firstDerived = mo; | |
125 } | |
126 | |
127 // NOTE: construction is split between this non-templated constructor and 'construct' function below. | |
288 | 128 this(QMetaObjectNative* nativeId, QMetaObject base) |
253 | 129 { |
130 _nativeId = nativeId; | |
131 if (base) | |
132 { | |
133 base.addDerived(this); | |
134 _base = base; | |
135 } | |
136 } | |
137 | |
138 // TODO: remove when D acquires templated constructors | |
139 void construct(T : QObject, Concrete = T)() | |
140 { | |
141 _classInfo = T.classinfo; | |
142 | |
143 _createWrapper = function QObject(void* nativeId) { | |
144 // COMPILER BUG: cast is should not be needed | |
145 auto obj = new Concrete(nativeId, cast(QtdObjectFlags)(QtdObjectFlags.nativeOwnership | QtdObjectFlags.dynamicEntity)); | |
146 // TODO: Probably this should be a virtual call from T's constructor | |
147 T.__createEntity(nativeId, cast(void*)obj); | |
148 return obj; | |
149 }; | |
150 } | |
151 | |
152 /++ | |
153 +/ | |
154 QMetaObject base() | |
155 { | |
156 return _base; | |
157 } | |
158 | |
159 /++ | |
160 +/ | |
288 | 161 QMetaObjectNative* nativeId() |
253 | 162 { |
163 return _nativeId; | |
164 } | |
165 | |
166 /++ | |
167 +/ | |
168 ClassInfo classInfo() | |
169 { | |
170 return _classInfo; | |
171 } | |
172 | |
288 | 173 const (QMetaMethod[]) methods() |
174 { | |
175 return _methods; | |
176 } | |
177 | |
178 void addMethod(QMetaMethod method_) | |
179 { | |
180 _methods ~= method_; | |
181 } | |
182 | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
183 QMetaMethod lookUpMethod(string slot) |
288 | 184 { |
185 foreach (method; _methods) | |
186 if (method.signature == slot) | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
187 return method; |
288 | 188 if (_base) |
189 return _base.lookUpMethod(slot); | |
190 else | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
191 return null; |
288 | 192 } |
193 | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
194 QMetaSignal lookUpSignal(string signal) |
288 | 195 { |
196 foreach (method; _methods) | |
197 if (method.signature == signal && cast(QMetaSignal)method) | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
198 return cast(QMetaSignal)method; |
288 | 199 if (_base) |
200 return _base.lookUpSignal(signal); | |
201 else | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
202 return null; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
203 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
204 |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
205 QMetaMethod[] lookUpMethodOverloads(string methodName) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
206 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
207 typeof(return) result; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
208 foreach (method; _methods) |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
209 if (method.name == methodName) |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
210 result ~= method; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
211 if (_base) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
212 result ~= _base.lookUpMethodOverloads(methodName); |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
213 return result; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
214 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
215 |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
216 QMetaSignal[] lookUpSignalOverloads(string signalName) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
217 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
218 typeof(return) result; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
219 foreach (method; _methods) |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
220 if (method.name == signalName && cast(QMetaSignal)method) |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
221 result ~= cast(QMetaSignal)method; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
222 if (_base) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
223 result ~= _base.lookUpSignalOverloads(signalName); |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
224 return result; |
288 | 225 } |
226 | |
253 | 227 private QMetaObject lookupDerived(void*[] moIds) |
228 { | |
229 assert (moIds.length >= 1); | |
230 | |
231 for (auto mo = _firstDerived; mo !is null; mo = mo._next) | |
232 { | |
233 if (mo._nativeId == moIds[0]) | |
234 { | |
235 if (moIds.length == 1) // exact match found | |
236 return mo; | |
237 else // look deeper | |
238 return mo.lookupDerived(moIds[1..$]); | |
239 } | |
240 } | |
241 | |
242 // no initialized wrapper that matches the native object. | |
243 // use the base class wrapper | |
244 return this; | |
245 } | |
246 | |
247 QObject getObject(void* nativeObjId) | |
248 { | |
249 QObject result; | |
250 | |
251 if (nativeObjId) | |
252 { | |
253 result = cast(QObject)qtd_get_d_qobject(nativeObjId); | |
254 if (!result) | |
255 { | |
256 auto moId = qtd_QObject_metaObject(nativeObjId); | |
257 if (_nativeId == moId) | |
258 result = _createWrapper(nativeObjId); | |
259 else | |
260 { | |
261 // get native metaobjects for the entire derivation lattice | |
262 // up to, but not including, the current metaobject. | |
263 size_t moCount = 1; | |
264 | |
265 for (void* tmp = moId;;) | |
266 { | |
267 tmp = qtd_QMetaObject_superClass(tmp); | |
268 assert(tmp); | |
269 if (tmp == _nativeId) | |
270 break; | |
271 moCount++; | |
272 } | |
273 | |
274 void*[] moIds = (cast(void**)alloca(moCount * (void*).sizeof))[0..moCount]; | |
275 | |
276 moIds[--moCount] = moId; | |
277 while (moCount > 0) | |
278 moIds[--moCount] = moId = qtd_QMetaObject_superClass(moId); | |
279 | |
280 result = lookupDerived(moIds)._createWrapper(nativeObjId); | |
288 | 281 } |
253 | 282 } |
283 } | |
284 | |
285 return result; | |
286 } | |
288 | 287 |
288 static void activate(QObject sender, QMetaObject m, int local_signal_index, void **argv) | |
289 { | |
290 qtd_QMetaObject_activate_3(sender.__nativeId, m.nativeId, local_signal_index, argv); | |
291 } | |
292 | |
293 static void activate(QObject sender, QMetaObject m, int from_local_signal_index, int to_local_signal_index, void **argv) | |
294 { | |
295 qtd_QMetaObject_activate_4(sender.__nativeId, m.nativeId, from_local_signal_index, to_local_signal_index, argv); | |
296 } | |
297 | |
298 static bool connect(const QObject sender, int signal_index, | |
299 const QObject receiver, int method_index, | |
300 int type = 0, int *types = null) | |
301 { | |
302 return qtd_QMetaObject_connect(sender.__nativeId, signal_index, receiver.__nativeId, method_index, type, types); | |
303 } | |
304 | |
305 int indexOfMethod_Cpp(string method) | |
306 { | |
307 return qtd_QMetaObject_indexOfMethod(_nativeId, toStringz(method)); | |
308 } | |
309 | |
310 int methodCount() | |
311 { | |
312 return qtd_QMetaObject_methodCount(_nativeId); | |
313 } | |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
314 |
336 | 315 static void connectImpl(QObject sender, string signalString, QObject receiver, string methodString) |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
316 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
317 QMetaSignal[] signals; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
318 QMetaMethod[] methods; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
319 QMetaSignal signal; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
320 QMetaMethod method; |
288 | 321 |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
322 if(indexOf(signalString, '(') > 0) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
323 signal = sender.metaObject.lookUpSignal(signalString); |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
324 else |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
325 signals = sender.metaObject.lookUpSignalOverloads(signalString); // parameters not specified. Looking for a match |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
326 |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
327 if(indexOf(methodString, '(') > 0) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
328 method = receiver.metaObject.lookUpMethod(methodString); |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
329 else |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
330 methods = receiver.metaObject.lookUpMethodOverloads(methodString); // parameters not specified. Looking for a match |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
331 |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
332 if(!signal && !method) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
333 { |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
334 Top: |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
335 foreach(sig; signals) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
336 foreach(meth; methods) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
337 if(startsWith(sig.args, meth.args)) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
338 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
339 signal = sig; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
340 method = meth; |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
341 break Top; |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
342 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
343 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
344 else if (!signal) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
345 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
346 foreach(sig; signals) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
347 if(startsWith(sig.args, method.args)) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
348 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
349 signal = sig; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
350 break; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
351 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
352 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
353 else if (!method) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
354 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
355 foreach(meth; methods) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
356 if(startsWith(signal.args, meth.args)) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
357 { |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
358 method = meth; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
359 break; |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
360 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
361 } |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
362 |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
363 bool success = false; |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
364 |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
365 if(!signal && !method) |
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
366 { |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
367 success = false; |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
368 } |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
369 else |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
370 { |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
371 int signalIndex = signal.indexOfMethod; |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
372 int methodIndex = method.indexOfMethod; |
336 | 373 success = QMetaObject.connect(sender, signalIndex, receiver, methodIndex); |
323
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
374 } |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
375 |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
376 if(!success) |
7a3c43424dca
make all examples compile with new signals/slots
eldar_ins@eldar-laptop
parents:
322
diff
changeset
|
377 throw new QMetaException("QMetaObject: Signal " ~ signalString ~ " and slot " ~ methodString ~ " cannot be found"); |
322
7c2cf27391c4
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
eldar_ins@eldar-laptop
parents:
288
diff
changeset
|
378 } |
253 | 379 } |
380 | |
288 | 381 extern(C) void qtd_QMetaObject_activate_3(void* sender, void* m, int local_signal_index, void **argv); |
382 extern(C) void qtd_QMetaObject_activate_4(void *sender, void* m, int from_local_signal_index, int to_local_signal_index, void **argv); | |
383 extern(C) bool qtd_QMetaObject_connect(const void* sender, int signal_index, | |
384 const void* receiver, int method_index, | |
385 int type, int *types); | |
386 | |
387 extern(C) int qtd_QMetaObject_indexOfMethod(void *nativeId, const(char) *method); | |
388 extern(C) int qtd_QMetaObject_methodCount(void *nativeId); | |
389 | |
336 | 390 extern(C) void* qtd_QMetaObject_superClass(void* nativeId); |