Added hash functions for QLine, QPoint, QRect and QSize classes.
Tests where also added. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
62234b4f86
commit
4787f1eb0f
2 changed files with 63 additions and 4 deletions
|
|
@ -674,7 +674,15 @@
|
||||||
<include file-name="QSize" location="global"/>
|
<include file-name="QSize" location="global"/>
|
||||||
</extra-includes>
|
</extra-includes>
|
||||||
</object-type>
|
</object-type>
|
||||||
<value-type name="QLine"/>
|
<value-type name="QLine" hash-function="PySide::hash">
|
||||||
|
<inject-code class="native" position="beginning">
|
||||||
|
namespace PySide {
|
||||||
|
template<> inline uint hash(const QLine& v) {
|
||||||
|
return qHash(qMakePair(qMakePair(v.x1(), v.y1()), qMakePair(v.x2(), v.y2())));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</inject-code>
|
||||||
|
</value-type>
|
||||||
<value-type name="QLineF">
|
<value-type name="QLineF">
|
||||||
<enum-type name="IntersectType" />
|
<enum-type name="IntersectType" />
|
||||||
<modify-function signature="intersect(QLineF, QPointF*)const">
|
<modify-function signature="intersect(QLineF, QPointF*)const">
|
||||||
|
|
@ -756,7 +764,14 @@
|
||||||
<modify-function signature="QDir(QString,QString,QFlags<QDir::SortFlag>,QFlags<QDir::Filter>)" remove="all" />
|
<modify-function signature="QDir(QString,QString,QFlags<QDir::SortFlag>,QFlags<QDir::Filter>)" remove="all" />
|
||||||
</value-type>
|
</value-type>
|
||||||
|
|
||||||
<value-type name="QPoint">
|
<value-type name="QPoint" hash-function="PySide::hash">
|
||||||
|
<inject-code class="native" position="beginning">
|
||||||
|
namespace PySide {
|
||||||
|
template<> inline uint hash(const QPoint& v) {
|
||||||
|
return qHash(qMakePair(v.x(), v.y()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</inject-code>
|
||||||
<modify-function signature="rx()" remove="all"/>
|
<modify-function signature="rx()" remove="all"/>
|
||||||
<modify-function signature="ry()" remove="all"/>
|
<modify-function signature="ry()" remove="all"/>
|
||||||
</value-type>
|
</value-type>
|
||||||
|
|
@ -764,7 +779,14 @@
|
||||||
<modify-function signature="rx()" remove="all"/>
|
<modify-function signature="rx()" remove="all"/>
|
||||||
<modify-function signature="ry()" remove="all"/>
|
<modify-function signature="ry()" remove="all"/>
|
||||||
</value-type>
|
</value-type>
|
||||||
<value-type name="QRect">
|
<value-type name="QRect" hash-function="PySide::hash">
|
||||||
|
<inject-code class="native" position="beginning">
|
||||||
|
namespace PySide {
|
||||||
|
template<> inline uint hash(const QRect& v) {
|
||||||
|
return qHash(qMakePair(qMakePair(v.x(), v.y()), qMakePair(v.width(), v.height())));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</inject-code>
|
||||||
<modify-function signature="getCoords(int*,int*,int*,int*)const">
|
<modify-function signature="getCoords(int*,int*,int*,int*)const">
|
||||||
<remove/>
|
<remove/>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
|
@ -780,7 +802,15 @@
|
||||||
<remove/>
|
<remove/>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
</value-type>
|
</value-type>
|
||||||
<value-type name="QSize">
|
|
||||||
|
<value-type name="QSize" hash-function="PySide::hash">
|
||||||
|
<inject-code class="native" position="beginning">
|
||||||
|
namespace PySide {
|
||||||
|
template<> inline uint hash(const QSize& v) {
|
||||||
|
return qHash(qMakePair(v.width(), v.height()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</inject-code>
|
||||||
<modify-function signature="rheight()" remove="all"/>
|
<modify-function signature="rheight()" remove="all"/>
|
||||||
<modify-function signature="rwidth()" remove="all"/>
|
<modify-function signature="rwidth()" remove="all"/>
|
||||||
</value-type>
|
</value-type>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import unittest
|
import unittest
|
||||||
from PySide.QtCore import QDate, QDateTime, QTime, QUrl
|
from PySide.QtCore import QDate, QDateTime, QTime, QUrl
|
||||||
|
from PySide.QtCore import QLine, QPoint, QRect, QSize
|
||||||
|
|
||||||
class HashTest(unittest.TestCase):
|
class HashTest(unittest.TestCase):
|
||||||
def testInsert(self):
|
def testInsert(self):
|
||||||
|
|
@ -20,6 +21,34 @@ class HashTest(unittest.TestCase):
|
||||||
self.assertEqual(myHash[qtime], "QTime")
|
self.assertEqual(myHash[qtime], "QTime")
|
||||||
self.assertEqual(myHash[qurl], "QUrl")
|
self.assertEqual(myHash[qurl], "QUrl")
|
||||||
|
|
||||||
|
def testQPointHash(self):
|
||||||
|
p1 = QPoint(12, 34)
|
||||||
|
p2 = QPoint(12, 34)
|
||||||
|
self.assertFalse(p1 is p2)
|
||||||
|
self.assertEqual(p1, p2)
|
||||||
|
self.assertEqual(hash(p1), hash(p2))
|
||||||
|
|
||||||
|
def testQSizeHash(self):
|
||||||
|
s1 = QSize(12, 34)
|
||||||
|
s2 = QSize(12, 34)
|
||||||
|
self.assertFalse(s1 is s2)
|
||||||
|
self.assertEqual(s1, s2)
|
||||||
|
self.assertEqual(hash(s1), hash(s2))
|
||||||
|
|
||||||
|
def testQRectHash(self):
|
||||||
|
r1 = QRect(12, 34, 56, 78)
|
||||||
|
r2 = QRect(12, 34, 56, 78)
|
||||||
|
self.assertFalse(r1 is r2)
|
||||||
|
self.assertEqual(r1, r2)
|
||||||
|
self.assertEqual(hash(r1), hash(r2))
|
||||||
|
|
||||||
|
def testQLineHash(self):
|
||||||
|
l1 = QLine(12, 34, 56, 78)
|
||||||
|
l2 = QLine(12, 34, 56, 78)
|
||||||
|
self.assertFalse(l1 is l2)
|
||||||
|
self.assertEqual(l1, l2)
|
||||||
|
self.assertEqual(hash(l1), hash(l2))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue