Rev 171: Implement flags() though we may need further refinements. in http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 7 23:08:03 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
------------------------------------------------------------
revno: 171
revision-id: john at arbash-meinel.com-20090707220759-bu83yqbq43eqkodg
parent: john at arbash-meinel.com-20090707220101-81fmz8kk5bn47sqa
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: wt_model
timestamp: Tue 2009-07-07 17:07:59 -0500
message:
Implement flags() though we may need further refinements.
-------------- next part --------------
=== modified file 'lib/wt_model.py'
--- a/lib/wt_model.py 2009-07-07 22:01:01 +0000
+++ b/lib/wt_model.py 2009-07-07 22:07:59 +0000
@@ -155,6 +155,13 @@
return QtCore.QVariant(headers[section])
return QtCore.QVariant()
+ def flags(self, index):
+ if index is None or not index.isValid():
+ # This should really be a QtCore.Qt.ItemFlags object, not sure how
+ # to cast it into one, though
+ return 0
+ return (QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
+
# def data(self, ...):
# implement def setData(self, ...) if we want to be editable
=== modified file 'tests/test_wt_model.py'
--- a/tests/test_wt_model.py 2009-07-07 22:01:01 +0000
+++ b/tests/test_wt_model.py 2009-07-07 22:07:59 +0000
@@ -29,6 +29,19 @@
class TestWTModel(tests.TestCaseWithTransport):
+ def test_flags_empty(self):
+ wt = self.make_branch_and_tree('.')
+ model = wt_model.WorkingTreeModel(wt)
+ self.assertEqual(0, model.flags(QtCore.QModelIndex()))
+
+ def test_flags_are_readonly(self):
+ wt = self.make_branch_and_tree('.')
+ self.build_tree(['a_file'])
+ model = wt_model.WorkingTreeModel(wt)
+ index = model.index(0, 0, None)
+ self.assertEqual(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable,
+ model.flags(index))
+
def test_index_invalid(self):
wt = self.make_branch_and_tree('.')
model = wt_model.WorkingTreeModel(wt)
More information about the bazaar-commits
mailing list