Version: (using KDE KDE 3.4.2) Installed from: Compiled From Sources One nice feature would be to allow Qt::Object::inherits() to use the QtRuby naming scheme for valid lookups. For example, right now: irb(main):001:0> w = Qt::Widget.new(nil) irb(main):002:0> w.inherits("Qt::Widget") => true irb(main):003:0> w.inherits("Qt::Object") => false irb(main):004:0> w.inherits("QWidget") => true irb(main):005:0> w.inherits("QObject") => true inherits works for "QObject", but my wish is that it worked for "Qt::Object" as well.
SVN commit 444221 by rdale: * Caleb Tennis wrote: One nice feature would be to allow Qt::Object::inherits() to use the QtRuby naming scheme for valid lookups. For example, right now: irb(main):001:0> w = Qt::Widget.new(nil) irb(main):002:0> w.inherits("Qt::Widget") => true irb(main):003:0> w.inherits("Qt::Object") => false irb(main):004:0> w.inherits("QWidget") => true irb(main):005:0> w.inherits("QObject") => true * Inherits now works for "QObject", and for "Qt::Object" as well. CCBUGS: 110415 M +18 -0 ChangeLog M +20 -0 rubylib/qtruby/Qt.cpp --- branches/KDE/3.5/kdebindings/qtruby/ChangeLog #444220:444221 @@ -1,3 +1,21 @@ +2005-08-09 Richard Dale <Richard_Dale@tipitina.demon.co.uk> + + * Caleb Tennis wrote: + One nice feature would be to allow Qt::Object::inherits() to use the QtRuby + naming scheme for valid lookups. For example, right now: + + irb(main):001:0> w = Qt::Widget.new(nil) + irb(main):002:0> w.inherits("Qt::Widget") + => true + irb(main):003:0> w.inherits("Qt::Object") + => false + irb(main):004:0> w.inherits("QWidget") + => true + irb(main):005:0> w.inherits("QObject") + => true + + * Inherits now works for "QObject", and for "Qt::Object" as well. + 2005-08-04 Richard Dale <Richard_Dale@tipitina.demon.co.uk> * Added a file called 'COPYING' to the qtruby project, with a note that --- branches/KDE/3.5/kdebindings/qtruby/rubylib/qtruby/Qt.cpp #444220:444221 @@ -1784,6 +1784,25 @@ return rb_funcall(klass, rb_intern("name"), 0); } +// Allow classnames in both 'Qt::Widget' and 'QWidget' formats to be +// used as an argument to Qt::Object.inherits() +static VALUE +inherits_qobject(int argc, VALUE * argv, VALUE /*self*/) +{ + if (argc != 1) { + return rb_call_super(argc, argv); + } + + Smoke::Index * classId = classcache.find(StringValuePtr(argv[0])); + + if (classId == 0) { + return rb_call_super(argc, argv); + } else { + VALUE super_class = rb_str_new2(qt_Smoke->classes[*classId].className); + return rb_call_super(argc, &super_class); + } +} + static void mocargs_free(void * ptr) { @@ -2477,6 +2496,7 @@ rb_define_method(klass, "pretty_print", (VALUE (*) (...)) pretty_print_qobject, 1); rb_define_method(klass, "receivers", (VALUE (*) (...)) receivers_qobject, 0); rb_define_method(klass, "className", (VALUE (*) (...)) class_name, 0); + rb_define_method(klass, "inherits", (VALUE (*) (...)) inherits_qobject, -1); return klass; }
Is fixed.