qtruby4 1.4.9-mswin32 → 2.1.0.b-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Rakefile +5 -0
  2. data/bin/Qt3Support4.dll +0 -0
  3. data/bin/QtAssistantClient4.dll +0 -0
  4. data/bin/QtCLucene4.dll +0 -0
  5. data/bin/QtCore4.dll +0 -0
  6. data/bin/QtDesigner4.dll +0 -0
  7. data/bin/QtDesignerComponents4.dll +0 -0
  8. data/bin/QtGui4.dll +0 -0
  9. data/bin/QtHelp4.dll +0 -0
  10. data/bin/QtNetwork4.dll +0 -0
  11. data/bin/QtOpenGL4.dll +0 -0
  12. data/bin/QtScript4.dll +0 -0
  13. data/bin/QtScriptTools4.dll +0 -0
  14. data/bin/QtSql4.dll +0 -0
  15. data/bin/QtSvg4.dll +0 -0
  16. data/bin/QtTest4.dll +0 -0
  17. data/bin/QtWebKit4.dll +0 -0
  18. data/bin/QtXml4.dll +0 -0
  19. data/bin/QtXmlPatterns4.dll +0 -0
  20. data/bin/assistant.exe +0 -0
  21. data/bin/designer.exe +0 -0
  22. data/bin/linguist.exe +0 -0
  23. data/bin/phonon4.dll +0 -0
  24. data/bin/qtruby4shared.dll +0 -0
  25. data/bin/rbrcc.exe +0 -0
  26. data/bin/rbuic4.exe +0 -0
  27. data/bin/smokeqt.dll +0 -0
  28. data/bin/smokeqtcore.dll +0 -0
  29. data/bin/smokeqtgui.dll +0 -0
  30. data/bin/smokeqtnetwork.dll +0 -0
  31. data/bin/smokeqtopengl.dll +0 -0
  32. data/bin/smokeqtsql.dll +0 -0
  33. data/bin/smokeqtsvg.dll +0 -0
  34. data/bin/smokeqtxml.dll +0 -0
  35. data/bin/smokeqtxmlpatterns.dll +0 -0
  36. data/lib/Qt/active_item_model.rb +234 -0
  37. data/lib/Qt/active_table_model.rb +122 -0
  38. data/lib/{qt → Qt}/qtruby4.rb +736 -318
  39. data/lib/qtruby4.dll +0 -0
  40. metadata +63 -45
  41. data/bin/QtDBus4.dll +0 -0
  42. data/bin/libdbus-1.dll +0 -0
  43. data/bin/qdbus.exe +0 -0
  44. data/bin/qdbuscpp2xml.exe +0 -0
  45. data/bin/qdbusviewer.exe +0 -0
  46. data/bin/qdbusxml2cpp.exe +0 -0
  47. data/bin/rbqtapi +0 -109
  48. data/bin/rbqtsh +0 -627
  49. data/extconf.rb +0 -9
  50. data/lib/Makefile +0 -5
  51. data/lib/qtruby4.so +0 -0
@@ -0,0 +1,5 @@
1
+ task :default do
2
+ puts "Copy needed files..."
3
+ require 'fileutils'
4
+ FileUtils.cp_r( Dir['bin/*'], "../../../../../../bin", :verbose => true )
5
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,234 @@
1
+ =begin
2
+ This Qt::AbstractItemModel based model allows an ActiveRecord or ActiveResource
3
+ data set be used for viewing in a Qt::TreeView.
4
+
5
+ Example usage:
6
+
7
+ app = Qt::Application.new(ARGV)
8
+ agencies = TravelAgency.find(:all)
9
+ model = ActiveItemModel.new(agencies)
10
+ tree = Qt::TreeView.new
11
+ tree.model = model
12
+ tree.show
13
+ app.exec
14
+
15
+ Written by Richard Dale and Silvio Fonseca
16
+
17
+ =end
18
+
19
+ require 'Qt'
20
+
21
+ #require "active_record"
22
+ #require "active_support"
23
+ #require "active_resource"
24
+
25
+ require 'date'
26
+
27
+ class TreeItem
28
+ attr_reader :childItems, :resource, :itemData
29
+
30
+ def initialize(item, keys, parent = nil, prefix="")
31
+ @keys = keys
32
+ @parentItem = parent
33
+ @childItems = []
34
+ @resource = item
35
+ if @resource.respond_to? :attributes
36
+ @resource.attributes.inject(@itemData = {}) do |data, a|
37
+ if a[1].respond_to? :attributes
38
+ TreeItem.new(a[1], @keys, self, prefix + a[0] + ".")
39
+ else
40
+ data[prefix + a[0]] = a[1]
41
+ end
42
+ data
43
+ end
44
+ else
45
+ @itemData = item
46
+ end
47
+
48
+ if @parentItem
49
+ @parentItem.appendChild(self)
50
+ end
51
+ end
52
+
53
+ def appendChild(item)
54
+ @childItems.push(item)
55
+ end
56
+
57
+ def child(row)
58
+ return @childItems[row]
59
+ end
60
+
61
+ def childCount
62
+ return @childItems.length
63
+ end
64
+
65
+ def columnCount
66
+ return @itemData.length
67
+ end
68
+
69
+ def data(column)
70
+ return Qt::Variant.new(@itemData[@keys[column]])
71
+ end
72
+
73
+ def parent
74
+ return @parentItem
75
+ end
76
+
77
+ def row
78
+ if !@parentItem.nil?
79
+ return @parentItem.childItems.index(self)
80
+ end
81
+
82
+ return 0
83
+ end
84
+ end
85
+
86
+ class ActiveItemModel < Qt::AbstractItemModel
87
+ def initialize(collection, columns=nil)
88
+ super()
89
+ @collection = collection
90
+ @keys = build_keys([], @collection.first.attributes)
91
+ @keys.inject(@labels = {}) do |labels, k|
92
+ labels[k] = k.humanize.gsub(/\./, ' ')
93
+ labels
94
+ end
95
+
96
+ @rootItem = TreeItem.new(@labels, @keys)
97
+ @collection.each do |row|
98
+ TreeItem.new(row, @keys, @rootItem)
99
+ end
100
+ end
101
+
102
+ def build_keys(keys, attrs, prefix="")
103
+ attrs.inject(keys) do |cols, a|
104
+ if a[1].respond_to? :attributes
105
+ build_keys(cols, a[1].attributes, prefix + a[0] + ".")
106
+ else
107
+ cols << prefix + a[0]
108
+ end
109
+ end
110
+ end
111
+
112
+ def [](row)
113
+ row = row.row if row.is_a?Qt::ModelIndex
114
+ @collection[row]
115
+ end
116
+
117
+ def column(name)
118
+ @keys.index name
119
+ end
120
+
121
+ def columnCount(parent)
122
+ if parent.valid?
123
+ return parent.internalPointer.columnCount
124
+ else
125
+ return @rootItem.columnCount
126
+ end
127
+ end
128
+
129
+ def data(index, role)
130
+ if !index.valid?
131
+ return Qt::Variant.new
132
+ end
133
+
134
+ if role != Qt::DisplayRole
135
+ return Qt::Variant.new
136
+ end
137
+
138
+ item = index.internalPointer
139
+ return item.data(index.column)
140
+ end
141
+
142
+ def setData(index, variant, role=Qt::EditRole)
143
+ if index.valid? and role == Qt::EditRole
144
+ raise "invalid column #{index.column}" if (index.column < 0 ||
145
+ index.column >= @keys.size)
146
+
147
+ att = @keys[index.column]
148
+ item = index.internalPointer
149
+
150
+ if ! item.itemData.has_key? att
151
+ return false
152
+ end
153
+
154
+ value = variant.value
155
+
156
+ if value.class.name == "Qt::Date"
157
+ value = Date.new(value.year, value.month, value.day)
158
+ elsif value.class.name == "Qt::Time"
159
+ value = Time.new(value.hour, value.min, value.sec)
160
+ end
161
+
162
+ att.gsub!(/.*\.(.*)/, '\1')
163
+ # Don't allow the primary key to be changed
164
+ if att == 'id'
165
+ return false
166
+ end
167
+
168
+ eval("item.resource.attributes['%s'] = value" % att)
169
+ item.resource.save
170
+ emit dataChanged(index, index)
171
+ return true
172
+ else
173
+ return false
174
+ end
175
+ end
176
+
177
+ def flags(index)
178
+ if !index.valid?
179
+ return Qt::ItemIsEnabled
180
+ end
181
+
182
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable
183
+ end
184
+
185
+ def headerData(section, orientation, role)
186
+ if orientation == Qt::Horizontal && role == Qt::DisplayRole
187
+ return Qt::Variant.new(@labels[@keys[section]])
188
+ end
189
+
190
+ return Qt::Variant.new
191
+ end
192
+
193
+ def index(row, column, parent)
194
+ if !parent.valid?
195
+ parentItem = @rootItem
196
+ else
197
+ parentItem = parent.internalPointer
198
+ end
199
+
200
+ @childItem = parentItem.child(row)
201
+ if ! @childItem.nil?
202
+ return createIndex(row, column, @childItem)
203
+ else
204
+ return Qt::ModelIndex.new
205
+ end
206
+ end
207
+
208
+ def parent(index)
209
+ if !index.valid?
210
+ return Qt::ModelIndex.new
211
+ end
212
+
213
+ childItem = index.internalPointer
214
+ parentItem = childItem.parent
215
+
216
+ if parentItem == @rootItem
217
+ return Qt::ModelIndex.new
218
+ end
219
+
220
+ return createIndex(parentItem.row, 0, parentItem)
221
+ end
222
+
223
+ def rowCount(parent)
224
+ if !parent.valid?
225
+ parentItem = @rootItem
226
+ else
227
+ parentItem = parent.internalPointer
228
+ end
229
+
230
+ return parentItem.childCount
231
+ end
232
+ end
233
+
234
+ # kate: indent-width 4;
@@ -0,0 +1,122 @@
1
+ =begin
2
+ This table model allows an ActiveRecord or ActiveResource to be used as a
3
+ basis for a Qt::AbstractTableModel for viewing in a Qt::TableView. Example
4
+ usage:
5
+
6
+ app = Qt::Application.new(ARGV)
7
+ agencies = TravelAgency.find(:all, :conditions => [:name => 'Another Agency'])
8
+ model = ActiveTableModel.new(agencies)
9
+ table = Qt::TableView.new
10
+ table.model = model
11
+ table.show
12
+ app.exec
13
+
14
+ Written by Richard Dale and Silvio Fonseca
15
+
16
+ =end
17
+
18
+ require 'Qt'
19
+ require 'date'
20
+
21
+ class ActiveTableModel < Qt::AbstractTableModel
22
+ def initialize(collection, columns=nil)
23
+ super()
24
+ @collection = collection
25
+ if columns
26
+ if columns.kind_of? Hash
27
+ @keys=columns.keys
28
+ @labels=columns.values
29
+ else
30
+ @keys=columns
31
+ end
32
+ else
33
+ @keys = build_keys([], @collection.first.attributes)
34
+ end
35
+ @labels||=@keys.collect { |k| k.humanize.gsub(/\./, ' ') }
36
+ end
37
+
38
+ def build_keys(keys, attrs, prefix="")
39
+ attrs.inject(keys) do |cols, a|
40
+ if a[1].respond_to? :attributes
41
+ build_keys(cols, a[1].attributes, prefix + a[0] + ".")
42
+ else
43
+ cols << prefix + a[0]
44
+ end
45
+ end
46
+ end
47
+
48
+ def rowCount(parent)
49
+ @collection.size
50
+ end
51
+
52
+ def columnCount(parent)
53
+ @keys.size
54
+ end
55
+
56
+
57
+ def [](row)
58
+ row = row.row if row.is_a?Qt::ModelIndex
59
+ @collection[row]
60
+ end
61
+
62
+ def column(name)
63
+ @keys.index name
64
+ end
65
+
66
+ def data(index, role=Qt::DisplayRole)
67
+ invalid = Qt::Variant.new
68
+ return invalid unless role == Qt::DisplayRole or role == Qt::EditRole
69
+ item = @collection[index.row]
70
+ return invalid if item.nil?
71
+ raise "invalid column #{index.column}" if (index.column < 0 ||
72
+ index.column >= @keys.size)
73
+ value = eval("item.attributes['%s']" % @keys[index.column].gsub(/\./, "'].attributes['"))
74
+ return Qt::Variant.new(value)
75
+ end
76
+
77
+ def headerData(section, orientation, role=Qt::DisplayRole)
78
+ invalid = Qt::Variant.new
79
+ return invalid unless role == Qt::DisplayRole
80
+ v = case orientation
81
+ when Qt::Horizontal
82
+ @labels[section]
83
+ else
84
+ section
85
+ end
86
+ return Qt::Variant.new(v)
87
+ end
88
+
89
+ def flags(index)
90
+ return Qt::ItemIsEditable | super(index)
91
+ end
92
+
93
+ def setData(index, variant, role=Qt::EditRole)
94
+ if index.valid? and role == Qt::EditRole
95
+ att = @keys[index.column]
96
+ # Don't allow the primary key to be changed
97
+ if att == 'id'
98
+ return false
99
+ end
100
+
101
+ item = @collection[index.row]
102
+ raise "invalid column #{index.column}" if (index.column < 0 ||
103
+ index.column >= @keys.size)
104
+ value = variant.value
105
+
106
+ if value.class.name == "Qt::Date"
107
+ value = Date.new(value.year, value.month, value.day)
108
+ elsif value.class.name == "Qt::Time"
109
+ value = Time.new(value.hour, value.min, value.sec)
110
+ end
111
+
112
+ eval("item['%s'] = value" % att.gsub(/\./, "']['"))
113
+ item.save
114
+ emit dataChanged(index, index)
115
+ return true
116
+ else
117
+ return false
118
+ end
119
+ end
120
+ end
121
+
122
+ # kate: indent-width 4;
@@ -3,16 +3,16 @@
3
3
  qtruby.rb - description
