aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtCore
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-02-02 16:33:01 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-03 19:00:59 -0200
commit3ec23a2a898e46a89d7f1b744e5b381a29454350 (patch)
tree58bb79753ecb022d2da90446f9ca12f18970fc2b /PySide/QtCore
parent6e33903fe2b45e8d9e5b631e8383d89d1078ec83 (diff)
Fixing QVariant converter toCpp for basic types
Instead of storing a single pointer, the converter now checks for basic python types like string, bool, ints, using the same if/self structure of the constructor. Only as a last resort it tries to convert to a python object holder. Reviewer: Renato Filho <renato.filho@openbossa.org>
Diffstat (limited to 'PySide/QtCore')
-rw-r--r--PySide/QtCore/glue/qvariant_converter_impl.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/PySide/QtCore/glue/qvariant_converter_impl.cpp b/PySide/QtCore/glue/qvariant_converter_impl.cpp
index 6bf7159c2..ac07090b0 100644
--- a/PySide/QtCore/glue/qvariant_converter_impl.cpp
+++ b/PySide/QtCore/glue/qvariant_converter_impl.cpp
@@ -42,8 +42,40 @@ QVariant Shiboken::Converter<QVariant>::toCpp(PyObject* pyobj)
// voodoo stuff to avoid linking qtcore bindings with qtgui bindings
uint typeCode = QMetaType::type(pyobj->ob_type->tp_name);
if (!typeCode || typeCode > QVariant::UserType) {
- Py_INCREF(pyobj);
- return QVariant::fromValue<PyObjectHolder>(pyobj);
+
+ // Check the implicit conversion stuff for most python-native types
+ if (SbkPySide_QtCore_QVariant_Type_CheckExact(pyobj)) {
+ QVariant::Type cpp_arg0 = Shiboken::Converter<QVariant::Type >::toCpp(pyobj);
+ // QVariant(QVariant::Type)
+ return QVariant(cpp_arg0);
+ } else if (SbkPySide_QtCore_Qt_GlobalColor_CheckExact(pyobj)) {
+ Qt::GlobalColor cpp_arg0 = Shiboken::Converter<Qt::GlobalColor >::toCpp(pyobj);
+ // QVariant(Qt::GlobalColor)
+ return QVariant(cpp_arg0);
+ } else if (PyBool_Check(pyobj)) {
+ bool cpp_arg0 = Shiboken::Converter<bool >::toCpp(pyobj);
+ // QVariant(bool)
+ return QVariant(cpp_arg0);
+ } else if (PyString_Check(pyobj)) {
+ const char * cpp_arg0 = Shiboken::Converter<const char * >::toCpp(pyobj);
+ // QVariant(const char*)
+ return QVariant(cpp_arg0);
+ } else if (PyFloat_Check(pyobj)) {
+ double cpp_arg0 = Shiboken::Converter<double >::toCpp(pyobj);
+ // QVariant(double)
+ return QVariant(cpp_arg0);
+ } else if (PyNumber_Check(pyobj)) {
+ int cpp_arg0 = Shiboken::Converter<int >::toCpp(pyobj);
+ // QVariant(int)
+ return QVariant(cpp_arg0);
+ } else if (PyLong_Check(pyobj)) {
+ qlonglong cpp_arg0 = Shiboken::Converter<qlonglong >::toCpp(pyobj);
+ // QVariant(qlonglong)
+ return QVariant(cpp_arg0);
+ } else {
+ Py_INCREF(pyobj);
+ return QVariant::fromValue<PyObjectHolder>(pyobj);
+ }
} else {
// Is a known Qt type
return QVariant(typeCode, reinterpret_cast<SbkBaseWrapper*>(pyobj)->cptr);