Rev 178: Add a decoration for column 0 from the QDirModel in http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
John Arbash Meinel
john at arbash-meinel.com
Thu Jul 9 19:33:20 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
------------------------------------------------------------
revno: 178
revision-id: john at arbash-meinel.com-20090709183314-bewoe20y3s4myix0
parent: john at arbash-meinel.com-20090709174453-tk9eahp0g02llou9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: wt_model
timestamp: Thu 2009-07-09 13:33:14 -0500
message:
Add a decoration for column 0 from the QDirModel
-------------- next part --------------
=== modified file 'lib/wt_model.py'
--- a/lib/wt_model.py 2009-07-08 19:39:21 +0000
+++ b/lib/wt_model.py 2009-07-09 18:33:14 +0000
@@ -176,10 +176,12 @@
# TODO: implement uspport for Qt.DecorationRole, if we return a
# QPixmap, then we will get the displayed icon.
item = index.internalPointer()
- if role == QtCore.Qt.DecorationRole:
+ if role == QtCore.Qt.DecorationRole and index.column() == 0:
# Return the decoration from an QDirModel
dir_index = self._dirmodel.index(item.path)
- return self._dirmodel.data(dir_index, role)
+ data = self._dirmodel.data(dir_index, role)
+ # print data
+ return data
if role != QtCore.Qt.DisplayRole:
return QtCore.QVariant()
attr = self._column_to_attribute[index.column()]
=== modified file 'tests/test_wt_model.py'
--- a/tests/test_wt_model.py 2009-07-08 19:39:21 +0000
+++ b/tests/test_wt_model.py 2009-07-09 18:33:14 +0000
@@ -25,9 +25,10 @@
)
from bzrlib.plugins.explorer.lib import wt_model
-
-
-class TestWTModel(tests.TestCaseWithTransport):
+from bzrlib.plugins.explorer.tests import TestCaseWithQt
+
+
+class TestWTModel(TestCaseWithQt):
def test_flags_empty(self):
wt = self.make_branch_and_tree('.')
@@ -91,7 +92,12 @@
res = model.data(a_index, QtCore.Qt.DecorationRole)
self.assertIsInstance(res, QtCore.QVariant)
self.assertTrue(res.isValid())
- self.assertTrue(res.canConvert(QtGui.QPixmap))
+ self.assertEqual('QIcon', res.typeName())
+ # For records not at column 0, we should get nothing
+ a_index = model.index(0, 1, root_index)
+ res = model.data(a_index, QtCore.Qt.DecorationRole)
+ self.assertIsInstance(res, QtCore.QVariant)
+ self.assertFalse(res.isValid())
def test_index_invalid(self):
wt = self.make_branch_and_tree('.')
More information about the bazaar-commits
mailing list