[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kjsembed/kjsembed
From:       Sebastian Sauer <mail () dipe ! org>
Date:       2008-06-11 22:07:05
Message-ID: 1213222025.838667.11962.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 819739 by sebsauer:

fix handle QObject/QWidget in QVariant/QVariantList's

 M  +16 -3     variant_binding.cpp  


--- trunk/KDE/kdelibs/kjsembed/kjsembed/variant_binding.cpp #819738:819739
@@ -30,9 +30,12 @@
 #include <QtCore/QBitRef>
 #include <QtCore/QByteRef>
 #include <QtCore/QDebug>
+#include <QtCore/QObject>
+#include <QtGui/QWidget>
 
 #include "kjseglobal.h"
 #include "static_binding.h"
+#include "qobject_binding.h"
 
 using namespace KJSEmbed;
 
@@ -404,9 +407,19 @@
         }
         default:
         {
-            returnValue = createVariant(exec, value.typeName(), value );
-            if( returnValue->isNull() )
-                returnValue = KJS::jsString( value.value<QString>() );
+            if( qVariantCanConvert< QWidget* >(value) ) {
+                QWidget* widget = qvariant_cast< QWidget* >(value);
+                returnValue = createQObject(exec, widget, KJSEmbed::ObjectBinding::CPPOwned);
+            }
+            else if( qVariantCanConvert< QObject* >(value) ) {
+                QObject* object = qvariant_cast< QObject* >(value);
+                returnValue = createQObject(exec, object, KJSEmbed::ObjectBinding::CPPOwned);
+            }
+            else {
+                returnValue = createVariant(exec, value.typeName(), value );
+                if( returnValue->isNull() )
+                    returnValue = KJS::jsString( value.value<QString>() );
+            }
             break;
         }
     }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic