diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-04-15 17:56:54 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:12 -0300 |
commit | 13878d27cd03c73aaf36952636b61ee25e801d33 (patch) | |
tree | 02b3deab86b548fda7883a617646a4031504c7a6 /PySide | |
parent | 595c70c32fd98bb8676195d8e847d3c2878c2485 (diff) |
Fixes Bug #757 - Constructor "QPixmap(const char* const[] xpm)" missing.
http://bugs.pyside.org/show_bug.cgi?id=757
Reviewer: Renato Araujo <renato.filho@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'PySide')
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 4de1e2f68..ab34ba061 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -659,24 +659,43 @@ </value-type> <value-type name="QPixmap" > <conversion-rule file="qpixmap_conversion.h" /> - <extra-includes> - <include file-name="QVariant" location="global"/> - </extra-includes> - <add-function signature="QPixmap(QVariant)"> + <add-function signature="QPixmap(const QImage&)"> + <modify-argument index="1"> + <rename to="image"/> + </modify-argument> <inject-code class="target" position="beginning"> - if (%1.type() == QVariant::Pixmap) - %0 = new %TYPE(%1.value<QPixmap>()); - else if (%1.type() == QVariant::Image) - %0 = new %TYPE(QPixmap::fromImage(%1.value<QImage>())); - else - PyErr_SetString(PyExc_TypeError, "QVariant must be holding a QPixmap"); + %0 = new %TYPE(QPixmap::fromImage(%1)); </inject-code> </add-function> + <modify-function signature="QPixmap(const char **)"> + <modify-argument index="1"> + <replace-type modified-type="PySequence" /> + </modify-argument> + <inject-code class="target" position="beginning"> + Shiboken::AutoDecRef strList(PySequence_Fast(%PYARG_1, "Invalid sequence.")); + int lineCount = PySequence_Fast_GET_SIZE(strList.object()); + for (int line = 0; line < lineCount; ++line) { + if (!PyString_Check(PySequence_Fast_GET_ITEM(strList.object(), line))) { + PyErr_SetString(PyExc_TypeError, "The argument must be a sequence of strings."); + break; + } + } + + const char** xpm = (const char**) malloc (lineCount * sizeof(const char**)); + for (int line = 0; line < lineCount; ++line) { + xpm[line] = PyString_AS_STRING(PySequence_Fast_GET_ITEM(strList.object(), line)); + } + + %BEGIN_ALLOW_THREADS + %0 = new %TYPE(xpm); + %END_ALLOW_THREADS + + free(xpm); + </inject-code> + </modify-function> <!-- ### Operator ! doesn't make sense in Python. --> <modify-function signature="operator!()const" remove="all"/> - <!-- ### See bug 757 --> - <modify-function signature="QPixmap(const char **)" remove="all"/> <!--### Obsolete in 4.3--> <modify-function signature="serialNumber()const" remove="all"/> <!-- ### --> |