[Kde-bindings] branches/KDE/4.2/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Apr 28 16:49:29 UTC 2009
SVN commit 960566 by rdale:
* Promote QtRuby 2.0.4 to the release branch
CCMAIL: kde-bindings at kde.org
M +30 -0 ChangeLog
M +4 -3 rails_support/active_item_model.rb
M +1 -1 rails_support/active_table_model.rb
M +17 -0 src/Qt.cpp
M +2 -16 src/handlers.cpp
M +23 -9 src/lib/Qt/qtruby4.rb
M +4 -4 src/marshall_basetypes.h
M +13 -0 src/marshall_types.cpp
M +1 -1 src/qtruby.h
--- branches/KDE/4.2/kdebindings/ruby/qtruby/ChangeLog #960565:960566
@@ -1,3 +1,33 @@
+2009-04-24 Richard Dale <richard.j.dale at gmail.com>
+ * The resolve_classname() function was not resolving names for QObject
+ derived classes when the class wasn't in the base Qt smoke library.
+ For instance, this meant that a Plasma::Applet was not being resolved to
+ a Plasma::PopupApplet to match the underlying C++ type.
+
+2009-04-17 Richard Dale <richard.j.dale at gmail.com>
+ * When Qt::StandardItemModel#setItemPrototype was used with a
+ Qt::StandardItem it crashed because the clone() method was using
+ Object#clone. So special case the clone() method. Thanks to Stefano Crocco
+ for reporting the bug.
+
+2009-04-07 Richard Dale <richard.j.dale at gmail.com>
+ * The ActiveRecord based model classes were setting changed values in the
+ 'attributes' and then saving the changed instance, like this
+
+ foo.attributes['my_att'] = value
+ foo.save
+
+ However, this no longer works with ActiveRecord, and the instance can
+ be changed more directly like this
+
+ foo['my_att'] = value
+ foo.save
+ * QtRuby wasn't building on Mac OS X with a version of Qt built without
+ QtDBus support, so add some #ifdefs to fix that
+
+2009-03-24 Richard Dale <richard.j.dale at gmail.com>
+ * Raised the QtRuby version to 2.0.3 for the RubyForge release
+
2009-03-20 Richard Dale <richard.j.dale at gmail.com>
* Remove 'LIBRARY' from this line in qtruby/src/CMakeLists.txt:
--- branches/KDE/4.2/kdebindings/ruby/qtruby/rails_support/active_item_model.rb #960565:960566
@@ -1,8 +1,9 @@
=begin
-This table model allows an ActiveRecord or ActiveResource to be used as a
-basis for a Qt::AbstractItemModel for viewing in a Qt::TreeView. Example
-usage:
+This Qt::AbstractItemModel based model allows an ActiveRecord or ActiveResource
+data set be used for viewing in a Qt::TreeView.
+Example usage:
+
app = Qt::Application.new(ARGV)
agencies = TravelAgency.find(:all)
model = ActiveItemModel.new(agencies)
--- branches/KDE/4.2/kdebindings/ruby/qtruby/rails_support/active_table_model.rb #960565:960566
@@ -109,7 +109,7 @@
value = Time.new(value.hour, value.min, value.sec)
end
- eval("item.attributes['%s'] = value" % att.gsub(/\./, "'].attributes['"))
+ eval("item['%s'] = value" % att.gsub(/\./, "']['"))
item.save
emit dataChanged(index, index)
return true
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/Qt.cpp #960565:960566
@@ -459,6 +459,23 @@
const char *
resolve_classname(smokeruby_object * o)
{
+ if (o->smoke->isDerivedFromByName(o->smoke->classes[o->classId].className, "QObject")) {
+ QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
+ const QMetaObject * meta = qobject->metaObject();
+
+ while (meta != 0) {
+ o->smoke = Smoke::classMap[meta->className()];
+ if (o->smoke != 0) {
+ o->classId = o->smoke->idClass(meta->className()).index;
+ if (o->classId != 0) {
+ return qtruby_modules[o->smoke].binding->className(o->classId);
+ }
+ }
+
+ meta = meta->superClass();
+ }
+ }
+
if (o->smoke->classes[o->classId].external) {
Smoke::ModuleIndex mi = o->smoke->findClass(o->smoke->className(o->classId));
o->smoke = mi.smoke;
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/handlers.cpp #960565:960566
@@ -623,21 +623,6 @@
default:
break;
}
- } else if (o->smoke->isDerivedFromByName(o->smoke->classes[o->classId].className, "QObject")) {
- QObject * qobject = (QObject *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QObject").index);
- const QMetaObject * meta = qobject->metaObject();
-
- while (meta != 0) {
- o->smoke = Smoke::classMap[meta->className()];
- if (o->smoke != 0) {
- o->classId = o->smoke->idClass(meta->className()).index;
- if (o->classId != 0) {
- return qtruby_modules[o->smoke].binding->className(o->classId);
- }
- }
-
- meta = meta->superClass();
- }
} else if (o->smoke->isDerivedFromByName(o->smoke->classes[o->classId].className, "QGraphicsItem")) {
QGraphicsItem * item = (QGraphicsItem *) o->smoke->cast(o->ptr, o->classId, o->smoke->idClass("QGraphicsItem").index);
switch (item->type()) {
@@ -1213,6 +1198,7 @@
stringlist->append(QString());
continue;
}
+
stringlist->append(*(qstringFromRString(item)));
}
@@ -1228,7 +1214,7 @@
if (m->cleanup()) {
delete stringlist;
}
-
+
break;
}
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #960565:960566
@@ -1256,7 +1256,7 @@
class ListWidgetItem < Qt::Base
def clone(*args)
- method_missing(:clone, *args)
+ Qt::ListWidgetItem.new(self)
end
def type(*args)
@@ -1265,12 +1265,12 @@
def inspect
str = super
- str.sub(/>$/, " text=%s>" % text)
+ str.sub(/>$/, " text='%s'>" % text)
end
def pretty_print(pp)
str = to_s
- pp.text str.sub(/>$/, " text=%s>" % text)
+ pp.text str.sub(/>$/, " text='%s'>" % text)
end
end
@@ -1855,9 +1855,23 @@
end
class StandardItem < Qt::Base
+ def inspect
+ str = super
+ str.sub(/>$/, " text='%s'>" % [text])
+ end
+
+ def pretty_print(pp)
+ str = to_s
+ pp.text str.sub(/>$/, "\n text='%s'>" % [text])
+ end
+
def type(*args)
method_missing(:type, *args)
end
+
+ def clone
+ Qt::StandardItem.new(self)
+ end
end
class StandardItemModel < Qt::Base
@@ -1892,7 +1906,7 @@
class TableWidgetItem < Qt::Base
def clone(*args)
- method_missing(:clone, *args)
+ Qt::TableWidgetItem.new(self)
end
def type(*args)
@@ -1901,12 +1915,12 @@
def inspect
str = super
- str.sub(/>$/, " text=%s>" % text)
+ str.sub(/>$/, " text='%s'>" % text)
end
def pretty_print(pp)
str = to_s
- pp.text str.sub(/>$/, " text=%s>" % text)
+ pp.text str.sub(/>$/, " text='%s'>" % text)
end
end
@@ -2069,7 +2083,7 @@
str.sub!(/>$/, "")
str << " parent=%s," % parent unless parent.nil?
for i in 0..(columnCount - 1)
- str << " text%d=%s," % [i, self.text(i)]
+ str << " text%d='%s'," % [i, self.text(i)]
end
str.sub!(/,?$/, ">")
end
@@ -2079,14 +2093,14 @@
str.sub!(/>$/, "")
str << " parent=%s," % parent unless parent.nil?
for i in 0..(columnCount - 1)
- str << " text%d=%s," % [i, self.text(i)]
+ str << " text%d='%s'," % [i, self.text(i)]
end
str.sub!(/,?$/, ">")
pp.text str
end
def clone(*args)
- method_missing(:clone, *args)
+ Qt::TreeWidgetItem.new(self)
end
def type(*args)
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/marshall_basetypes.h #960565:960566
@@ -139,13 +139,13 @@
template <>
void marshall_to_ruby<SmokeClassWrapper>(Marshall *m)
{
- if(m->item().s_voidp == 0) {
+ if (m->item().s_voidp == 0) {
*(m->var()) = Qnil;
return;
}
void *p = m->item().s_voidp;
VALUE obj = getPointerObject(p);
- if(obj != Qnil) {
+ if (obj != Qnil) {
*(m->var()) = obj;
return ;
}
@@ -153,13 +153,13 @@
smokeruby_object * o = alloc_smokeruby_object(false, m->smoke(), m->type().classId(), p);
const char * classname = resolve_classname(o);
- if(m->type().isConst() && m->type().isRef()) {
+ if (m->type().isConst() && m->type().isRef()) {
p = construct_copy( o );
if (do_debug & qtdb_gc) {
qWarning("copying %s %p to %p\n", classname, o->ptr, p);
}
- if(p) {
+ if (p) {
o->ptr = p;
o->allocated = true;
}
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/marshall_types.cpp #960565:960566
@@ -18,7 +18,15 @@
#include "marshall_types.h"
#include <smoke/qt_smoke.h>
+
+#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qmap.h>
+
+#ifdef QT_QTDBUS
#include <QtDBus>
+#endif
static bool qtruby_embedded = false;
@@ -661,8 +669,10 @@
o[0] = new QHash<void*, void*>;
} else if (type.startsWith("QMap")) {
o[0] = new QMap<void*, void*>;
+#ifdef QT_QTDBUS
} else if (type == "QDBusVariant") {
o[0] = new QDBusVariant;
+#endif
} else {
Smoke::ModuleIndex ci = qt_Smoke->findClass(type);
if (ci.index != 0) {
@@ -702,8 +712,11 @@
QByteArray t(type().name());
t.replace("const ", "");
t.replace("&", "");
+
if (t == "QDBusVariant") {
+#ifdef QT_QTDBUS
*reinterpret_cast<QDBusVariant*>(o[0]) = *(QDBusVariant*) _stack[0].s_class;
+#endif
} else {
// Save any address in zeroth element of the arrary of 'void*'s passed to
// qt_metacall()
--- branches/KDE/4.2/kdebindings/ruby/qtruby/src/qtruby.h #960565:960566
@@ -26,7 +26,7 @@
#ifndef QT_VERSION_STR
#define QT_VERSION_STR "Unknown"
#endif
-#define QTRUBY_VERSION "2.0.3"
+#define QTRUBY_VERSION "2.0.4"
#if !defined RSTRING_LEN
#define RSTRING_LEN(a) RSTRING(a)->len
More information about the Kde-bindings
mailing list