summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-07-20 17:48:15 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-07-20 19:11:48 -0300
commit0c2b68c9049980eaafb9fee77b2186837f00d843 (patch)
treefc3f55470aa0907171503d56e27362c41341cede
parent2e98f87d20b5b310d40995acefb93b1a105025de (diff)
downloadpyside-0c2b68c9049980eaafb9fee77b2186837f00d843.tar.gz
pyside-0c2b68c9049980eaafb9fee77b2186837f00d843.tar.xz
pyside-0c2b68c9049980eaafb9fee77b2186837f00d843.zip
Fix bug 821 - "Mapping interface for QPixmapCache"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml12
-rw-r--r--tests/QtGui/qpixmapcache_test.py7
2 files changed, 18 insertions, 1 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 66fe96b..8e2eec9 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -2382,8 +2382,18 @@
</object-type>
<object-type name="QPixmapCache">
<value-type name="Key"/>
+ <add-function signature="find(QPixmapCache::Key)">
+ <inject-code>
+ QPixmap p;
+ if (%CPPSELF.%FUNCTION_NAME(%1, &amp;p)) {
+ %PYARG_0 = %CONVERTTOPYTHON[QPixmap](p);
+ } else {
+ %PYARG_0 = Py_None;
+ Py_INCREF(%PYARG_0);
+ }
+ </inject-code>
+ </add-function>
<!-- ### Obsolete. -->
- <modify-function signature="find(QString)" remove="all"/>
<modify-function signature="find(QString,QPixmap&amp;)" remove="all"/>
<!--### End of obsolete section -->
</object-type>
diff --git a/tests/QtGui/qpixmapcache_test.py b/tests/QtGui/qpixmapcache_test.py
index 33d631b..68b4d92 100644
--- a/tests/QtGui/qpixmapcache_test.py
+++ b/tests/QtGui/qpixmapcache_test.py
@@ -10,6 +10,8 @@ class QPixmapCacheTest(UsesQApplication):
ok = QPixmapCache.find('img', pm1)
self.assertFalse(ok)
+ self.assertEqual(QPixmapCache.find('img'), None)
+
pm2 = QPixmap()
ok = QPixmapCache.insert('img', pm2)
self.assertTrue(ok)
@@ -18,11 +20,15 @@ class QPixmapCacheTest(UsesQApplication):
ok = QPixmapCache.find('img', pm3)
self.assertTrue(ok)
+ self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
+
def testWithKey(self):
pm1 = QPixmap()
ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
self.assertFalse(ok)
+ self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)
+
pm2 = QPixmap()
key = QPixmapCache.insert(pm2)
@@ -30,6 +36,7 @@ class QPixmapCacheTest(UsesQApplication):
ok = QPixmapCache.find(key, pm3)
self.assertTrue(ok)
+ self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
if __name__ == '__main__':
unittest.main()