diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-02-01 15:29:09 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-02-01 20:35:42 -0300 |
commit | e864bdf57e2c549ad5f8f6f8b966dadca6f1ee68 (patch) | |
tree | 1c44621a846a9b29686734227273d4fbc6aa5a24 /PySide/QtGui | |
parent | e4919faa31215b55ec6f95ca0ff58ba6dd011124 (diff) |
QPixmap conversion from QVariant.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Diffstat (limited to 'PySide/QtGui')
-rw-r--r-- | PySide/QtGui/qpixmap_conversion.h | 27 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/PySide/QtGui/qpixmap_conversion.h b/PySide/QtGui/qpixmap_conversion.h new file mode 100644 index 000000000..18e3ce910 --- /dev/null +++ b/PySide/QtGui/qpixmap_conversion.h @@ -0,0 +1,27 @@ +inline bool Converter< QPixmap >::isConvertible(PyObject* pyobj) +{ + bool isVariant = SbkQVariant_Check(pyobj); + if (isVariant) { + QVariant var(Converter<QVariant>::toCpp(pyobj)); + return var.type() == QVariant::Pixmap; + } else if (SbkQSize_Check(pyobj) || SbkQString_Check(pyobj)) { + return true; + } + return false; + +} + +inline QPixmap Converter< QPixmap >::toCpp(PyObject* pyobj) +{ + bool isVariant = SbkQVariant_Check(pyobj); + if (isVariant) { + QVariant var(Converter<QVariant>::toCpp(pyobj)); + return var.value<QPixmap>(); + } else if (SbkQSize_Check(pyobj)) { + return QPixmap(Shiboken::Converter<QSize& >::toCpp(pyobj)); + } else if (SbkQString_Check(pyobj)) { + return QPixmap(Shiboken::Converter<QString& >::toCpp(pyobj)); + } + + return *SbkQPixmap_cptr(pyobj); +} diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index d322c95b1..ee46d2b82 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -628,6 +628,7 @@ </value-type> <value-type name="QAbstractTextDocumentLayout::Selection" /> <value-type name="QPixmap" > + <conversion-rule file="qpixmap_conversion.h" /> <extra-includes> <include file-name="QVariant" location="global"/> </extra-includes> |