Fix bug 821 - "Mapping interface for QPixmapCache"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
ef45b5a924
commit
e3539a09a8
2 changed files with 18 additions and 1 deletions
|
|
@ -2382,8 +2382,18 @@
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QPixmapCache">
|
<object-type name="QPixmapCache">
|
||||||
<value-type name="Key"/>
|
<value-type name="Key"/>
|
||||||
|
<add-function signature="find(QPixmapCache::Key)">
|
||||||
|
<inject-code>
|
||||||
|
QPixmap p;
|
||||||
|
if (%CPPSELF.%FUNCTION_NAME(%1, &p)) {
|
||||||
|
%PYARG_0 = %CONVERTTOPYTHON[QPixmap](p);
|
||||||
|
} else {
|
||||||
|
%PYARG_0 = Py_None;
|
||||||
|
Py_INCREF(%PYARG_0);
|
||||||
|
}
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
<!-- ### Obsolete. -->
|
<!-- ### Obsolete. -->
|
||||||
<modify-function signature="find(QString)" remove="all"/>
|
|
||||||
<modify-function signature="find(QString,QPixmap&)" remove="all"/>
|
<modify-function signature="find(QString,QPixmap&)" remove="all"/>
|
||||||
<!--### End of obsolete section -->
|
<!--### End of obsolete section -->
|
||||||
</object-type>
|
</object-type>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ class QPixmapCacheTest(UsesQApplication):
|
||||||
ok = QPixmapCache.find('img', pm1)
|
ok = QPixmapCache.find('img', pm1)
|
||||||
self.assertFalse(ok)
|
self.assertFalse(ok)
|
||||||
|
|
||||||
|
self.assertEqual(QPixmapCache.find('img'), None)
|
||||||
|
|
||||||
pm2 = QPixmap()
|
pm2 = QPixmap()
|
||||||
ok = QPixmapCache.insert('img', pm2)
|
ok = QPixmapCache.insert('img', pm2)
|
||||||
self.assertTrue(ok)
|
self.assertTrue(ok)
|
||||||
|
|
@ -18,11 +20,15 @@ class QPixmapCacheTest(UsesQApplication):
|
||||||
ok = QPixmapCache.find('img', pm3)
|
ok = QPixmapCache.find('img', pm3)
|
||||||
self.assertTrue(ok)
|
self.assertTrue(ok)
|
||||||
|
|
||||||
|
self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits())
|
||||||
|
|
||||||
def testWithKey(self):
|
def testWithKey(self):
|
||||||
pm1 = QPixmap()
|
pm1 = QPixmap()
|
||||||
ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
|
ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
|
||||||
self.assertFalse(ok)
|
self.assertFalse(ok)
|
||||||
|
|
||||||
|
self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)
|
||||||
|
|
||||||
pm2 = QPixmap()
|
pm2 = QPixmap()
|
||||||
key = QPixmapCache.insert(pm2)
|
key = QPixmapCache.insert(pm2)
|
||||||
|
|
||||||
|
|
@ -30,6 +36,7 @@ class QPixmapCacheTest(UsesQApplication):
|
||||||
ok = QPixmapCache.find(key, pm3)
|
ok = QPixmapCache.find(key, pm3)
|
||||||
self.assertTrue(ok)
|
self.assertTrue(ok)
|
||||||
|
|
||||||
|
self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue