aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-03-23 08:29:18 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-03-23 09:45:49 -0300
commit290d773b323e8a0c7e9178b4c7997dcb2db5ba97 (patch)
treec65589841192ed715a39436519ba8dde804a19e0
parentc424162a0380609eed447fd370467813242fec08 (diff)
Adds a hash function to QTreeWidgetItem objects.
A "hashable" unit test was added as well. Reviewed by Anderson Lizardo <anderson.lizardo@openbossa.org> Reviewed by Bruno Araújo <bruno.araujo@openbossa.org>
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml2
-rw-r--r--tests/qtgui/hashabletype_test.py18
2 files changed, 19 insertions, 1 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 5e1d6b4db..42293461a 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -2856,7 +2856,7 @@
</modify-argument>
</modify-function>
</object-type>
- <object-type name="QTreeWidgetItem" >
+ <object-type name="QTreeWidgetItem" hash-function="qHash">
<modify-function signature="operator&lt;(QTreeWidgetItem)const">
<modify-argument index="1" invalidate-after-use="yes"/>
</modify-function>
diff --git a/tests/qtgui/hashabletype_test.py b/tests/qtgui/hashabletype_test.py
new file mode 100644
index 000000000..64683a398
--- /dev/null
+++ b/tests/qtgui/hashabletype_test.py
@@ -0,0 +1,18 @@
+'''Test cases for __hash__'''
+
+import unittest
+
+from PySide.QtGui import QTreeWidgetItem
+from helper import UsesQApplication
+
+class HashableTest(UsesQApplication):
+
+ def testQTreeWidgetItemHash(self):
+ h = {}
+ obj = QTreeWidgetItem()
+ h[obj] = 2
+ self.assert_(h.get(obj), 2)
+
+if __name__ == '__main__':
+ unittest.main()
+