aboutsummaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-01-24 18:18:45 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:51:49 -0300
commit9c7755b08018b1e71d7895e20f91f848152ffe9d (patch)
tree6cc6271c1d86c5794eb433d7e4c0b74d93b7568d /PySide
parenta51b488ca06d412c7071f4f44e556d45b022ec81 (diff)
Implement support to others color spec on deepcopy function.
Created unit test QColor reduce function. Fixes bug #612. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml42
1 files changed, 38 insertions, 4 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index d606fdb2b..c6f29443d 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -766,10 +766,44 @@
</extra-includes>
<add-function signature="__reduce__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- <insert-template name="reduce_code">
- <replace from="%REDUCE_FORMAT" to="iiii" />
- <replace from="%REDUCE_ARGS" to="%CPPSELF.red(), %CPPSELF.green(), %CPPSELF.blue(), %CPPSELF.alpha()" />
- </insert-template>
+ PyObject *createFunction = 0;
+
+ switch(%CPPSELF.spec()) {
+ case QColor::Rgb:
+ {
+ qreal r, g, b, a;
+ createFunction = PyObject_GetAttrString(%PYSELF, "fromRgbF");
+ %CPPSELF.getRgbF(&amp;r, &amp;g, &amp;b, &amp;a);
+ %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, r, g, b, a);
+ break;
+ }
+ case QColor::Hsv:
+ {
+ qreal h, s, v, a;
+ createFunction = PyObject_GetAttrString(%PYSELF, "fromHsvF");
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;v, &amp;a);
+ %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, v, a);
+ break;
+ }
+ case QColor::Cmyk:
+ {
+ qreal c, m, y, k, a;
+ createFunction = PyObject_GetAttrString(%PYSELF, "fromCmykF");
+ %CPPSELF.getCmykF(&amp;c, &amp;m, &amp;y, &amp;k, &amp;a);
+ %PYARG_0 = Py_BuildValue("(N(fffff))", createFunction, c, m, y, k, a);
+ break;
+ }
+ case QColor::Hsl:
+ {
+ qreal h, s, l, a;
+ createFunction = PyObject_GetAttrString(%PYSELF, "fromHslF");
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;l, &amp;a);
+ %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, l, a);
+ break;
+ }
+ default:
+ %PYARG_0 = 0;
+ }
</inject-code>
</add-function>
<modify-function signature="QColor(QColor::Spec)" remove="all"/>