4
4
  -------------------
5
5
  begin : Fri Jul 4 2003
6
- copyright : (C) 2003-2005 by Richard Dale
7
- email : Richard_Dale@tipitina.demon.co.uk
6
+ copyright : (C) 2003-2008 by Richard Dale
7
+ email : richard.j.dale@gmail.com
8
8
  ***************************************************************************/
9
9
 
10
10
  /***************************************************************************
11
11
  * *
12
12
  * This program is free software; you can redistribute it and/or modify *
13
- * it under the terms of the GNU General Public License as published by *
14
- * the Free Software Foundation; either version 2 of the License, or *
15
- * (at your option) any later version. *
13
+ * it under the terms of the GNU Lesser General Public License as *
14
+ * published by the Free Software Foundation; either version 2 of the *
15
+ * License, or (at your option) any later version. *
16
16
  * *
17
17
  ***************************************************************************/
18
18
  =end
@@ -42,29 +42,50 @@ module Qt
42
42
  def Qt.debug_level
43
43
  @@debug_level
44
44
  end
45
-
45
+
46
+ module Internal
47
+ #
48
+ # From the enum MethodFlags in qt-copy/src/tools/moc/generator.cpp
49
+ #
50
+ AccessPrivate = 0x00
51
+ AccessProtected = 0x01
52
+ AccessPublic = 0x02
53
+ MethodMethod = 0x00
54
+ MethodSignal = 0x04
55
+ MethodSlot = 0x08
56
+ MethodCompatibility = 0x10
57
+ MethodCloned = 0x20
58
+ MethodScriptable = 0x40
59
+ end
60
+
46
61
  class Base
47
62
  def self.signals(*signal_list)
48
63
  meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
49
- meta.add_signals(signal_list)
64
+ meta.add_signals(signal_list, Internal::MethodSignal | Internal::AccessProtected)
50
65
  meta.changed = true
51
66
  end
52
67
 
53
68
  def self.slots(*slot_list)
54
69
  meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
55
- meta.add_slots(slot_list)
70
+ meta.add_slots(slot_list, Internal::MethodSlot | Internal::AccessPublic)
71
+ meta.changed = true
72
+ end
73
+
74
+ def self.private_slots(*slot_list)
75
+ meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
76
+ meta.add_slots(slot_list, Internal::MethodSlot | Internal::AccessPrivate)
56
77
  meta.changed = true
57
78
  end
58
79
 
59
80
  def self.q_signal(signal)
60
81
  meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
61
- meta.add_signals([signal])
82
+ meta.add_signals([signal], Internal::MethodSignal | Internal::AccessProtected)
62
83
  meta.changed = true
63
84
  end
64
85
 
65
86
  def self.q_slot(slot)
66
87
  meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
67
- meta.add_slots([slot])
88
+ meta.add_slots([slot], Internal::MethodSlot | Internal::AccessPublic)
68
89
  meta.changed = true
69
90
  end
70
91
 
@@ -151,6 +172,7 @@ module Qt
151
172
  # Object has a '==' operator instance method, so pretend it
152
173
  # don't exist by calling method_missing() explicitely
153
174
  def ==(a)
175
+ return false if a.nil?
154
176
  begin
155
177
  Qt::method_missing(:==, self, a)
156
178
  rescue
@@ -158,6 +180,33 @@ module Qt
158
180
  end
159
181
  end
160
182
 
183
+ def self.ancestors
184
+ klass = self
185
+ classid = nil
186
+ loop do
187
+ classid = Qt::Internal::find_pclassid(klass.name)
188
+ break if classid.index
189
+
190
+ klass = klass.superclass
191
+ if klass.nil?
192
+ return super
193
+ end
194
+ end
195
+
196
+ klasses = super
197
+ klasses.delete(Qt::Base)
198
+ klasses.delete(self)
199
+ ids = []
200
+ Qt::Internal::getAllParents(classid, ids)
201
+ return [self] + ids.map {|id| Qt::Internal.find_class(Qt::Internal.classid2name(id))} + klasses
202
+ end
203
+
204
+ # Change the behaviors of is_a? and kind_of? (alias of is_a?) to use above self.ancestors method
205
+ # Note: this definition also affects Object#===
206
+ def is_a?(mod)
207
+ super || self.class.ancestors.include?(mod)
208
+ end
209
+ alias :kind_of? :is_a?
161
210
 
162
211
  def methods(regular=true)
163
212
  if !regular
@@ -194,6 +243,177 @@ module Qt
194
243
  return meths.uniq
195
244
  end
196
245
  end # Qt::Base
246
+
247
+ # Provides a mutable numeric class for passing to methods with
248
+ # C++ 'int*' or 'int&' arg types
249
+ class Integer
250
+ attr_accessor :value
251
+ def initialize(n=0) @value = n end
252
+
253
+ def +(n)
254
+ return Integer.new(@value + n.to_i)
255
+ end
256
+ def -(n)
257
+ return Integer.new(@value - n.to_i)
258
+ end
259
+ def *(n)
260
+ return Integer.new(@value * n.to_i)
261
+ end
262
+ def /(n)
263
+ return Integer.new(@value / n.to_i)
264
+ end
265
+ def %(n)
266
+ return Integer.new(@value % n.to_i)
267
+ end
268
+ def **(n)
269
+ return Integer.new(@value ** n.to_i)
270
+ end
271
+
272
+ def |(n)
273
+ return Integer.new(@value | n.to_i)
274
+ end
275
+ def &(n)
276
+ return Integer.new(@value & n.to_i)
277
+ end
278
+ def ^(n)
279
+ return Integer.new(@value ^ n.to_i)
280
+ end
281
+ def <<(n)
282
+ return Integer.new(@value << n.to_i)
283
+ end
284
+ def >>(n)
285
+ return Integer.new(@value >> n.to_i)
286
+ end
287
+ def >(n)
288
+ return @value > n.to_i
289
+ end
290
+ def >=(n)
291
+ return @value >= n.to_i
292
+ end
293
+ def <(n)
294
+ return @value < n.to_i
295
+ end
296
+ def <=(n)
297
+ return @value <= n.to_i
298
+ end
299
+
300
+ def <=>(n)
301
+ if @value < n.to_i
302
+ return -1
303
+ elsif @value > n.to_i
304
+ return 1
305
+ else
306
+ return 0
307
+ end
308
+ end
309
+
310
+ def to_f() return @value.to_f end
311
+ def to_i() return @value.to_i end
312
+ def to_s() return @value.to_s end
313
+
314
+ def coerce(n)
315
+ [n, @value]
316
+ end
317
+ end
318
+
319
+ # If a C++ enum was converted to an ordinary ruby Integer, the
320
+ # name of the type is lost. The enum type name is needed for overloaded
321
+ # method resolution when two methods differ only by an enum type.
322
+ class Enum
323
+ attr_accessor :type, :value
324
+ def initialize(n, enum_type)
325
+ @value = n
326
+ @type = enum_type
327
+ end
328
+
329
+ def +(n)
330
+ return @value + n.to_i
331
+ end
332
+ def -(n)
333
+ return @value - n.to_i
334
+ end
335
+ def *(n)
336
+ return @value * n.to_i
337
+ end
338
+ def /(n)
339
+ return @value / n.to_i
340
+ end
341
+ def %(n)
342
+ return @value % n.to_i
343
+ end
344
+ def **(n)
345
+ return @value ** n.to_i
346
+ end
347
+
348
+ def |(n)
349
+ return Enum.new(@value | n.to_i, @type)
350
+ end
351
+ def &(n)
352
+ return Enum.new(@value & n.to_i, @type)
353
+ end
354
+ def ^(n)
355
+ return Enum.new(@value ^ n.to_i, @type)
356
+ end
357
+ def ~()
358
+ return ~ @value
359
+ end
360
+ def <(n)
361
+ return @value < n.to_i
362
+ end
363
+ def <=(n)
364
+ return @value <= n.to_i
365
+ end
366
+ def >(n)
367
+ return @value > n.to_i
368
+ end
369
+ def >=(n)
370
+ return @value >= n.to_i
371
+ end
372
+ def <<(n)
373
+ return Enum.new(@value << n.to_i, @type)
374
+ end
375
+ def >>(n)
376
+ return Enum.new(@value >> n.to_i, @type)
377
+ end
378
+
379
+ def ==(n) return @value == n.to_i end
380
+ def to_i() return @value end
381
+
382
+ def to_f() return @value.to_f end
383
+ def to_s() return @value.to_s end
384
+
385
+ def coerce(n)
386
+ [n, @value]
387
+ end
388
+
389
+ def inspect
390
+ to_s
391
+ end
392
+
393
+ def pretty_print(pp)
394
+ pp.text "#<%s:0x%8.8x @type=%s, @value=%d>" % [self.class.name, object_id, type, value]
395
+ end
396
+ end
397
+
398
+ # Provides a mutable boolean class for passing to methods with
399
+ # C++ 'bool*' or 'bool&' arg types
400
+ class Boolean
401
+ attr_accessor :value
402
+ def initialize(b=false) @value = b end
403
+ def nil?
404
+ return !@value
405
+ end
406
+ end
407
+
408
+ class AbstractSlider < Qt::Base
409
+ def range=(arg)
410
+ if arg.kind_of? Range
411
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
412
+ else
413
+ return super(arg)
414
+ end
415
+ end
416
+ end
197
417
 
198
418
  class AbstractSocket < Qt::Base
199
419
  def abort(*args)
@@ -234,6 +454,14 @@ module Qt
234
454
  end
235
455
 
236
456
  class Application < Qt::Base
457
+ def initialize(*args)
458
+ if args.length == 1 && args[0].kind_of?(Array)
459
+ super(args.length + 1, [$0] + args[0])
460
+ else
461
+ super(*args)
462
+ end
463
+ $qApp = self
464
+ end
237
465
  # Delete the underlying C++ instance after exec returns
238
466
  # Otherwise, rb_gc_call_finalizer_at_exit() can delete
239
467
  # stuff that Qt::Application still needs for its cleanup.
@@ -261,6 +489,14 @@ module Qt
261
489
  end
262
490
 
263
491
  class ByteArray < Qt::Base
492
+ def initialize(*args)
493
+ if args.size == 1 && args[0].kind_of?(String)
494
+ super(args[0], args[0].size)
495
+ else
496
+ super
497
+ end
498
+ end
499
+
264
500
  def to_s
265
501
  return constData()
266
502
  end
@@ -345,12 +581,28 @@ module Qt
345
581
  end
346
582
 
347
583
  class CoreApplication < Qt::Base
584
+ def initialize(*args)
585
+ if args.length == 1 && args[0].kind_of?(Array)
586
+ super(args.length + 1, [$0] + args[0])
587
+ else
588
+ super(*args)
589
+ end
590
+ $qApp = self
591
+ end
592
+
593
+ # Delete the underlying C++ instance after exec returns
594
+ # Otherwise, rb_gc_call_finalizer_at_exit() can delete
595
+ # stuff that Qt::Application still needs for its cleanup.
348
596
  def exec
349
597
  method_missing(:exec)
350
598
  self.dispose
351
599
  Qt::Internal.application_terminated = true
352
600
  end
353
601
 
602
+ def type(*args)
603
+ method_missing(:type, *args)
604
+ end
605
+
354
606
  def exit(*args)
355
607
  method_missing(:exit, *args)
356
608
  end
@@ -375,7 +627,6 @@ module Qt
375
627
  end
376
628
 
377
629
  class Date < Qt::Base
378
-
379
630
  def initialize(*args)
380
631
  if args.size == 1 && args[0].class.name == "Date"
381
632
  return super(args[0].year, args[0].month, args[0].day)
@@ -393,6 +644,10 @@ module Qt
393
644
  str = to_s
394
645
  pp.text str.sub(/>$/, " %s>" % toString)
395
646
  end
647
+
648
+ def to_date
649
+ ::Date.new! to_julian_day
650
+ end
396
651
  end
397
652
 
398
653
  class DateTime < Qt::Base
@@ -400,11 +655,26 @@ module Qt
400
655
  if args.size == 1 && args[0].class.name == "DateTime"
401
656
  return super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
402
657
  Qt::Time.new(args[0].hour, args[0].min, args[0].sec) )
658
+ elsif args.size == 1 && args[0].class.name == "Time"
659
+ result = super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
660
+ Qt::Time.new(args[0].hour, args[0].min, args[0].sec, args[0].usec / 1000) )
661
+ result.timeSpec = (args[0].utc? ? Qt::UTC : Qt::LocalTime)
662
+ return result
403
663
  else
404
664
  return super(*args)
405
665
  end
406
666
  end
407
667
 
668
+ def to_time
669
+ if timeSpec == Qt::UTC
670
+ return ::Time.utc( date.year, date.month, date.day,
671
+ time.hour, time.minute, time.second, time.msec * 1000 )
672
+ else
673
+ return ::Time.local( date.year, date.month, date.day,
674
+ time.hour, time.minute, time.second, time.msec * 1000 )
675
+ end
676
+ end
677
+
408
678
  def inspect
409
679
  str = super
410
680
  str.sub(/>$/, " %s>" % toString)
@@ -416,6 +686,18 @@ module Qt
416
686
  end
417
687
  end
418
688
 
689
+ class DBusArgument < Qt::Base
690
+ def inspect
691
+ str = super
692
+ str.sub(/>$/, " currentSignature='%s', atEnd=%s>" % [currentSignature, atEnd])
693
+ end
694
+
695
+ def pretty_print(pp)
696
+ str = to_s
697
+ pp.text str.sub(/>$/, " currentSignature='%s, atEnd=%s'>" % [currentSignature, atEnd])
698
+ end
699
+ end
700
+
419
701
  class DBusConnection < Qt::Base
420
702
  def send(*args)
421
703
  method_missing(:send, *args)
@@ -459,10 +741,13 @@ module Qt
459
741
  end
460
742
 
461
743
  class DBusInterface < Qt::Base
462
-
463
744
  def call(method_name, *args)
464
745
  if args.length == 0
465
746
  return super(method_name)
747
+ elsif method_name.is_a? Qt::Enum
748
+ opt = args.shift
749
+ qdbusArgs = args.collect {|arg| qVariantFromValue(arg)}
750
+ return super(method_name, opt, *qdbusArgs)
466
751
  else
467
752
  # If the method is Qt::DBusInterface.call(), create an Array
468
753
  # 'dbusArgs' of Qt::Variants from '*args'
@@ -494,7 +779,13 @@ module Qt
494
779
  def value
495
780
  if type() == Qt::DBusMessage::ReplyMessage
496
781
  reply = arguments()
497
- return reply.length > 0 ? reply[0].value : nil
782
+ if reply.length == 0
783
+ return nil
784
+ elsif reply.length == 1
785
+ return reply[0].value
786
+ else
787
+ return reply.collect {|v| v.value}
788
+ end
498
789
  else
499
790
  return nil
500
791
  end
@@ -546,18 +837,52 @@ module Qt
546
837
  end
547
838
  end
548
839
 
840
+ class Dial < Qt::Base
841
+ def range=(arg)
842
+ if arg.kind_of? Range
843
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
844
+ else
845
+ return super(arg)
846
+ end
847
+ end
848
+ end
849
+
549
850
  class Dialog < Qt::Base
550
851
  def exec(*args)
551
852
  method_missing(:exec, *args)
552
853
  end
553
854
  end
554
855
 
856
+ class Dir < Qt::Base
857
+ Time = Qt::Enum.new(1, "QDir::SortFlag")
858
+ end
859
+
555
860
  class DomAttr < Qt::Base
556
861
  def name(*args)
557
862
  method_missing(:name, *args)
558
863
  end
559
864
  end
560
865
 
866
+ class DoubleSpinBox < Qt::Base
867
+ def range=(arg)
868
+ if arg.kind_of? Range
869
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
870
+ else
871
+ return super(arg)
872
+ end
873
+ end
874
+ end
875
+
876
+ class DoubleValidator < Qt::Base
877
+ def range=(arg)
878
+ if arg.kind_of? Range
879
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
880
+ else
881
+ return super(arg)
882
+ end
883
+ end
884
+ end
885
+
561
886
  class DomDocumentType < Qt::Base
562
887
  def name(*args)
563
888
  method_missing(:name, *args)
@@ -618,6 +943,8 @@ module Qt
618
943
  end
619
944
 
620
945
  class FileIconProvider < Qt::Base
946
+ File = Qt::Enum.new(6, "QFileIconProvider::IconType")
947
+
621
948
  def type(*args)
622
949
  method_missing(:type, *args)
623
950
  end
@@ -643,6 +970,10 @@ module Qt
643
970
  end
644
971
  end
645
972
 
973
+ class FontDatabase < Qt::Base
974
+ Symbol = Qt::Enum.new(30, "QFontDatabase::WritingSystem")
975
+ end
976
+
646
977
  class Ftp < Qt::Base
647
978
  def abort(*args)
648
979
  method_missing(:abort, *args)
@@ -691,19 +1022,23 @@ module Qt
691
1022
  end
692
1023
  end
693
1024
 
694
- class GraphicsItemGroup < Qt::Base
1025
+ class GraphicsItemGroup < Qt::Base
1026
+ Type = 10
1027
+
695
1028
  def type(*args)
696
1029
  method_missing(:type, *args)
697
1030
  end
698
1031
  end
699
1032
 
700
- class GraphicsLineItem < Qt::Base
1033
+ class GraphicsLineItem < Qt::Base
1034
+ Type = 6
701
1035
  def type(*args)
702
1036
  method_missing(:type, *args)
703
1037
  end
704
1038
  end
705
1039
 
706
1040
  class GraphicsPathItem < Qt::Base
1041
+ Type = 2
707
1042
  def type(*args)
708
1043
  method_missing(:type, *args)
709
1044
  end
@@ -715,13 +1050,22 @@ module Qt
715
1050
  end
716
1051
  end
717
1052
 
718
- class GraphicsPolygonItem < Qt::Base
1053
+ class GraphicsPolygonItem < Qt::Base
1054
+ Type = 5
1055
+ def type(*args)
1056
+ method_missing(:type, *args)
1057
+ end
1058
+ end
1059
+
1060
+ class GraphicsProxyWidget < Qt::Base
1061
+ Type = 12
719
1062
  def type(*args)
720
1063
  method_missing(:type, *args)
721
1064
  end
722
1065
  end
723
1066
 
724
1067
  class GraphicsRectItem < Qt::Base
1068
+ Type = 3
725
1069
  def type(*args)
726
1070
  method_missing(:type, *args)
727
1071
  end
@@ -758,12 +1102,28 @@ module Qt
758
1102
  end
759
1103
 
760
1104
  class GraphicsSimpleTextItem < Qt::Base
1105
+ Type = 9
1106
+ def type(*args)
1107
+ method_missing(:type, *args)
1108
+ end
1109
+ end
1110
+
1111
+ class GraphicsSvgItem < Qt::Base
1112
+ Type = 13
1113
+ def type(*args)
1114
+ method_missing(:type, *args)
1115
+ end
1116
+ end
1117
+
1118
+ class GraphicsTextItem < Qt::Base
1119
+ Type = 8
761
1120
  def type(*args)
762
1121
  method_missing(:type, *args)
763
1122
  end
764
1123
  end
765
1124
 
766
- class GraphicsTextItem < Qt::Base
1125
+ class GraphicsWidget < Qt::Base
1126
+ Type = 11
767
1127
  def type(*args)
768
1128
  method_missing(:type, *args)
769
1129
  end
@@ -863,7 +1223,26 @@ module Qt
863
1223
  end
864
1224
  end
865
1225
 
1226
+ class IntValidator < Qt::Base
1227
+ def range=(arg)
1228
+ if arg.kind_of? Range
1229
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1230
+ else
1231
+ return super(arg)
1232
+ end
1233
+ end
1234
+ end
1235
+
866
1236
  class ItemSelection < Qt::Base
1237
+ include Enumerable
1238
+
1239
+ def each
1240
+ for i in 0...count
1241
+ yield at(i)
1242
+ end
1243
+ return self
1244
+ end
1245
+
867
1246
  def select(*args)
868
1247
  method_missing(:select, *args)
869
1248
  end
@@ -879,6 +1258,12 @@ module Qt
879
1258
  end
880
1259
  end
881
1260
 
1261
+ class KeyEvent < Qt::Base
1262
+ def type(*args)
1263
+ method_missing(:type, *args)
1264
+ end
1265
+ end
1266
+
882
1267
  class KeySequence < Qt::Base
883
1268
  def initialize(*args)
884
1269
  if args.length == 1 && args[0].kind_of?(Qt::Enum) && args[0].type == "Qt::Key"
@@ -886,6 +1271,16 @@ module Qt
886
1271
  end
887
1272
  return super(*args)
888
1273
  end
1274
+
1275
+ def inspect
1276
+ str = super
1277
+ str.sub(/>$/, " %s>" % toString)
1278
+ end
1279
+
1280
+ def pretty_print(pp)
1281
+ str = to_s
1282
+ pp.text str.sub(/>$/, " %s>" % toString)
1283
+ end
889
1284
  end
890
1285
 
891
1286
  class LCDNumber < Qt::Base
@@ -902,7 +1297,7 @@ module Qt
902
1297
 
903
1298
  class ListWidgetItem < Qt::Base
904
1299
  def clone(*args)
905
- method_missing(:clone, *args)
1300
+ Qt::ListWidgetItem.new(self)
906
1301
  end
907
1302
 
908
1303
  def type(*args)
@@ -911,12 +1306,12 @@ module Qt
911
1306
 
912
1307
  def inspect
913
1308
  str = super
914
- str.sub(/>$/, " text=%s>" % text)
1309
+ str.sub(/>$/, " text='%s'>" % text)
915
1310
  end
916
1311
 
917
1312
  def pretty_print(pp)
918
1313
  str = to_s
919
- pp.text str.sub(/>$/, " text=%s>" % text)
1314
+ pp.text str.sub(/>$/, " text='%s'>" % text)
920
1315
  end
921
1316
  end
922
1317
 
@@ -973,7 +1368,8 @@ module Qt
973
1368
  class MetaMethod < Qt::Base
974
1369
  # Oops, name clash with the Signal module so hard code
975
1370
  # this value rather than get it from the Smoke runtime
976
- Signal = 1
1371
+ Method = Qt::Enum.new(0, "QMetaMethod::MethodType")
1372
+ Signal = Qt::Enum.new(1, "QMetaMethod::MethodType")
977
1373
  end
978
1374
 
979
1375
  class MetaObject < Qt::Base
@@ -1101,6 +1497,8 @@ module Qt
1101
1497
  end
1102
1498
 
1103
1499
  class MetaType < Qt::Base
1500
+ Float = Qt::Enum.new(135, "QMetaType::Type")
1501
+
1104
1502
  def load(*args)
1105
1503
  method_missing(:load, *args)
1106
1504
  end
@@ -1176,24 +1574,46 @@ module Qt
1176
1574
  class Point < Qt::Base
1177
1575
  def inspect
1178
1576
  str = super
1179
- str.sub(/>$/, " x=%d, y=%d>" % [x, y])
1577
+ str.sub(/>$/, " x=%d, y=%d>" % [self.x, self.y])
1180
1578
  end
1181
1579
 
1182
1580
  def pretty_print(pp)
1183
1581
  str = to_s
1184
- pp.text str.sub(/>$/, "\n x=%d,\n y=%d>" % [x, y])
1582
+ pp.text str.sub(/>$/, "\n x=%d,\n y=%d>" % [self.x, self.y])
1185
1583
  end
1186
1584
  end
1187
1585
 
1188
1586
  class PointF < Qt::Base
1189
1587
  def inspect
1190
1588
  str = super
1191
- str.sub(/>$/, " x=%f, y=%f>" % [x, y])
1589
+ str.sub(/>$/, " x=%f, y=%f>" % [self.x, self.y])
1192
1590
  end
1193
1591
 
1194
1592
  def pretty_print(pp)
1195
1593
  str = to_s
1196
- pp.text str.sub(/>$/, "\n x=%f,\n y=%f>" % [x, y])
1594
+ pp.text str.sub(/>$/, "\n x=%f,\n y=%f>" % [self.x, self.y])
1595
+ end
1596
+ end
1597
+
1598
+ class Polygon < Qt::Base
1599
+ include Enumerable
1600
+
1601
+ def each
1602
+ for i in 0...count
1603
+ yield point(i)
1604
+ end
1605
+ return self
1606
+ end
1607
+ end
1608
+
1609
+ class PolygonF < Qt::Base
1610
+ include Enumerable
1611
+
1612
+ def each
1613
+ for i in 0...count
1614
+ yield point(i)
1615
+ end
1616
+ return self
1197
1617
  end
1198
1618
  end
1199
1619
 
@@ -1203,6 +1623,30 @@ module Qt
1203
1623
  end
1204
1624
  end
1205
1625
 
1626
+ class Process < Qt::Base
1627
+ StandardError = Qt::Enum.new(1, "QProcess::ProcessChannel")
1628
+ end
1629
+
1630
+ class ProgressBar < Qt::Base
1631
+ def range=(arg)
1632
+ if arg.kind_of? Range
1633
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1634
+ else
1635
+ return super(arg)
1636
+ end
1637
+ end
1638
+ end
1639
+
1640
+ class ProgressDialog < Qt::Base
1641
+ def range=(arg)
1642
+ if arg.kind_of? Range
1643
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1644
+ else
1645
+ return super(arg)
1646
+ end
1647
+ end
1648
+ end
1649
+
1206
1650
  class Printer < Qt::Base
1207
1651
  def abort(*args)
1208
1652
  method_missing(:abort, *args)
@@ -1282,24 +1726,24 @@ module Qt
1282
1726
  class Rect < Qt::Base
1283
1727
  def inspect
1284
1728
  str = super
1285
- str.sub(/>$/, " left=%d, right=%d, top=%d, bottom=%d>" % [left, right, top, bottom])
1729
+ str.sub(/>$/, " x=%d, y=%d, width=%d, height=%d>" % [self.x, self.y, width, height])
1286
1730
  end
1287
1731
 
1288
1732
  def pretty_print(pp)
1289
1733
  str = to_s
