/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to branchview/treemodel.py

  • Committer: Daniel Schierbeck
  • Date: 2008-04-07 20:34:51 UTC
  • mfrom: (450.6.13 bugs)
  • mto: (463.2.1 bug.78765)
  • mto: This revision was merged to the branch mainline in revision 462.
  • Revision ID: daniel.schierbeck@gmail.com-20080407203451-2i6el7jf9t0k9y64
Merged bug page improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
import gtk
11
11
import gobject
 
12
import pango
 
13
import re
12
14
from xml.sax.saxutils import escape
13
15
 
14
 
from bzrlib.config import parse_username
15
 
from bzrlib.revision import NULL_REVISION
16
 
 
17
 
from time import (
18
 
    strftime,
19
 
    localtime,
20
 
    )
 
16
from time import (strftime, localtime)
21
17
 
22
18
REVID = 0
23
19
NODE = 1
32
28
PARENTS = 10
33
29
CHILDREN = 11
34
30
TAGS = 12
35
 
AUTHORS = 13
36
31
 
37
32
class TreeModel(gtk.GenericTreeModel):
38
33
 
 
34
    
39
35
    def __init__ (self, branch, line_graph_data):
40
36
        gtk.GenericTreeModel.__init__(self)
41
37
        self.revisions = {}
42
 
        self.branch = branch
 
38
        self.branch = branch
43
39
        self.repository = branch.repository
44
40
        self.line_graph_data = line_graph_data
45
41
 
46
 
        if self.branch.supports_tags():
 
42
        if self.branch.supports_tags():
47
43
            self.tags = self.branch.tags.get_reverse_tag_dict()
48
44
        else:
49
45
            self.tags = {}
57
53
 
58
54
    def on_get_flags(self):
59
55
        return gtk.TREE_MODEL_LIST_ONLY
60
 
 
 
56
    
61
57
    def on_get_n_columns(self):
62
 
        return 14
63
 
 
 
58
        return 13
 
59
    
64
60
    def on_get_column_type(self, index):
65
61
        if index == REVID: return gobject.TYPE_STRING
66
62
        if index == NODE: return gobject.TYPE_PYOBJECT
75
71
        if index == PARENTS: return gobject.TYPE_PYOBJECT
76
72
        if index == CHILDREN: return gobject.TYPE_PYOBJECT
77
73
        if index == TAGS: return gobject.TYPE_PYOBJECT
78
 
        if index == AUTHORS: return gobject.TYPE_STRING
79
 
 
 
74
        
80
75
    def on_get_iter(self, path):
81
76
        return path[0]
82
 
 
 
77
    
83
78
    def on_get_path(self, rowref):
84
79
        return rowref
85
 
 
 
80
    
86
81
    def on_get_value(self, rowref, column):
87
82
        if len(self.line_graph_data) > 0:
88
83
            (revid, node, lines, parents,
105
100
 
106
101
        if column == TAGS: return self.tags.get(revid, [])
107
102
 
108
 
        if not revid or revid == NULL_REVISION:
 
103
        if revid is None:
109
104
            return None
110
105
        if revid not in self.revisions:
111
106
            revision = self.repository.get_revisions([revid])[0]
112
107
            self.revisions[revid] = revision
113
108
        else:
114
109
            revision = self.revisions[revid]
115
 
 
 
110
        
116
111
        if column == REVISION: return revision
117
112
        if column == SUMMARY: return escape(revision.get_summary())
118
113
        if column == MESSAGE: return escape(revision.message)
119
 
        if column == COMMITTER: return parse_username(revision.committer)[0]
120
 
        if column == TIMESTAMP:
 
114
        if column == COMMITTER: return re.sub('<.*@.*>', '', 
 
115
                                             revision.committer).strip(' ')
 
116
        if column == TIMESTAMP: 
121
117
            return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp))
122
 
        if column == AUTHORS:
123
 
            return ", ".join([
124
 
                parse_username(author)[0] for author in revision.get_apparent_authors()])
125
118
 
126
119
    def on_iter_next(self, rowref):
127
120
        if rowref < len(self.line_graph_data) - 1:
128
121
            return rowref+1
129
122
        return None
130
 
 
 
123
    
131
124
    def on_iter_children(self, parent):
132
125
        if parent is None: return 0
133
126
        return None
134
 
 
 
127
    
135
128
    def on_iter_has_child(self, rowref):
136
129
        return False
137
 
 
 
130
    
138
131
    def on_iter_n_children(self, rowref):
139
132
        if rowref is None: return len(self.line_graph_data)
140
133
        return 0
141
 
 
 
134
    
142
135
    def on_iter_nth_child(self, parent, n):
143
136
        if parent is None: return n
144
137
        return None
145
 
 
 
138
    
146
139
    def on_iter_parent(self, child):
147
140
        return None