[Kde-bindings] KDE/kdebindings/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Wed Apr 5 09:13:24 UTC 2006
SVN commit 526646 by rdale:
* Simplify the Qt::AbstractItemModel.createIndex() code
* Fix bug where return values from rb_call_super() were being ignored
* Make :foobar a synonym for 'foobar()' in SLOT()/SIGNAL() calls and
slot/signal declarations
CCMAIL: kde-bindings at kde.org
M +7 -0 ChangeLog
M +34 -9 rubylib/qtruby/Qt.cpp
M +8 -2 rubylib/qtruby/lib/Qt/qtruby.rb
--- trunk/KDE/kdebindings/qtruby/ChangeLog #526645:526646
@@ -1,3 +1,10 @@
+2006-04-05 Richard Dale <rdale at foton.es>
+
+ * Simplify the Qt::AbstractItemModel.createIndex() code
+ * Fix bug where return values from rb_call_super() were being ignored
+ * Make :foobar a synonym for 'foobar()' in SLOT()/SIGNAL() calls and
+ slot/signal declarations
+
2006-04-04 Richard Dale <rdale at foton.es>
* Added the itemviews/simpledommodel and itemviews/simpletreemodel
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #526645:526646
@@ -1122,7 +1122,7 @@
} else if (strcmp(o->smoke->classes[o->classId].className, "QLine") == 0) {
_current_method = drawlines_line_vector;
} else {
- rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
MethodCall c(qt_Smoke, _current_method, self, argv, argc-1);
@@ -1130,8 +1130,7 @@
return self;
}
- rb_call_super(argc, argv);
- return self;
+ return rb_call_super(argc, argv);
}
static VALUE
@@ -1166,7 +1165,7 @@
} else if (strcmp(o->smoke->classes[o->classId].className, "QRect") == 0) {
_current_method = drawlines_rect_vector;
} else {
- rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
MethodCall c(qt_Smoke, _current_method, self, argv, argc-1);
@@ -1174,11 +1173,31 @@
return self;
}
- rb_call_super(argc, argv);
- return self;
+ return rb_call_super(argc, argv);
}
static VALUE
+qabstractitemmodel_createindex(int argc, VALUE * argv, VALUE /* self */)
+{
+ if (argc == 3 && TYPE(argv[2]) != T_FIXNUM && TYPE(argv[2]) != T_BIGNUM) {
+ // Change the VALUE to a Ruby Integer, so it can be marshalled to a
+ // C++ int. Then look for the QAbstractItemModel::createIndex(int, int, int)
+ // variant
+ argv[2] = UINT2NUM(argv[2]);
+ }
+
+ return rb_call_super(argc, argv);
+}
+
+static VALUE
+qmodelindex_internalpointer(VALUE self)
+{
+ smokeruby_object *o = value_obj_info(self);
+ QModelIndex * index = (QModelIndex *) o->ptr;
+ return (VALUE) index->internalPointer();
+}
+
+static VALUE
metaObject(VALUE self)
{
VALUE metaObject = rb_funcall(qt_internal_module, rb_intern("getMetaObject"), 1, self);
@@ -1228,7 +1247,7 @@
if (px.indexIn(pred) != -1) {
smokeruby_object *o = value_obj_info(self);
if(!o || !o->ptr) {
- rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
// Drop the trailing '?'
@@ -1275,7 +1294,7 @@
if (_current_method == -1) {
free(temp_stack);
- rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
}
// Success. Cache result.
@@ -1333,7 +1352,7 @@
free(temp_stack);
return result;
} else {
- rb_call_super(argc, argv);
+ return rb_call_super(argc, argv);
}
}
@@ -2453,6 +2472,10 @@
} else {
rb_define_singleton_method(klass, "new", (VALUE (*) (...)) new_qobject, -1);
}
+
+ if (packageName == "Qt::AbstractItemModel") {
+ rb_define_method(klass, "createIndex", (VALUE (*) (...)) qabstractitemmodel_createindex, -1);
+ }
} else if (packageName.startsWith("Qext::")) {
if (qext_scintilla_module == Qnil) {
qext_scintilla_module = rb_define_module("Qext");
@@ -2504,6 +2527,8 @@
} else if (packageName == "Qt::Painter") {
rb_define_method(klass, "drawLines", (VALUE (*) (...)) qpainter_drawlines, -1);
rb_define_method(klass, "drawRects", (VALUE (*) (...)) qpainter_drawrects, -1);
+ } else if (packageName == "Qt::ModelIndex") {
+ rb_define_method(klass, "internalPointer", (VALUE (*) (...)) qmodelindex_internalpointer, 0);
}
return klass;
--- trunk/KDE/kdebindings/qtruby/rubylib/qtruby/lib/Qt/qtruby.rb #526645:526646
@@ -58,13 +58,13 @@
def self.q_signal(signal)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
- meta.add_signals([signal.to_s + "()"])
+ meta.add_signals([signal])
meta.changed = true
end
def self.q_slot(slot)
meta = Qt::Meta[self.name] || Qt::MetaInfo.new(self)
- meta.add_slots([slot.to_s + "()"])
+ meta.add_slots([slot])
meta.changed = true
end
@@ -1692,6 +1692,9 @@
def add_signals(signal_list)
signal_list.each do |signal|
+ if signal.kind_of? Symbol
+ signal = signal.to_s + "()"
+ end
signal = Qt::MetaObject.normalizedSignature(signal).to_s
if signal =~ /([^\s]*)\((.*)\)/
@signals.push QObjectMember.new($1, signal, $2)
@@ -1717,6 +1720,9 @@
def add_slots(slot_list)
slot_list.each do |slot|
+ if slot.kind_of? Symbol
+ slot = slot.to_s + "()"
+ end
slot = Qt::MetaObject.normalizedSignature(slot).to_s
if slot =~ /([^\s]*)\((.*)\)/
@slots.push QObjectMember.new($1, slot, $2)
More information about the Kde-bindings
mailing list