1290
- pp.text str.sub(/>$/, "\n left=%d,\n right=%d,\n top=%d,\n bottom=%d>" % [left, right, top, bottom])
1734
+ pp.text str.sub(/>$/, "\n x=%d,\n y=%d,\n width=%d,\n height=%d>" % [self.x, self.y, width, height])
1291
1735
  end
1292
1736
  end
1293
1737
 
1294
1738
  class RectF < Qt::Base
1295
1739
  def inspect
1296
1740
  str = super
1297
- str.sub(/>$/, " left=%f, right=%f, top=%f, bottom=%f>" % [left, right, top, bottom])
1741
+ str.sub(/>$/, " x=%f, y=%f, width=%f, height=%f>" % [self.x, self.y, width, height])
1298
1742
  end
1299
1743
 
1300
1744
  def pretty_print(pp)
1301
1745
  str = to_s
1302
- pp.text str.sub(/>$/, "\n left=%f,\n right=%f,\n top=%f,\n bottom=%f>" % [left, right, top, bottom])
1746
+ pp.text str.sub(/>$/, "\n x=%f,\n y=%f,\n width=%f,\n height=%f>" % [self.x, self.y, width, height])
1303
1747
  end
1304
1748
  end
1305
1749
 
@@ -1309,6 +1753,16 @@ module Qt
1309
1753
  end
1310
1754
  end
1311
1755
 
1756
+ class ScrollBar < Qt::Base
1757
+ def range=(arg)
1758
+ if arg.kind_of? Range
1759
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1760
+ else
1761
+ return super(arg)
1762
+ end
1763
+ end
1764
+ end
1765
+
1312
1766
  class Shortcut < Qt::Base
1313
1767
  def id(*args)
1314
1768
  method_missing(:id, *args)
@@ -1354,21 +1808,43 @@ module Qt
1354
1808
  class SizePolicy < Qt::Base
1355
1809
  def inspect
1356
1810
  str = super
1357
- str.sub(/>$/, " horData=%d, verData=%d>" % [horData, verData])
1811
+ str.sub(/>$/, " horizontalPolicy=%d, verticalPolicy=%d>" % [horizontalPolicy, verticalPolicy])
1358
1812
  end
1359
1813
 
1360
1814
  def pretty_print(pp)
1361
1815
  str = to_s
1362
- pp.text str.sub(/>$/, "\n horData=%d,\n verData=%d>" % [horData, verData])
1816
+ pp.text str.sub(/>$/, "\n horizontalPolicy=%d,\n verticalPolicy=%d>" % [horizontalPolicy, verticalPolicy])
1817
+ end
1818
+ end
1819
+
1820
+ class Slider < Qt::Base
1821
+ def range=(arg)
1822
+ if arg.kind_of? Range
1823
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1824
+ else
1825
+ return super(arg)
1826
+ end
1363
1827
  end
1364
1828
  end
1365
1829
 
1366
1830
  class SocketNotifier < Qt::Base
1831
+ Exception = Qt::Enum.new(2, "QSocketNotifier::Type")
1832
+
1367
1833
  def type(*args)
1368
1834
  method_missing(:type, *args)
1369
1835
  end
1370
1836
  end
1371
1837
 
1838
+ class SpinBox < Qt::Base
1839
+ def range=(arg)
1840
+ if arg.kind_of? Range
1841
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
1842
+ else
1843
+ return super(arg)
1844
+ end
1845
+ end
1846
+ end
1847
+
1372
1848
  class SqlDatabase < Qt::Base
1373
1849
  def exec(*args)
1374
1850
  method_missing(:exec, *args)
@@ -1420,9 +1896,23 @@ module Qt
1420
1896
  end
1421
1897
 
1422
1898
  class StandardItem < Qt::Base
1899
+ def inspect
1900
+ str = super
1901
+ str.sub(/>$/, " text='%s'>" % [text])
1902
+ end
1903
+
1904
+ def pretty_print(pp)
1905
+ str = to_s
1906
+ pp.text str.sub(/>$/, "\n text='%s'>" % [text])
1907
+ end
1908
+
1423
1909
  def type(*args)
1424
1910
  method_missing(:type, *args)
1425
1911
  end
1912
+
1913
+ def clone
1914
+ Qt::StandardItem.new(self)
1915
+ end
1426
1916
  end
1427
1917
 
1428
1918
  class StandardItemModel < Qt::Base
@@ -1457,7 +1947,7 @@ module Qt
1457
1947
 
1458
1948
  class TableWidgetItem < Qt::Base
1459
1949
  def clone(*args)
1460
- method_missing(:clone, *args)
1950
+ Qt::TableWidgetItem.new(self)
1461
1951
  end
1462
1952
 
1463
1953
  def type(*args)
@@ -1466,12 +1956,12 @@ module Qt
1466
1956
 
1467
1957
  def inspect
1468
1958
  str = super
1469
- str.sub(/>$/, " text=%s>" % text)
1959
+ str.sub(/>$/, " text='%s'>" % text)
1470
1960
  end
1471
1961
 
1472
1962
  def pretty_print(pp)
1473
1963
  str = to_s
1474
- pp.text str.sub(/>$/, " text=%s>" % text)
1964
+ pp.text str.sub(/>$/, " text='%s'>" % text)
1475
1965
  end
1476
1966
  end
1477
1967
 
@@ -1571,6 +2061,16 @@ module Qt
1571
2061
  end
1572
2062
  end
1573
2063
 
2064
+ class TimeLine < Qt::Base
2065
+ def frameRange=(arg)
2066
+ if arg.kind_of? Range
2067
+ return super(arg.begin, arg.exclude_end? ? arg.end - 1 : arg.end)
2068
+ else
2069
+ return super(arg)
2070
+ end
2071
+ end
2072
+ end
2073
+
1574
2074
  class ToolButton < Qt::Base
1575
2075
  def setShortcut(arg)
1576
2076
  if arg.kind_of?(String)
@@ -1624,7 +2124,7 @@ module Qt
1624
2124
  str.sub!(/>$/, "")
1625
2125
  str << " parent=%s," % parent unless parent.nil?
1626
2126
  for i in 0..(columnCount - 1)
1627
- str << " text%d=%s," % [i, self.text(i)]
2127
+ str << " text%d='%s'," % [i, self.text(i)]
1628
2128
  end
1629
2129
  str.sub!(/,?$/, ">")
1630
2130
  end
@@ -1634,14 +2134,14 @@ module Qt
1634
2134
  str.sub!(/>$/, "")
1635
2135
  str << " parent=%s," % parent unless parent.nil?
1636
2136
  for i in 0..(columnCount - 1)
1637
- str << " text%d=%s," % [i, self.text(i)]
2137
+ str << " text%d='%s'," % [i, self.text(i)]
1638
2138
  end
1639
2139
  str.sub!(/,?$/, ">")
1640
2140
  pp.text str
1641
2141
  end
1642
2142
 
1643
2143
  def clone(*args)
1644
- method_missing(:clone, *args)
2144
+ Qt::TreeWidgetItem.new(self)
1645
2145
  end
1646
2146
 
1647
2147
  def type(*args)
@@ -1663,17 +2163,33 @@ module Qt
1663
2163
  end
1664
2164
  end
1665
2165
 
2166
+ class Url < Qt::Base
2167
+ def inspect
2168
+ str = super
2169
+ str.sub(/>$/, " url=%s>" % toString)
2170
+ end
2171
+
2172
+ def pretty_print(pp)
2173
+ str = to_s
2174
+ pp.text str.sub(/>$/, " url=%s>" % toString)
2175
+ end
2176
+ end
2177
+
1666
2178
  class UrlInfo < Qt::Base
1667
2179
  def name(*args)
1668
2180
  method_missing(:name, *args)
1669
2181
  end
1670
2182
  end
1671
2183
 
2184
+ class Uuid < Qt::Base
2185
+ Time = Qt::Enum.new(1, "QUuid::Version")
2186
+ end
2187
+
1672
2188
  class Variant < Qt::Base
1673
- String = 10
1674
- Date = 14
1675
- Time = 15
1676
- DateTime = 16
2189
+ String = Qt::Enum.new(10, "QVariant::Type")
2190
+ Date = Qt::Enum.new(14, "QVariant::Type")
2191
+ Time = Qt::Enum.new(15, "QVariant::Type")
2192
+ DateTime = Qt::Enum.new(16, "QVariant::Type")
1677
2193
 
1678
2194
  def initialize(*args)
1679
2195
  if args.size == 1 && args[0].nil?
@@ -1685,6 +2201,8 @@ module Qt
1685
2201
  Qt::Time.new(args[0].hour, args[0].min, args[0].sec) ) )
1686
2202
  elsif args.size == 1 && args[0].class.name == "Time"
1687
2203
  return super(Qt::Time.new(args[0]))
2204
+ elsif args.size == 1 && args[0].class.name == "BigDecimal"
2205
+ return super(args[0].to_f) # we have to make do with a float
1688
2206
  else
1689
2207
  return super(*args)
1690
2208
  end
@@ -1708,6 +2226,8 @@ module Qt
1708
2226
 
1709
2227
  def value
1710
2228
  case type()
2229
+ when Qt::Variant::Invalid
2230
+ return nil
1711
2231
  when Qt::Variant::Bitmap
1712
2232
  when Qt::Variant::Bool
1713
2233
  return toBool
@@ -1793,12 +2313,7 @@ module Qt
1793
2313
  return toUrl
1794
2314
  end
1795
2315
 
1796
- case typeName()
1797
- when "QDBusArgument"
1798
- return qVariantValue(Qt::DBusArgument, self)
1799
- when "QDBusVariant"
1800
- return qVariantValue(Qt::Variant, self)
1801
- end
2316
+ return qVariantValue(nil, self)
1802
2317
  end
1803
2318
 
1804
2319
  def inspect
@@ -1864,168 +2379,6 @@ module Qt
1864
2379
  method_missing(:type, *args)
1865
2380
  end
1866
2381
  end
1867
-
1868
- # Provides a mutable numeric class for passing to methods with
1869
- # C++ 'int*' or 'int&' arg types
1870
- class Integer
1871
- attr_accessor :value
1872
- def initialize(n=0) @value = n end
1873
-
1874
- def +(n)
1875
- return Integer.new(@value + n.to_i)
1876
- end
1877
- def -(n)
1878
- return Integer.new(@value - n.to_i)
1879
- end
1880
- def *(n)
1881
- return Integer.new(@value * n.to_i)
1882
- end
1883
- def /(n)
1884
- return Integer.new(@value / n.to_i)
1885
- end
1886
- def %(n)
1887
- return Integer.new(@value % n.to_i)
1888
- end
1889
- def **(n)
1890
- return Integer.new(@value ** n.to_i)
1891
- end
1892
-
1893
- def |(n)
1894
- return Integer.new(@value | n.to_i)
1895
- end
1896
- def &(n)
1897
- return Integer.new(@value & n.to_i)
1898
- end
1899
- def ^(n)
1900
- return Integer.new(@value ^ n.to_i)
1901
- end
1902
- def <<(n)
1903
- return Integer.new(@value << n.to_i)
1904
- end
1905
- def >>(n)
1906
- return Integer.new(@value >> n.to_i)
1907
- end
1908
- def >(n)
1909
- return @value > n.to_i
1910
- end
1911
- def >=(n)
1912
- return @value >= n.to_i
1913
- end
1914
- def <(n)
1915
- return @value < n.to_i
1916
- end
1917
- def <=(n)
1918
- return @value <= n.to_i
1919
- end
1920
-
1921
- def <=>(n)
1922
- if @value < n.to_i
1923
- return -1
1924
- elsif @value > n.to_i
1925
- return 1
1926
- else
1927
- return 0
1928
- end
1929
- end
1930
-
1931
- def to_f() return @value.to_f end
1932
- def to_i() return @value.to_i end
1933
- def to_s() return @value.to_s end
1934
-
1935
- def coerce(n)
1936
- [n, @value]
1937
- end
1938
- end
1939
-
1940
- # If a C++ enum was converted to an ordinary ruby Integer, the
1941
- # name of the type is lost. The enum type name is needed for overloaded
1942
- # method resolution when two methods differ only by an enum type.
1943
- class Enum
1944
- attr_accessor :type, :value
1945
- def initialize(n, type)
1946
- super()
1947
- @value = n
1948
- @type = type
1949
- end
1950
-
1951
- def +(n)
1952
- return @value + n.to_i
1953
- end
1954
- def -(n)
1955
- return @value - n.to_i
1956
- end
1957
- def *(n)
1958
- return @value * n.to_i
1959
- end
1960
- def /(n)
1961
- return @value / n.to_i
1962
- end
1963
- def %(n)
1964
- return @value % n.to_i
1965
- end
1966
- def **(n)
1967
- return @value ** n.to_i
1968
- end
1969
-
1970
- def |(n)
1971
- return Enum.new(@value | n.to_i, @type)
1972
- end
1973
- def &(n)
1974
- return Enum.new(@value & n.to_i, @type)
1975
- end
1976
- def ^(n)
1977
- return Enum.new(@value ^ n.to_i, @type)
1978
- end
1979
- def ~()
1980
- return ~ @value
1981
- end
1982
- def <(n)
1983
- return @value < n.to_i
1984
- end
1985
- def <=(n)
1986
- return @value <= n.to_i
1987
- end
1988
- def >(n)
1989
- return @value > n.to_i
1990
- end
1991
- def >=(n)
1992
- return @value >= n.to_i
1993
- end
1994
- def <<(n)
1995
- return Enum.new(@value << n.to_i, @type)
1996
- end
1997
- def >>(n)
1998
- return Enum.new(@value >> n.to_i, @type)
1999
- end
2000
-
2001
- def ==(n) return @value == n.to_i end
2002
- def to_i() return @value end
2003
-
2004
- def to_f() return @value.to_f end
2005
- def to_s() return @value.to_s end
2006
-
2007
- def coerce(n)
2008
- [n, @value]
2009
- end
2010
-
2011
- def inspect
2012
- to_s
2013
- end
2014
-
2015
- def pretty_print(pp)
2016
- pp.text "#<%s:0x%8.8x @type=%s, @value=%d>" % [self.class.name, object_id, type, value]
2017
- end
2018
- end
2019
-
2020
- # Provides a mutable boolean class for passing to methods with
2021
- # C++ 'bool*' or 'bool&' arg types
2022
- class Boolean
2023
- attr_accessor :value
2024
- def initialize(b=false) @value = b end
2025
- def nil?
2026
- return !@value
2027
- end
2028
- end
2029
2382
 
2030
2383
  class SignalBlockInvocation < Qt::Object
2031
2384
  def initialize(parent, block, signature)
@@ -2033,7 +2386,11 @@ module Qt
2033
2386
  if metaObject.indexOfSlot(signature) == -1
2034
2387
  self.class.slots signature
2035
2388
  end
2389
+ # This makes a difference between being and not being able
2390
+ # to run with GC.stress= true. Reason unclear.
2391
+ gc_disabled= GC.disable
2036
2392
  @block = block
2393
+ GC.enable unless gc_disabled
2037
2394
  end
2038
2395
 
2039
2396
  def invoke(*args)
@@ -2055,40 +2412,90 @@ module Qt
2055
2412
  @target.instance_exec(*args, &@block)
2056
2413
  end
2057
2414
  end
2058
-
2415
+
2416
+ class MethodInvocation < Qt::Object
2417
+ def initialize(target, method, signature)
2418
+ super(target)
2419
+ if metaObject.indexOfSlot(signature) == -1
2420
+ self.class.slots signature
2421
+ end
2422
+ @target = target
2423
+ method = method.intern unless method.is_a?Symbol
2424
+ @method = method
2425
+ end
2426
+
2427
+ def invoke(*args)
2428
+ @target.send @method, *args
2429
+ end
2430
+ end
2431
+
2059
2432
  module Internal
2060
2433
  @@classes = {}
2061
2434
  @@cpp_names = {}
2062
2435
  @@idclass = []
2063
2436
 
2437
+ @@normalize_procs = []
2438
+
2439
+ class ModuleIndex
2440
+ attr_accessor :index
2441
+
2442
+ def smoke
2443
+ if ! @smoke
2444
+ return 0
2445
+ end
2446
+ return @smoke
2447
+ end
2448
+
2449
+ def initialize(smoke, index)
2450
+ @smoke = smoke
2451
+ @index = index
2452
+ end
2453
+ end
2454
+
2455
+ def self.classes
2456
+ return @@classes
2457
+ end
2458
+
2459
+ def self.cpp_names
2460
+ return @@cpp_names
2461
+ end
2462
+
2463
+ def self.idclass
2464
+ return @@idclass
2465
+ end
2466
+
2467
+ def self.add_normalize_proc(func)
2468
+ @@normalize_procs << func
2469
+ end
2470
+
2064
2471
  def Internal.normalize_classname(classname)
2065
- if classname =~ /^Qext/
2066
- now = classname.sub(/^Qext(?=[A-Z])/,'Qext::')
2067
- elsif classname =~ /^Qwt/
2068
- now = classname.sub(/^Qwt(?=[A-Z])/,'Qwt::')
2069
- elsif classname =~ /^Q3/
2070
- now = classname.sub(/^Q3(?=[A-Z])/,'Qt3::')
2472
+ @@normalize_procs.each do |func|
2473
+ ret = func.call(classname)
2474
+ if !ret.nil?
2475
+ return ret
2476
+ end
2477
+ end
2478
+ if classname =~ /^Q3/
2479
+ ruby_classname = classname.sub(/^Q3(?=[A-Z])/,'Qt3::')
2071
2480
  elsif classname =~ /^Q/
2072
- now = classname.sub(/^Q(?=[A-Z])/,'Qt::')
2073
- elsif classname =~ /^(KConfigSkeleton|KWin)::/
2074
- now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
2075
- elsif classname !~ /::/
2076
- now = classname.sub(/^K?(?=[A-Z])/,'KDE::')
2481
+ ruby_classname = classname.sub(/^Q(?=[A-Z])/,'Qt::')
2077
2482
  else
2078
- now = classname
2483
+ ruby_classname = classname
2079
2484
  end
2080
- # puts "normalize_classname = was::#{classname}, now::#{now}"
2081
- now
2485
+ ruby_classname
2082
2486
  end
2083
2487
 
2084
2488
  def Internal.init_class(c)
2489
+ if c == "WebCore" || c == "std" || c == "QGlobalSpace"
2490
+ return
2491
+ end
2085
2492
  classname = Qt::Internal::normalize_classname(c)
2086
- classId = Qt::Internal.idClass(c)
2493
+ classId = Qt::Internal.findClass(c)
2087
2494
  insert_pclassid(classname, classId)
2088
- @@idclass[classId] = classname
2495
+ @@idclass[classId.index] = classname
2089
2496
  @@cpp_names[classname] = c
2090
- klass = isQObject(classId) ? create_qobject_class(classname) \
2091
- : create_qt_class(classname)
2497
+ klass = isQObject(c) ? create_qobject_class(classname, Qt) \
2498
+ : create_qt_class(classname, Qt)
2092
2499
  @@classes[classname] = klass unless klass.nil?
2093
2500
  end
2094
2501
 
@@ -2098,47 +2505,52 @@ module Qt
2098
2505
 
2099
2506
  def Internal.checkarg(argtype, typename)
2100
2507
  puts " #{typename} (#{argtype})" if debug_level >= DebugLevel::High
2508
+ const_point = typename =~ /^const\s+/ ? -1 : 0
2101
2509
  if argtype == 'i'
2102
- if typename =~ /^int&?$|^signed int&?$|^signed$|^qint32&?$|^quint32&?$/
2103
- return 2
2104
- elsif typename =~ /^(?:short|ushort|unsigned short int|uchar|uint|long|ulong|unsigned long int|unsigned|float|double|WId|Q_PID|^quint16&?$|^qint16&?$)$/
2105
- return 1
2510
+ if typename =~ /^int&?$|^signed int&?$|^signed$|^qint32&?$/
2511
+ return 6 + const_point
2512
+ elsif typename =~ /^quint32&?$/
2513
+ return 4 + const_point
2514
+ elsif typename =~ /^(?:short|ushort|unsigned short int|unsigned short|uchar||unsigned char|uint|long|ulong|unsigned long int|unsigned|float|double|WId|Q_PID|^quint16&?$|^qint16&?$)$/
2515
+ return 4 + const_point
2106
2516
  elsif typename =~ /^(quint|qint|qulong|qlong|qreal)/
2107
- return 1
2517
+ return 4 + const_point
2108
2518
  else
2109
2519
  t = typename.sub(/^const\s+/, '')
2110
2520
  t.sub!(/[&*]$/, '')
2111
2521
  if isEnum(t)
2112
- return 0
2522
+ return 2
2113
2523
  end
2114
2524
  end
2115
2525
  elsif argtype == 'n'
2116
2526
  if typename =~ /^double$|^qreal$/
2117
- return 2
2527
+ return 6 + const_point
2118
2528
  elsif typename =~ /^float$/
2119
- return 1
2529
+ return 4 + const_point
2120
2530
  elsif typename =~ /^int&?$/
2121
- return 0
2531
+ return 2 + const_point
2122
2532
  elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|float|double)$/
2123
- return 0
2533
+ return 2 + const_point
2124
2534
  else
2125
2535
  t = typename.sub(/^const\s+/, '')
2126
2536
  t.sub!(/[&*]$/, '')
2127
2537
  if isEnum(t)
2128
- return 0
2538
+ return 2 + const_point
2129
2539
  end
2130
2540
  end
2131
2541
  elsif argtype == 'B'
2132
2542
  if typename =~ /^(?:bool)[*&]?$/
2133
- return 0
2543
+ return 2 + const_point
2134
2544
  end
2135
2545
  elsif argtype == 's'
2136
2546
  if typename =~ /^(const )?((QChar)[*&]?)$/
2137
- return 1
2138
- elsif typename =~ /^(?:u?char\*|const u?char\*|(?:const )?(Q(C?)String)[*&]?)$/
2139
- qstring = !$1.nil?
2140
- c = ("C" == $2)
2141
- return c ? 2 : (qstring ? 3 : 0)
2547
+ return 6 + const_point
2548
+ elsif typename =~ /^(?:(u(nsigned )?)?char\*)$/
2549
+ return 4 + const_point
2550
+ elsif typename =~ /^(?:const (u(nsigned )?)?char\*)$/
2551
+ return 2 + const_point
2552
+ elsif typename =~ /^(?:(?:const )?(QString)[*&]?)$/
2553
+ return 8 + const_point
2142
2554
  end
2143
2555
  elsif argtype == 'a'
2144
2556
  # FIXME: shouldn't be hardcoded. Installed handlers should tell what ruby type they expect.
@@ -2152,41 +2564,41 @@ module Qt
2152
2564
  char\*\*
2153
2565
  )
2154
2566
  )$/x
2155
- return 0
2567
+ return 2 + const_point
2156
2568
  end
2157
2569
  elsif argtype == 'u'
2158
2570
  # Give nil matched against string types a higher score than anything else
2159
2571
  if typename =~ /^(?:u?char\*|const u?char\*|(?:const )?((Q(C?)String))[*&]?)$/
2160
- return 1
2572
+ return 4 + const_point
2161
2573
  # Numerics will give a runtime conversion error, so they fail the match
2162
2574
  elsif typename =~ /^(?:short|ushort|uint|long|ulong|signed|unsigned|int)$/
2163
2575
  return -99
2164
2576
  else
2165
- return 0
2577
+ return 2 + const_point
2166
2578
  end
2167
2579
  elsif argtype == 'U'
2168
2580
  if typename =~ /QStringList/
2169
- return 1
2581
+ return 4 + const_point
2170
2582
  else
2171
- return 0
2583
+ return 2 + const_point
2172
2584
  end
2173
2585
  else
2174
2586
  t = typename.sub(/^const\s+/, '')
2587
+ t.sub!(/(::)?Ptr$/, '')
2175
2588
  t.sub!(/[&*]$/, '')
2176
2589
  if argtype == t
2177
- return 1
2590
+ return 4 + const_point
2178
2591
  elsif classIsa(argtype, t)
2179
- return 0
2592
+ return 2 + const_point
2180
2593
  elsif isEnum(argtype) and
2181
2594
  (t =~ /int|qint32|uint|quint32|long|ulong/ or isEnum(t))
2182
- return 0
2595
+ return 2 + const_point
2183
2596
  end
2184
2597
  end
2185
2598
  return -99
2186
2599
  end
2187
2600
 
2188
2601
  def Internal.find_class(classname)
2189
- # puts @@classes.keys.sort.join "\n"
2190
2602
  @@classes[classname]
2191
2603
  end
2192
2604
 
@@ -2195,7 +2607,7 @@ module Qt
2195
2607
  # wrapped in a new ruby variable of type T_DATA
2196
2608
  def Internal.try_initialize(instance, *args)
2197
2609
  initializer = instance.method(:initialize)
2198
- catch "newqt" do
2610
+ catch :newqt do
2199
2611
  initializer.call(*args)
2200
2612
  end
2201
2613
  end
@@ -2205,7 +2617,7 @@ module Qt
2205
2617
  # if no args were passed to the block. Or otherwise,
2206
2618
  # run the block in the context of the arg.
2207
2619
  def Internal.run_initializer_block(instance, block)
2208
- if block.arity == -1
2620
+ if block.arity == -1 || block.arity == 0
2209
2621
  instance.instance_eval(&block)
2210
2622
  elsif block.arity == 1
2211
2623
  block.call(instance)
@@ -2230,7 +2642,7 @@ module Qt
2230
2642
 
2231
2643
  if method == "new"
2232
2644
  method = classname.dup
2233
- method.gsub!(/^(QTextLayout|KParts|KIO|KNS|DOM|Kontact|Kate|KTextEditor|KConfigSkeleton::ItemEnum|KConfigSkeleton|KWin)::/,"")
2645
+ method.gsub!(/^.*::/,"")
2234
2646
  end
2235
2647
  method = "operator" + method.sub("@","") if method !~ /[a-zA-Z]+/
2236
2648
  # Change foobar= to setFoobar()
@@ -2261,7 +2673,7 @@ module Qt
2261
2673
  methodIds = []
2262
2674
  methods.collect { |meth| methodIds.concat( findMethod(classname, meth) ) }
2263
2675
 
2264
- if method =~ /_/ && methodIds.length == 0
2676
+ if method =~ /._./ && methodIds.length == 0
2265
2677
  # If the method name contains underscores, convert to camel case
2266
2678
  # form and try again
2267
2679
  method.gsub!(/(.)_(.)/) {$1 + $2.upcase}
@@ -2276,7 +2688,7 @@ module Qt
2276
2688
  prototypes = dumpCandidates(methodIds).split("\n")
2277
2689
  line_len = (prototypes.collect { |p| p.length }).max
2278
2690
  prototypes.zip(methodIds) {
2279
- |prototype,id| puts "#{prototype.ljust line_len} (#{id})"
2691
+ |prototype,id| puts "#{prototype.ljust line_len} (smoke: #{id.smoke} index: #{id.index})"
2280
2692
  }
2281
2693
  end
2282
2694
 
@@ -2285,11 +2697,11 @@ module Qt
2285
2697
  best_match = -1
2286
2698
  methodIds.each do
2287
2699
  |id|
2288
- puts "matching => #{id}" if debug_level >= DebugLevel::High
2700
+ puts "matching => smoke: #{id.smoke} index: #{id.index}" if debug_level >= DebugLevel::High
2289
2701
  current_match = 0
2290
2702
  (0...args.length).each do
2291
2703
  |i|
2292
- current_match += checkarg( getVALUEtype(args[i]), getTypeNameOfArg(id, i) )
2704
+ current_match += checkarg(get_value_type(args[i]), get_arg_type_name(id, i))
2293
2705
  end
2294
2706
 
2295
2707
  # Note that if current_match > best_match, then chosen must be nil
@@ -2300,12 +2712,17 @@ module Qt
2300
2712
  # If ambiguous matches occur the problem must be fixed be adjusting the relative
2301
2713
  # ranking of the arg types involved in checkarg().
2302
2714
  elsif current_match == best_match
2303
- chosen = nil
2715
+ if !isConstMethod(id) and isConstMethod(chosen)
2716
+ chosen = id
2717
+ elsif isConstMethod(id) == isConstMethod(chosen)
2718
+ puts "multiple methods matching, this is an error" if debug_level >= DebugLevel::Minimal
2719
+ chosen = nil
2720
+ end
2304
2721
  end
2305
- puts "match => #{id} score: #{current_match}" if debug_level >= DebugLevel::High
2722
+ puts "match => #{id.index} score: #{current_match}" if debug_level >= DebugLevel::High
2306
2723
  end
2307
2724
 
2308
- puts "Resolved to id: #{chosen}" if !chosen.nil? && debug_level >= DebugLevel::High
2725
+ puts "Resolved to id: #{chosen.index}" if !chosen.nil? && debug_level >= DebugLevel::High
2309
2726
  end
2310
2727
 
2311
2728
  if debug_level >= DebugLevel::Minimal && chosen.nil? && method !~ /^operator/
@@ -2321,9 +2738,9 @@ module Qt
2321
2738
  end
2322
2739
  method_ids = hash.values_at(*constructor_names).flatten
2323
2740
  puts dumpCandidates(method_ids)
2741
+ else
2742
+ puts "setCurrentMethod(smokeList index: #{chosen.smoke}, meth index: #{chosen.index})" if debug_level >= DebugLevel::High
2324
2743
  end
2325
-
2326
- puts "setCurrentMethod(#{chosen})" if debug_level >= DebugLevel::High
2327
2744
  setCurrentMethod(chosen) if chosen
2328
2745
  return nil
2329
2746
  end
@@ -2333,7 +2750,7 @@ module Qt
2333
2750
  if c == "Qt"
2334
2751
  # Don't change Qt to Qt::t, just leave as is
2335
2752
  @@cpp_names["Qt"] = c
2336
- elsif c != "QInternal"
2753
+ elsif c != "QInternal" && !c.empty?
2337
2754
  Qt::Internal::init_class(c)
