[Kde-bindings] KDE/kdebindings/ruby/qtruby
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Sun Nov 18 11:42:48 UTC 2007
SVN commit 738219 by rdale:
* At the suggestion of Vincent Fourmond added a Qt::DateTime.to_time
method which returns a Ruby time. Also enhanced the Qt::DateTime
constructor so that it can be passed a Ruby Time.
* Qt::Variants containing either QDBusObjectPaths or QDBusSignatures
can now be converted to Ruby Strings with a Qt::Variant.value call.
Fixes bug reported by maniel on the #qtruby IRC channel.
CCMAIL: kde-bindings at kde.org
M +9 -0 ChangeLog
M +26 -2 src/Qt.cpp
M +19 -0 src/lib/Qt/qtruby4.rb
--- trunk/KDE/kdebindings/ruby/qtruby/ChangeLog #738218:738219
@@ -1,3 +1,12 @@
+2007-11-18 Richard Dale <rdale at foton.es>
+
+ * At the suggestion of Vincent Fourmond added a Qt::DateTime.to_time
+ method which returns a Ruby time. Also enhanced the Qt::DateTime
+ constructor so that it can be passed a Ruby Time.
+ * Qt::Variants containing either QDBusObjectPaths or QDBusSignatures
+ can now be converted to Ruby Strings with a Qt::Variant.value call.
+ Fixes bug reported by maniel on the #qtruby IRC channel.
+
2007-11-12 Richard Dale <rdale at foton.es>
* If QModelIndex.internalPointer() is zero, return Qnil
--- trunk/KDE/kdebindings/ruby/qtruby/src/Qt.cpp #738218:738219
@@ -1449,6 +1449,26 @@
arg->endStructure();
return self;
}
+
+static VALUE
+qvariant_qdbusobjectpath_value(VALUE self)
+{
+ smokeruby_object *o = value_obj_info(self);
+ QVariant * arg = (QVariant *) o->ptr;
+ QString s = qVariantValue<QDBusObjectPath>(*arg).path();
+ return rb_str_new2(s.toLatin1());
+}
+
+static VALUE
+qvariant_qdbussignature_value(VALUE self)
+{
+ smokeruby_object *o = value_obj_info(self);
+ QVariant * arg = (QVariant *) o->ptr;
+ QString s = qVariantValue<QDBusSignature>(*arg).signature();
+ return rb_str_new2(s.toLatin1());
+}
+
+
#endif
// The QtRuby runtime's overloaded method resolution mechanism can't currently
@@ -2816,12 +2836,12 @@
VALUE result = rb_ary_new();
Smoke::Index meth = qt_Smoke->findMethod(c, name);
//#ifdef DEBUG
- if (do_debug & qtdb_calls) qWarning("DAMNIT on %s::%s => %d", c, name, meth);
+ if (do_debug & qtdb_calls) qWarning("Found method %s::%s => %d", c, name, meth);
//#endif
if(!meth) {
meth = qt_Smoke->findMethod("QGlobalSpace", name);
//#ifdef DEBUG
- if (do_debug & qtdb_calls) qWarning("DAMNIT on QGlobalSpace::%s => %d", name, meth);
+ if (do_debug & qtdb_calls) qWarning("Found method QGlobalSpace::%s => %d", name, meth);
//#endif
}
@@ -3290,6 +3310,10 @@
qvariant_class = klass;
rb_define_singleton_method(qvariant_class, "fromValue", (VALUE (*) (...)) qvariant_from_value, -1);
rb_define_singleton_method(qvariant_class, "new", (VALUE (*) (...)) new_qvariant, -1);
+#ifdef QT_QTDBUS
+ rb_define_method(klass, "qdbusobjectpath_value", (VALUE (*) (...)) qvariant_qdbusobjectpath_value, 1);
+ rb_define_method(klass, "qdbussignature_value", (VALUE (*) (...)) qvariant_qdbussignature_value, 1);
+#endif
} else if (packageName == "Qt::ByteArray") {
rb_define_method(klass, "+", (VALUE (*) (...)) qbytearray_append, 1);
} else if (packageName == "Qt::Char") {
--- trunk/KDE/kdebindings/ruby/qtruby/src/lib/Qt/qtruby4.rb #738218:738219
@@ -400,11 +400,26 @@
if args.size == 1 && args[0].class.name == "DateTime"
return super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
Qt::Time.new(args[0].hour, args[0].min, args[0].sec) )
+ elsif args.size == 1 && args[0].class.name == "Time"
+ result = super( Qt::Date.new(args[0].year, args[0].month, args[0].day),
+ Qt::Time.new(args[0].hour, args[0].min, args[0].sec, args[0].usec / 1000) )
+ result.timeSpec = (args[0].utc? ? Qt::UTC : Qt::LocalTime)
+ return result
else
return super(*args)
end
end
+ def to_time
+ if timeSpec == Qt::UTC
+ return ::Time.utc( date.year, date.month, date.day,
+ time.hour, time.minute, time.second, time.msec * 1000 )
+ else
+ return ::Time.local( date.year, date.month, date.day,
+ time.hour, time.minute, time.second, time.msec * 1000 )
+ end
+ end
+
def inspect
str = super
str.sub(/>$/, " %s>" % toString)
@@ -1804,6 +1819,10 @@
return qVariantValue(Qt::DBusArgument, self)
when "QDBusVariant"
return qVariantValue(Qt::Variant, self)
+ when "QDBusObjectPath"
+ return qdbusobjectpath_value(self)
+ when "QDBusSignature"
+ return qdbussignature_value(self)
end
end
More information about the Kde-bindings
mailing list