mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
Give dataview.TreeListItem hash and equality operators.
Remove non equality operators from DataViewItem, as there is no implicit ordering of the items that makes sense
This commit is contained in:
@@ -84,12 +84,8 @@ def run():
|
||||
c.addCppMethod('long', '__hash__', '()', """\
|
||||
return (long)self->GetID();
|
||||
""")
|
||||
c.addCppMethod('bool', '__lt__', '(wxDataViewItem* other)', "return (self->GetID() < other->GetID());")
|
||||
c.addCppMethod('bool', '__le__', '(wxDataViewItem* other)', "return (self->GetID() <= other->GetID());")
|
||||
c.addCppMethod('bool', '__eq__', '(wxDataViewItem* other)', "return (self->GetID() == other->GetID());")
|
||||
c.addCppMethod('bool', '__ne__', '(wxDataViewItem* other)', "return (self->GetID() != other->GetID());")
|
||||
c.addCppMethod('bool', '__ge__', '(wxDataViewItem* other)', "return (self->GetID() >= other->GetID());")
|
||||
c.addCppMethod('bool', '__gt__', '(wxDataViewItem* other)', "return (self->GetID() > other->GetID());")
|
||||
c.addAutoProperties()
|
||||
|
||||
|
||||
|
||||
@@ -42,10 +42,18 @@ def run():
|
||||
#-----------------------------------------------------------------
|
||||
c = module.find('wxTreeListItem')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
|
||||
c.addCppMethod('int', '__nonzero__', '()', """\
|
||||
return self->IsOk();
|
||||
""")
|
||||
|
||||
c.addCppMethod('long', '__hash__', '()', """\
|
||||
return (long)self->GetID();
|
||||
""")
|
||||
|
||||
c.addCppMethod('bool', '__eq__', '(wxTreeListItem* other)', "return (self->GetID() == other->GetID());")
|
||||
c.addCppMethod('bool', '__ne__', '(wxTreeListItem* other)', "return (self->GetID() != other->GetID());")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
c = module.find('wxTreeListItemComparator')
|
||||
|
||||
@@ -65,6 +65,18 @@ class treelist_Tests(wtc.WidgetTestCase):
|
||||
self.assertTrue(isinstance(s, list))
|
||||
self.assertEqual(len(s), 1)
|
||||
self.assertTrue(isinstance(s[0], wx.dataview.TreeListItem))
|
||||
self.assertTrue(root == s[0])
|
||||
|
||||
|
||||
def test_treelistitem_hashable(self):
|
||||
tlc = wx.dataview.TreeListCtrl(self.frame)
|
||||
root = self._populateTree(tlc)
|
||||
d = dict()
|
||||
d[root] = 'root'
|
||||
|
||||
tlc.Select(root)
|
||||
s = tlc.GetSelections()
|
||||
assert d[s[0]] == 'root'
|
||||
|
||||
|
||||
def test_treelist3(self):
|
||||
|
||||
Reference in New Issue
Block a user