2338
2755
  end
2339
2756
  end
@@ -2351,8 +2768,8 @@ module Qt
2351
2768
  return num.value = val
2352
2769
  end
2353
2770
 
2354
- def Internal.create_qenum(num, type)
2355
- return Qt::Enum.new(num, type)
2771
+ def Internal.create_qenum(num, enum_type)
2772
+ return Qt::Enum.new(num, enum_type)
2356
2773
  end
2357
2774
 
2358
2775
  def Internal.get_qenum_type(e)
@@ -2369,50 +2786,12 @@ module Qt
2369
2786
 
2370
2787
  def Internal.getAllParents(class_id, res)
2371
2788
  getIsa(class_id).each do |s|
2372
- c = idClass(s)
2789
+ c = findClass(s)
2373
2790
  res << c
2374
2791
  getAllParents(c, res)
2375
2792
  end
2376
2793
  end
2377
2794
 
2378
- def Internal.signalInfo(qobject, signal_name)
2379
- signals = Meta[qobject.class.name].get_signals
2380
- signals.each_with_index do |signal, i|
2381
- if signal.name == signal_name
2382
- return [signal.reply_type, signal.full_name, i]
2383
- end
2384
- end
2385
- end
2386
-
2387
- def Internal.getMocArguments(reply_type, member)
2388
- argStr = member.sub(/.*\(/, '').sub(/\)$/, '')
2389
- args = argStr.scan(/([^,]*<[^>]+>)|([^,]+)/)
2390
- args.unshift reply_type
2391
- mocargs = allocateMocArguments(args.length)
2392
- args.each_with_index do |arg, i|
2393
- arg = arg.to_s
2394
- a = arg.sub(/^const\s+/, '')
2395
- a = (a =~ /^(bool|int|double|char\*|QString)&?$/) ? $1 : 'ptr'
2396
- valid = setMocType(mocargs, i, arg, a)
2397
- end
2398
- result = []
2399
- result << args.length << mocargs
2400
- result
2401
- end
2402
-
2403
- #
2404
- # From the enum MethodFlags in qt-copy/src/tools/moc/generator.cpp
2405
- #
2406
- AccessPrivate = 0x00
2407
- AccessProtected = 0x01
2408
- AccessPublic = 0x02
2409
- MethodMethod = 0x00
2410
- MethodSignal = 0x04
2411
- MethodSlot = 0x08
2412
- MethodCompatibility = 0x10
2413
- MethodCloned = 0x20
2414
- MethodScriptable = 0x40
2415
-
2416
2795
  # Keeps a hash of strings against their corresponding offsets
2417
2796
  # within the qt_meta_stringdata sequence of null terminated
2418
2797
  # strings. Returns a proc to get an offset given a string.
@@ -2465,7 +2844,7 @@ module Qt
2465
2844
  if dbus
2466
2845
  data.push MethodScriptable | MethodSignal | AccessPublic
2467
2846
  else
2468
- data.push MethodSignal | AccessProtected # flags, always protected for now
2847
+ data.push entry.access # flags, always protected for now
2469
2848
  end
2470
2849
  end
2471
2850
 
@@ -2477,7 +2856,7 @@ module Qt
2477
2856
  if dbus
2478
2857
  data.push MethodScriptable | MethodSlot | AccessPublic # flags, always public for now
2479
2858
  else
2480
- data.push MethodSlot | AccessPublic # flags, always public for now
2859
+ data.push entry.access # flags, always public for now
2481
2860
  end
2482
2861
  end
2483
2862
 
@@ -2514,6 +2893,11 @@ module Qt
2514
2893
  meta.metaobject
2515
2894
  end
2516
2895
 
2896
+ # Handles calls of the form:
2897
+ # connect(myobj, SIGNAL('mysig(int)'), mytarget) {|arg(s)| ...}
2898
+ # connect(myobj, SIGNAL('mysig(int)')) {|arg(s)| ...}
2899
+ # connect(myobj, SIGNAL(:mysig), mytarget) { ...}
2900
+ # connect(myobj, SIGNAL(:mysig)) { ...}
2517
2901
  def Internal.connect(src, signal, target, block)
2518
2902
  args = (signal =~ /\((.*)\)/) ? $1 : ""
2519
2903
  signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
@@ -2523,6 +2907,9 @@ module Qt
2523
2907
  SLOT(signature) )
2524
2908
  end
2525
2909
 
2910
+ # Handles calls of the form:
2911
+ # connect(SIGNAL(:mysig)) { ...}
2912
+ # connect(SIGNAL('mysig(int)')) {|arg(s)| ...}
2526
2913
  def Internal.signal_connect(src, signal, block)
2527
2914
  args = (signal =~ /\((.*)\)/) ? $1 : ""
2528
2915
  signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
@@ -2531,6 +2918,27 @@ module Qt
2531
2918
  Qt::SignalBlockInvocation.new(src, block, signature),
2532
2919
  SLOT(signature) )
2533
2920
  end
2921
+
2922
+ # Handles calls of the form:
2923
+ # connect(:mysig, mytarget, :mymethod))
2924
+ # connect(SIGNAL('mysignal(int)'), mytarget, :mymethod))
2925
+ def Internal.method_connect(src, signal, target, method)
2926
+ signal = SIGNAL(signal) if signal.is_a?Symbol
2927
+ args = (signal =~ /\((.*)\)/) ? $1 : ""
2928
+ signature = Qt::MetaObject.normalizedSignature("invoke(%s)" % args).to_s
2929
+ return Qt::Object.connect( src,
2930
+ signal,
2931
+ Qt::MethodInvocation.new(target, method, signature),
2932
+ SLOT(signature) )
2933
+ end
2934
+
2935
+ # Handles calls of the form:
2936
+ # Qt::Timer.singleShot(500, myobj) { ...}
2937
+ def Internal.single_shot_timer_connect(interval, target, block)
2938
+ return Qt::Timer.singleShot( interval,
2939
+ Qt::BlockInvocation.new(target, block, "invoke()"),
2940
+ SLOT("invoke()") )
2941
+ end
2534
2942
  end # Qt::Internal
2535
2943
 
2536
2944
  Meta = {}
@@ -2542,7 +2950,7 @@ module Qt
2542
2950
  # :full_name is 'foobar(QString,bool)'
2543
2951
  # :arg_types is 'QString,bool'
2544
2952
  # :reply_type is 'int'
2545
- QObjectMember = Struct.new :name, :full_name, :arg_types, :reply_type
2953
+ QObjectMember = Struct.new :name, :full_name, :arg_types, :reply_type, :access
2546
2954
 
2547
2955
  class MetaInfo
2548
2956
  attr_accessor :classinfos, :dbus, :signals, :slots, :metaobject, :mocargs, :changed
@@ -2559,7 +2967,7 @@ module Qt
2559
2967
  Internal.addMetaObjectMethods(klass)
2560
2968
  end
2561
2969
 
2562
- def add_signals(signal_list)
2970
+ def add_signals(signal_list, access)
2563
2971
  signal_names = []
2564
2972
  signal_list.each do |signal|
2565
2973
  if signal.kind_of? Symbol
@@ -2567,7 +2975,11 @@ module Qt
2567
2975
  end
2568
2976
  signal = Qt::MetaObject.normalizedSignature(signal).to_s
2569
2977
  if signal =~ /^(([\w,<>:]*)\s+)?([^\s]*)\((.*)\)/
2570
- @signals.push QObjectMember.new($3, $3 + "(" + $4 + ")", $4, ($2 == 'void' || $2.nil?) ? "" : $2)
2978
+ @signals.push QObjectMember.new( $3,
2979
+ $3 + "(" + $4 + ")",
2980
+ $4,
2981
+ ($2 == 'void' || $2.nil?) ? "" : $2,
2982
+ access )
2571
2983
  signal_names << $3
2572
2984
  else
2573
2985
  qWarning( "#{@klass.name}: Invalid signal format: '#{signal}'" )
@@ -2590,14 +3002,18 @@ module Qt
2590
3002
  return all_signals
2591
3003
  end
2592
3004
 
2593
- def add_slots(slot_list)
3005
+ def add_slots(slot_list, access)
2594
3006
  slot_list.each do |slot|
2595
3007
  if slot.kind_of? Symbol
2596
3008
  slot = slot.to_s + "()"
2597
3009
  end
2598
3010
  slot = Qt::MetaObject.normalizedSignature(slot).to_s
2599
3011
  if slot =~ /^(([\w,<>:]*)\s+)?([^\s]*)\((.*)\)/
2600
- @slots.push QObjectMember.new($3, $3 + "(" + $4 + ")", $4, ($2 == 'void' || $2.nil?) ? "" : $2)
3012
+ @slots.push QObjectMember.new( $3,
3013
+ $3 + "(" + $4 + ")",
3014
+ $4,
3015
+ ($2 == 'void' || $2.nil?) ? "" : $2,
3016
+ access )
2601
3017
  else
2602
3018
  qWarning( "#{@klass.name}: Invalid slot format: '#{slot}'" )
2603
3019
  end
@@ -2660,7 +3076,7 @@ class Object
2660
3076
  # matter for the intended use in invoking blocks as Qt slots.
2661
3077
  def instance_exec(*arguments, &block)
2662
3078
  block.bind(self)[*arguments]
2663
- end
3079
+ end unless defined? instance_exec
2664
3080
  end
2665
3081
 
2666
3082
  class Proc
@@ -2709,10 +3125,10 @@ class Module
2709
3125
  end
2710
3126
 
2711
3127
  klass = self
2712
- classid = 0
3128
+ classid = Qt::Internal::ModuleIndex.new(0, 0)
2713
3129
  loop do
2714
3130
  classid = Qt::Internal::find_pclassid(klass.name)
2715
- break if classid > 0
3131
+ break if classid.index
2716
3132
 
2717
3133
  klass = klass.superclass
2718
3134
  if klass.nil?
@@ -2732,3 +3148,5 @@ class Module
2732
3148
  return meths.uniq
2733
3149
  end
2734
3150
  end
3151
+
3152
+ # kate: space-indent false;