1 from PyQt4
import QtGui
2 from PyQt4
import QtCore
3 from PyQt4
.QtCore
import SIGNAL
9 from cola
import gitcmds
10 from cola
import signals
11 from cola
.widgets
.selectcommits
import select_commits
12 from cola
.classic
.view
import Browser
13 from cola
.classic
.model
import GitRepoModel
14 from cola
.classic
.model
import GitRepoEntryManager
15 from cola
.compat
import set
18 def widget(parent
, update
=True):
19 """Return a widget for immediate use."""
20 view
= Browser(parent
, update
=update
)
21 view
.tree
.setModel(GitRepoModel(view
.tree
))
22 view
.ctl
= ClassicController(view
.tree
)
26 def cola_classic(update
=True):
27 """Launch a new cola classic session."""
28 view
= widget(None, update
=update
)
33 class ClassicController(QtCore
.QObject
):
34 def __init__(self
, view
=None):
35 QtCore
.QObject
.__init
__(self
, view
)
36 self
.model
= cola
.model()
39 self
.connect(view
, SIGNAL('history(QStringList)'),
41 self
.connect(view
, SIGNAL('expanded(QModelIndex)'),
43 self
.connect(view
, SIGNAL('difftool_predecessor'),
44 self
.difftool_predecessor
)
46 def view_history(self
, entries
):
47 """Launch the configured history browser path-limited to entries."""
48 entries
= map(unicode, entries
)
49 cola
.notifier().broadcast(signals
.visualize_paths
, entries
)
51 def query_model(self
, model_index
):
52 """Update information about a directory as it is expanded."""
53 item
= self
.view
.item_from_index(model_index
)
55 if path
in self
.updated
:
57 self
.updated
.add(path
)
58 GitRepoEntryManager
.entry(path
).update()
59 entry
= GitRepoEntryManager
.entry
60 for row
in xrange(item
.rowCount()):
61 path
= item
.child(row
, 0).path
64 def difftool_predecessor(self
, paths
):
65 """Prompt for an older commit and launch difftool against it."""
67 revs
, summaries
= gitcmds
.log_helper(all
=False, extra_args
=args
)
68 commits
= select_commits('Select Previous Version',
69 revs
, summaries
, multiselect
=False)
73 cola
.difftool
.launch([commit
, '--'] + paths
)
76 if __name__
== '__main__':
79 app
= QtGui
.QApplication(sys
.argv
)
82 QtCore
.QThreadPool
.globalInstance().waitForDone()