aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtGui
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-08-16 11:47:29 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:44 -0300
commita17bf4130564d074023235bd5b99f95f86f79702 (patch)
treee5475225deb098d4d78f70439148a2d592346b95 /PySide/QtGui
parente3502d00fc5c8a9641641de8e8b5bafe7ea51fe4 (diff)
Implemented QColor.__repr__ and QColor.__str__ functions.
Fixes bug #961. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'PySide/QtGui')
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml51
1 files changed, 51 insertions, 0 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 38646d2b1..48e0a3064 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -1100,11 +1100,62 @@
<include file-name="QPixmap" location="global"/>
</extra-includes>
</value-type>
+
+ <template name="qcolor_repr">
+ switch(%CPPSELF.spec()) {
+ case QColor::Rgb:
+ {
+ qreal r, g, b, a;
+ %CPPSELF.getRgbF(&amp;r, &amp;g, &amp;b, &amp;a);
+ QString repr = QString().sprintf("PySide.QtGui.QColor.fromRgbF(%.6f, %.6f, %.6f, %.6f)", r, g, b, a);
+ %PYARG_0 = PyString_FromString(qPrintable(repr));
+ break;
+ }
+ case QColor::Hsv:
+ {
+ qreal h, s, v, a;
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;v, &amp;a);
+ QString repr = QString().sprintf("PySide.QtGui.QColor.fromHsvF(%.6f, %.6f, %.6f, %.6f)", h, s, v, a);
+ %PYARG_0 = PyString_FromString(qPrintable(repr));
+ break;
+ }
+ case QColor::Cmyk:
+ {
+ qreal c, m, y, k, a;
+ %CPPSELF.getCmykF(&amp;c, &amp;m, &amp;y, &amp;k, &amp;a);
+ QString repr = QString().sprintf("PySide.QtGui.QColor.fromCmykF(%.6f, %.6f, %.6f, %.6f, %.6f)", c, m, y, k, a);
+ %PYARG_0 = PyString_FromString(qPrintable(repr));
+ break;
+ }
+ #if QT_VERSION >= 0x040600
+ case QColor::Hsl:
+ {
+ qreal h, s, l, a;
+ %CPPSELF.getHsvF(&amp;h, &amp;s, &amp;l, &amp;a);
+ QString repr = QString().sprintf("PySide.QtGui.QColor.fromHslF(%.6f, %.6f, %.6f, %.6f)", h, s, l, a);
+ %PYARG_0 = PyString_FromString(qPrintable(repr));
+ break;
+ }
+ #endif
+ default:
+ %PYARG_0 = 0;
+ }
+ </template>
<value-type name="QColor">
<enum-type name="Spec"/>
<extra-includes>
<include file-name="QVariant" location="global"/>
</extra-includes>
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="qcolor_repr" />
+ </inject-code>
+ </add-function>
+ <add-function signature="__str__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ <insert-template name="qcolor_repr" />
+ </inject-code>
+ </add-function>
<add-function signature="__reduce__" return-type="PyObject*">
<inject-code class="target" position="beginning">
PyObject *createFunction = 0;