ObjQt  Diff

Differences From Artifact [d103de14ea]:

To Artifact [c04c6365a3]:


19
20
21
22
23
24
25
26
27


28
29



30
31
32
33
34
35
36
19
20
21
22
23
24
25


26
27
28
29
30
31
32
33
34
35
36
37
38
39







-
-
+
+


+
+
+







 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#import "QtObject.h"
#import "QtEvent.h"
#import "QtThread.h"

#import "helpers.h"
#import "OFString+QString.h"
#import "OFDataArray+QByteArray.h"

#include <QVariant>

using ObjQt::toOF;
using ObjQt::toQt;

@implementation QtObject
@synthesize qObject = _qObject;

- init
{
	OF_INVALID_INIT_METHOD
84
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114

115
116
117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139


140
141
142

143
144
145

146
147

148
149

150
151
152
153

154
155
156
157
158

159
160
161
162
163
164

165
166
167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
87
88
89
90
91
92
93

94

95
96
97
98
99
100
101
102
103
104
105
106
107

108
109
110
111
112
113
114
115

116
117
118
119
120
121
122

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139


140
141
142
143

144



145


146


147
148
149
150

151
152
153
154
155

156
157
158
159
160
161

162
163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179







-
+
-













-
+







-
+






-
+














-
+

-
-
+
+


-
+
-
-
-
+
-
-
+
-
-
+



-
+




-
+





-
+









-
+







{
	const QObjectList &qChildren = _qObject->children();
	OFMutableArray *children = [OFMutableArray arrayWithCapacity:
	    qChildren.count()];
	void *pool = objc_autoreleasePoolPush();

	for (QObject *qChild: qChildren)
		[children addObject:
		[children addObject: toOF(qChild)];
		    [[[QtObject alloc] initWithQObject: qChild] autorelease]];

	[children makeImmutable];

	objc_autoreleasePoolPop(pool);

	return children;
}

- (QMetaObject::Connection)connectSignal: (OFString*)signal
				  sender: (QtObject*)sender
				  method: (OFString*)method
				    type: (Qt::ConnectionType)type
{
	return _qObject->connect([sender qObject],
	return _qObject->connect(toQt(sender),
	    [signal UTF8String], [method UTF8String], type);
}

- (bool)disconnectSignal: (OFString*)signal
		receiver: (QtObject*)receiver
		  method: (OFString*)method
{
	return _qObject->disconnect([signal UTF8String], [receiver qObject],
	return _qObject->disconnect([signal UTF8String], toQt(receiver),
	    [method UTF8String]);
}

- (bool)disconnectAllSignalsForReceiver: (QtObject*)receiver
				 method: (OFString*)method
{
	return _qObject->disconnect([receiver qObject], [method UTF8String]);
	return _qObject->disconnect(toQt(receiver), [method UTF8String]);
}

- (void)dumpObjectInfo
{
	_qObject->dumpObjectInfo();
}

- (void)dumpObjectTree
{
	_qObject->dumpObjectTree();
}

- (OFArray OF_GENERIC(OFDataArray*)*)dynamicPropertyNames
{
	const QList<QByteArray> &qDynamicPropertyNames =
	const QList<QByteArray> &dynamicPropertyNames =
	    _qObject->dynamicPropertyNames();
	OFMutableArray *dynamicPropertyNames =
	    [OFMutableArray arrayWithCapacity: qDynamicPropertyNames.count()];
	OFMutableArray *ret =
	    [OFMutableArray arrayWithCapacity: dynamicPropertyNames.count()];
	void *pool = objc_autoreleasePoolPush();

	for (const QByteArray &qDynamicPropertyName: qDynamicPropertyNames) {
	for (const QByteArray &dynamicPropertyName: dynamicPropertyNames)
		OFDataArray *dynamicPropertyName = [OFDataArray dataArray];
		[dynamicPropertyName addItems: qDynamicPropertyName.data()
					count: qDynamicPropertyName.count()];
		[ret addObject: toOF(dynamicPropertyName)];
		[dynamicPropertyNames addObject: dynamicPropertyName];
	}


	[dynamicPropertyNames makeImmutable];
	[ret makeImmutable];

	objc_autoreleasePoolPop(pool);

	return dynamicPropertyNames;
	return ret;
}

- (bool)handleEvent: (QtEvent*)event
{
	return _qObject->event([event qEvent]);
	return _qObject->event(toQt(event));
}

- (bool)filterEvent: (QtEvent*)event
	  forObject: (QtObject*)watched
{
	return _qObject->eventFilter([watched qObject], [event qEvent]);
	return _qObject->eventFilter(toQt(watched), toQt(event));
}

- (bool)inheritsClassWithName: (OFString*)className
{
	return _qObject->inherits([className UTF8String]);
}

- (void)installEventFilter: (QtObject*)filterObj
{
	_qObject->installEventFilter([filterObj qObject]);
	_qObject->installEventFilter(toQt(filterObj));
}

- (bool)isWidgetType
{
	return _qObject->isWidgetType();
}

192
193
194
195
196
197
198
199

200
201
202
203
204
205

206
207
208
209
210

211
212
213
214
215
216
217
218
219
220

221
222
223
224
225
226
227
190
191
192
193
194
195
196

197
198
199
200
201


202
203
204
205
206

207
208
209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
224







-
+




-
-
+




-
+









-
+







- (const QMetaObject*)metaObject
{
	return _qObject->metaObject();
}

- (void)moveToThread: (QtThread*)targetThread
{
	_qObject->moveToThread([targetThread qThread]);
	_qObject->moveToThread(toQt(targetThread));
}

- (QtObject*)parent
{
	return [[[QtObject alloc]
	    initWithQObject: _qObject->parent()] autorelease];
	return toOF(_qObject->parent());
}

- (void)setParent: (QtObject*)parent
{
	_qObject->setParent([parent qObject]);
	_qObject->setParent(toQt(parent));
}

- (QVariant)propertyForName: (OFString*)name
{
	return _qObject->property([name UTF8String]);
}

- (void)removeEventFilter: (QtObject*)obj
{
	_qObject->removeEventFilter([obj qObject]);
	_qObject->removeEventFilter(toQt(obj));
}

- (bool)setProperty: (QVariant&)value
	    forName: (OFString*)name
{
	return _qObject->setProperty([name UTF8String], value);
}
235
236
237
238
239
240
241
242
243

244
245
246
247
248
249
250
251
232
233
234
235
236
237
238


239
240
241
242
243
244
245
246
247







-
-
+








			 type: (Qt::TimerType)type
{
	return _qObject->startTimer(interval, type);
}

- (QtThread*)thread
{
	return [[[QtThread alloc]
	    initWithQThread: _qObject->thread()] autorelease];
	return toOF(_qObject->thread());
}

- (void)deleteLater
{
	OF_ENSURE(!_ownsObject);
	_qObject->deleteLater();
}
@end