~javierder/qbzr/send

« back to all changes in this revision

Viewing changes to lib/uifactory.py

  • Committer: Gary van der Merwe
  • Date: 2009-06-12 03:18:47 UTC
  • mfrom: (760.1.11 trees)
  • Revision ID: garyvdm@gmail.com-20090612031847-nku4esk7sk7d7cwv
qannotate: Refactor so that we only load revisions if there lines that the revision touches on screen.

This give a small perforamnce increase for local branches and a big performance increase for remote branches.

Most of the code to do this is now common with qlog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
            return f(*args, **kargs)
37
37
    return decorate
38
38
 
 
39
def quifactory():
 
40
    if isinstance(ui.ui_factory, QUIFactory):
 
41
        return ui.ui_factory
 
42
    return None
 
43
 
 
44
def current_throbber():
 
45
    ui = quifactory()
 
46
    if ui:
 
47
        return ui.throbber()
 
48
    return None
 
49
 
39
50
class QUIFactory(ui.UIFactory):
40
51
 
41
52
    def __init__(self):
54
65
    
55
66
        self._progress_view._repaint = self.progress_view_repaint
56
67
    
 
68
    def throbber(self):
 
69
        current_widget = self.current_widget()
 
70
        if current_widget and getattr(current_widget, 'throbber', None) is not None:
 
71
            return current_widget.throbber
 
72
        return None
 
73
    
57
74
    def report_transport_activity(self, transport, byte_count, direction):
58
75
        """Called by transports as they do IO.
59
76
        
64
81
        self._total_byte_count += byte_count
65
82
        self._bytes_since_update += byte_count
66
83
 
67
 
        current_widget = self.current_widget()
68
 
        if current_widget and getattr(current_widget, 'throbber', None) is not None:
 
84
        throbber = self.throbber()
 
85
        if throbber:
69
86
            now = time.time()
70
87
            if self._transport_update_time is None:
71
88
                self._transport_update_time = now
83
100
                msg = ("%6dkB @         " %
84
101
                    (self._total_byte_count>>10,))
85
102
            
86
 
            current_widget.throbber.transport.setText(msg)
 
103
            throbber.transport.setText(msg)
87
104
        
88
105
        QtCore.QCoreApplication.processEvents()
89
106