Mercurial > projects > qtd
annotate qt/core/QMetaObject.d @ 322:7c2cf27391c4 signals
A slight change of the connect syntax. More sofisticated signals/slots lookup. Some fixes in examples.
author | eldar_ins@eldar-laptop |
---|---|
date | Sun, 27 Dec 2009 21:13:38 +0500 |
parents | f9559a957be9 |
children | 7a3c43424dca |
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 } |
288 | 54 } |
55 | |
56 class QMetaSignal : QMetaMethod | |
57 { | |
58 this(string signature_, int indexOfMethod_) | |
59 { | |
60 super(signature_, indexOfMethod_); | |
61 } | |
62 } | |
63 | |
64 class QMetaSlot : QMetaMethod | |
65 { | |
66 this(string signature_, int indexOfMethod_) | |
67 { | |
68 super(signature_, indexOfMethod_); | |
69 } | |
70 } | |
71 | |
72 class MetaObject : MetaType | |
73 { | |
74 MetaObject _base; | |
75 } | |
76 | |
77 struct QMetaObjectNative | |
78 { | |
79 QMetaObjectNative *superdata; | |
80 immutable(char) *stringdata; | |
81 const(uint) *data; | |
82 void *extradata; | |
83 } | |
84 | |
253 | 85 final class QMetaObject |
86 { | |
288 | 87 enum Call |
88 { | |
89 InvokeMetaMethod, | |
90 ReadProperty, | |
91 WriteProperty, | |
92 ResetProperty, | |
93 QueryPropertyDesignable, | |
94 QueryPropertyScriptable, | |
95 QueryPropertyStored, | |
96 QueryPropertyEditable, | |
97 QueryPropertyUser, | |
98 CreateInstance | |
99 } | |
100 | |
253 | 101 private |
102 { | |
288 | 103 QMetaObjectNative* _nativeId; |
253 | 104 QMetaObject _base; // super class |
105 QMetaObject _firstDerived; // head of the linked list of derived classes | |
106 QMetaObject _next; // next sibling on this derivation level | |
288 | 107 QMetaMethod[] _methods; |
253 | 108 ClassInfo _classInfo; |
109 | |
110 QObject function(void* nativeId) _createWrapper; | |
111 } | |
112 | |
113 private void addDerived(QMetaObject mo) | |
114 { | |
115 mo._next = _firstDerived; | |
116 _firstDerived = mo; | |
117 } | |
118 | |
119 // NOTE: construction is split between this non-templated constructor and 'construct' function below. | |
288 | 120 this(QMetaObjectNative* nativeId, QMetaObject base) |
253 | 121 { |
122 _nativeId = nativeId; | |
123 if (base) | |
124 { | |
125 base.addDerived(this); | |
126 _base = base; | |
127 } | |
128 } | |
129 | |
130 // TODO: remove when D acquires templated constructors | |
131 void construct(T : QObject, Concrete = T)() | |
132 { | |
133 _classInfo = T.classinfo; | |
134 | |
135 _createWrapper = function QObject(void* nativeId) { | |
136 // COMPILER BUG: cast is should not be needed | |
137 auto obj = new Concrete(nativeId, cast(QtdObjectFlags)(QtdObjectFlags.nativeOwnership | QtdObjectFlags.dynamicEntity)); | |
138 // TODO: Probably this should be a virtual call from T's constructor | |
139 T.__createEntity(nativeId, cast(void*)obj); | |
140 return obj; | |
141 }; | |
142 } | |
143 | |
144 /++ | |
145 +/ | |
146 QMetaObject base() | |
147 { | |
148 return _base; | |
149 } | |
150 | |
151 /++ | |
152 +/ | |
288 | 153 QMetaObjectNative* nativeId() |
253 | 154 { |
155 return _nativeId; | |
156 } | |
157 | |
158 /++ | |
159 +/ | |
160 ClassInfo classInfo() | |
161 { | |
162 return _classInfo; | |
163 } | |
164 | |
288 | 165 const (QMetaMethod[]) methods() |
166 { | |
167 return _methods; | |
168 } | |
169 | |
170 void addMethod(QMetaMethod method_) | |
171 { | |
172 _methods ~= method_; | |
173 } | |
174 | |
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
|
175 QMetaMethod lookUpMethod(string slot) |
288 | 176 { |
177 foreach (method; _methods) | |
178 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
|
179 return method; |
288 | 180 if (_base) |
181 return _base.lookUpMethod(slot); | |
182 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
|
183 return null; |
288 | 184 } |
185 | |
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
|
186 QMetaSignal lookUpSignal(string signal) |
288 | 187 { |
188 foreach (method; _methods) | |
189 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
|
190 return cast(QMetaSignal)method; |
288 | 191 if (_base) |
192 return _base.lookUpSignal(signal); | |
193 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
|
194 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
|
195 } |
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
|
196 |
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
|
197 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
|
198 { |
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
|
199 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
|
200 foreach (method; _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
|
201 if (startsWith(method.signature, 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
|
202 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
|
203 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
|
204 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
|
205 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
|
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 |
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 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
|
209 { |
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 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
|
211 foreach (method; _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
|
212 if (startsWith(method.signature, signalName) && 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
|
213 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
|
214 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
|
215 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
|
216 return result; |
288 | 217 } |
218 | |
253 | 219 private QMetaObject lookupDerived(void*[] moIds) |
220 { | |
221 assert (moIds.length >= 1); | |
222 | |
223 for (auto mo = _firstDerived; mo !is null; mo = mo._next) | |
224 { | |
225 if (mo._nativeId == moIds[0]) | |
226 { | |
227 if (moIds.length == 1) // exact match found | |
228 return mo; | |
229 else // look deeper | |
230 return mo.lookupDerived(moIds[1..$]); | |
231 } | |
232 } | |
233 | |
234 // no initialized wrapper that matches the native object. | |
235 // use the base class wrapper | |
236 return this; | |
237 } | |
238 | |
239 QObject getObject(void* nativeObjId) | |
240 { | |
241 QObject result; | |
242 | |
243 if (nativeObjId) | |
244 { | |
245 result = cast(QObject)qtd_get_d_qobject(nativeObjId); | |
246 if (!result) | |
247 { | |
248 auto moId = qtd_QObject_metaObject(nativeObjId); | |
249 if (_nativeId == moId) | |
250 result = _createWrapper(nativeObjId); | |
251 else | |
252 { | |
253 // get native metaobjects for the entire derivation lattice | |
254 // up to, but not including, the current metaobject. | |
255 size_t moCount = 1; | |
256 | |
257 for (void* tmp = moId;;) | |
258 { | |
259 tmp = qtd_QMetaObject_superClass(tmp); | |
260 assert(tmp); | |
261 if (tmp == _nativeId) | |
262 break; | |
263 moCount++; | |
264 } | |
265 | |
266 void*[] moIds = (cast(void**)alloca(moCount * (void*).sizeof))[0..moCount]; | |
267 | |
268 moIds[--moCount] = moId; | |
269 while (moCount > 0) | |
270 moIds[--moCount] = moId = qtd_QMetaObject_superClass(moId); | |
271 | |
272 result = lookupDerived(moIds)._createWrapper(nativeObjId); | |
288 | 273 } |
253 | 274 } |
275 } | |
276 | |
277 return result; | |
278 } | |
288 | 279 |
280 static void activate(QObject sender, QMetaObject m, int local_signal_index, void **argv) | |
281 { | |
282 qtd_QMetaObject_activate_3(sender.__nativeId, m.nativeId, local_signal_index, argv); | |
283 } | |
284 | |
285 static void activate(QObject sender, QMetaObject m, int from_local_signal_index, int to_local_signal_index, void **argv) | |
286 { | |
287 qtd_QMetaObject_activate_4(sender.__nativeId, m.nativeId, from_local_signal_index, to_local_signal_index, argv); | |
288 } | |
289 | |
290 static bool connect(const QObject sender, int signal_index, | |
291 const QObject receiver, int method_index, | |
292 int type = 0, int *types = null) | |
293 { | |
294 return qtd_QMetaObject_connect(sender.__nativeId, signal_index, receiver.__nativeId, method_index, type, types); | |
295 } | |
296 | |
297 int indexOfMethod_Cpp(string method) | |
298 { | |
299 return qtd_QMetaObject_indexOfMethod(_nativeId, toStringz(method)); | |
300 } | |
301 | |
302 int methodCount() | |
303 { | |
304 return qtd_QMetaObject_methodCount(_nativeId); | |
305 } | |
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
|
306 |
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
|
307 static bool connectImpl(QObject sender, string signalString, QObject receiver, string 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
|
308 { |
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
|
309 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
|
310 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
|
311 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
|
312 QMetaMethod method; |
288 | 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 |
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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 |
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 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
|
321 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
|
322 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
|
323 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
|
324 |
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 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
|
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 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
|
328 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
|
329 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
|
330 { |
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 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
|
332 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
|
333 goto doConnect; |
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
|
334 } |
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 } |
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 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
|
337 { |
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 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
|
339 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
|
340 { |
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
|
341 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
|
342 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
|
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 } |
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 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
|
346 { |
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 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
|
348 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
|
349 { |
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 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
|
351 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
|
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 } |
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 doConnect: |
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(!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
|
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 writeln(stderr, "QMetaObject: Signal and slots cannot be found"); |
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 return false; |
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 int signalIndex = signal.indexOfMethod; |
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 int methodIndex = method.indexOfMethod; |
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
|
363 return QMetaObject.connect(sender, signalIndex, receiver, methodIndex); |
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
|
364 } |
253 | 365 } |
366 | |
288 | 367 extern(C) void qtd_QMetaObject_activate_3(void* sender, void* m, int local_signal_index, void **argv); |
368 extern(C) void qtd_QMetaObject_activate_4(void *sender, void* m, int from_local_signal_index, int to_local_signal_index, void **argv); | |
369 extern(C) bool qtd_QMetaObject_connect(const void* sender, int signal_index, | |
370 const void* receiver, int method_index, | |
371 int type, int *types); | |
372 | |
373 extern(C) int qtd_QMetaObject_indexOfMethod(void *nativeId, const(char) *method); | |
374 extern(C) int qtd_QMetaObject_methodCount(void *nativeId); | |
375 | |
253 | 376 extern(C) void* qtd_QMetaObject_superClass(void* nativeId); |