Rev 163: Some fairly broken work on playing with a custom model for WT viewing. in http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
John Arbash Meinel
john at arbash-meinel.com
Tue Jul 7 20:44:26 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr-explorer/wt_model
------------------------------------------------------------
revno: 163
revision-id: john at arbash-meinel.com-20090707194419-lm7utnurj1n15nr6
parent: john at arbash-meinel.com-20090707193948-7aoywu7hx628yys6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: wt_model
timestamp: Tue 2009-07-07 14:44:19 -0500
message:
Some fairly broken work on playing with a custom model for WT viewing.
-------------- next part --------------
=== modified file 'lib/wt_browser.py'
--- a/lib/wt_browser.py 2009-07-02 06:50:18 +0000
+++ b/lib/wt_browser.py 2009-07-07 19:44:19 +0000
@@ -26,6 +26,35 @@
)
+class WorkingTreeModel(QtGui.QDirModel):
+ """A model that starts to know information about a given directory.
+ """
+
+ def __init__(self, parent=None):
+ QtGui.QDirModel.__init__(self, parent)
+ self._dir_model_columns = QtGui.QDirModel.columnCount(self)
+ self._extra_data = {}
+
+ def columnCount(self, ignored=None):
+ return self._dir_model_columns + 1
+
+ def data(self, index, role):
+ if not index.isValid():
+ return QtCore.QVariant()
+ column = index.column() - self._dir_model_columns
+ if column < 0:
+ return QtGui.QDirModel.data(self, index, role)
+ if role != QtCore.Qt.DisplayRole:
+ return QtCore.QVariant()
+ return QtCore.QVariant('this is my str')
+
+ def headerData(self, section, orientation, role):
+ column = section - self._dir_model_columns
+ if column < 0:
+ return QtGui.QDirModel.headerData(self, section, orientation, role)
+ return QtCore.QVariant('my section')
+
+
class WorkingTreeBrowser(QtGui.QDockWidget):
def __init__(self, action_callback, browse_action, *args):
@@ -39,7 +68,7 @@
def _build_ui(self):
# Init them model and view
- model = QtGui.QDirModel()
+ model = WorkingTreeModel()
# sort flags for tree view: direcotries first,
# on Windows items are case-insensitive
flags = QtCore.QDir.SortFlags(QtCore.QDir.Name|QtCore.QDir.DirsFirst)
@@ -50,10 +79,10 @@
view.setModel(model)
# Hide all except the Name column
- for i in range(1, model.columnCount()):
- view.setColumnHidden(i, True)
- if getattr(view, 'setHeaderHidden', None):
- view.setHeaderHidden(True)
+ # for i in range(1, model.columnCount()):
+ # view.setColumnHidden(i, True)
+ # if getattr(view, 'setHeaderHidden', None):
+ # view.setHeaderHidden(True)
# Build a button bar for the view
browse_button = QtGui.QPushButton()
More information about the bazaar-commits
mailing list