1
# -*- coding: utf-8 -*-
3
# Copyright (c) 2002 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
6
# It is inspired by the cvs history form code found in LinCVS
10
Module implementing a dialog to show the output of the cvs history command process.
15
from PyQt4.QtCore import *
16
from PyQt4.QtGui import *
18
from Ui_CvsHistoryDialog import Ui_CvsHistoryDialog
20
class CvsHistoryDialog(QWidget, Ui_CvsHistoryDialog):
22
Module implementing a dialog to show the output of the cvs history command process.
24
def __init__(self, vcs, parent = None):
28
@param vcs reference to the vcs object
29
@param parent parent widget (QWidget)
31
QWidget.__init__(self, parent)
34
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
35
self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
37
self.process = QProcess()
41
self.connect(self.process, SIGNAL('finished(int, QProcess::ExitStatus)'),
43
self.connect(self.process, SIGNAL('readyReadStandardOutput()'),
45
self.connect(self.process, SIGNAL('readyReadStandardError()'),
50
Private method to resort the tree.
52
self.historyList.sortItems(self.historyList.sortColumn(),
53
self.historyList.header().sortIndicatorOrder())
55
def __resizeColumns(self):
57
Private method to resize the list columns.
59
self.historyList.header().resizeSections(QHeaderView.ResizeToContents)
60
self.historyList.header().setStretchLastSection(True)
62
def __generateItem(self, index, date, time, timezone, event, author, revision,
65
Private method to generate a status item in the status list.
67
@param index index number of the history entry (integer)
68
@param date date of the entry (string or QString)
69
@param time time of the entry (string or QString)
70
@param timezone timezone of the entry (string or QString)
71
@param event event type (string or QString)
72
@param author author (string or QString)
73
@param revision revision number (string or QString)
74
@param file file name (string or QString)
75
@param path path of the file (string or QString)
77
itm = QTreeWidgetItem(self.historyList,
80
<< ' %s %s %s ' % (unicode(date), unicode(time), unicode(timezone)) \
88
def closeEvent(self, e):
90
Private slot implementing a close event handler.
92
@param e close event (QCloseEvent)
94
if self.process is not None and \
95
self.process.state() != QProcess.NotRunning:
96
self.process.terminate()
97
QTimer.singleShot(2000, self.process, SLOT('kill()'))
98
self.process.waitForFinished(3000)
104
Public slot to start the cvs history command.
106
@param fn filename (string)
108
self.setWindowTitle(self.trUtf8('CVS History %1').arg(fn))
109
QApplication.processEvents()
111
self.intercept = False
113
self.dname, self.fname = self.vcs.splitPath(fn)
118
self.vcs.addArguments(args, self.vcs.options['global'])
119
args.append('history')
120
self.vcs.addArguments(args, self.vcs.options['history'])
121
args.append(self.fname)
123
self.process.setWorkingDirectory(self.dname)
125
self.process.start('cvs', args)
129
Private slot called when the process finished or the user pressed the button.
131
if self.process is not None and \
132
self.process.state() != QProcess.NotRunning:
133
self.process.terminate()
134
QTimer.singleShot(2000, self.process, SLOT('kill()'))
135
self.process.waitForFinished(3000)
137
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
138
self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
139
self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
141
self.inputGroup.setEnabled(False)
145
self.historyList.doItemsLayout()
146
self.__resizeColumns()
149
def on_buttonBox_clicked(self, button):
151
Private slot called by a button of the button box clicked.
153
@param button button that was clicked (QAbstractButton)
155
if button == self.buttonBox.button(QDialogButtonBox.Close):
157
elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
160
def __procFinished(self, exitCode, exitStatus):
162
Private slot connected to the finished signal.
164
@param exitCode exit code of the process (integer)
165
@param exitStatus exit status of the process (QProcess.ExitStatus)
169
def __readStdout(self):
171
Private slot to handle the readyReadStdout signal.
173
It reads the output of the process, formats it and inserts it into
176
self.process.setReadChannel(QProcess.StandardOutput)
178
while self.process.canReadLine():
179
s = QString(self.process.readLine())
184
list = s.split(' ', QString.SkipEmptyParts)
187
continue # we got something
189
if cmd in ['O', 'F', 'E']:
190
if list.count() != 8:
191
continue # we got some bad output
193
if unicode(self.fname) != '.':
196
if list.count() != 10:
197
continue # we got some bad output
199
dir = unicode(list[7])
200
if unicode(self.dname)[-len(dir):] != dir:
204
event = self.trUtf8('Checkout ')
206
event = self.trUtf8('Tag ')
208
event = self.trUtf8('Release ')
210
event = self.trUtf8('Export ')
213
event = self.trUtf8('Update, Deleted ')
215
event = self.trUtf8('Update, Copied ')
217
event = self.trUtf8('Update, Merged ')
219
event = self.trUtf8('Update, Conflict ')
221
event = self.trUtf8('Update, Patched')
224
event = self.trUtf8('Commit, Modified ')
226
event = self.trUtf8('Commit, Added ')
228
event = self.trUtf8('Commit, Removed ')
230
event = self.trUtf8('Unknown (%1)').arg(cmd)
233
self.__generateItem(self.index, list[1], list[2], list[3], event,
234
list[4], list[5], list[6], list[7])
236
self.__generateItem(self.index, list[1], list[2], list[3], event,
237
list[4], '', '', list[5])
241
def __readStderr(self):
243
Private slot to handle the readyReadStderr signal.
245
It reads the error output of the process and inserts it into the
248
if self.process is not None:
249
s = QString(self.process.readAllStandardError())
250
self.errors.insertPlainText(s)
251
self.errors.ensureCursorVisible()
253
def on_passwordCheckBox_toggled(self, isOn):
255
Private slot to handle the password checkbox toggled.
257
@param isOn flag indicating the status of the check box (boolean)
260
self.input.setEchoMode(QLineEdit.Password)
262
self.input.setEchoMode(QLineEdit.Normal)
265
def on_sendButton_clicked(self):
267
Private slot to send the input to the subversion process.
269
input = self.input.text()
270
input.append(os.linesep)
272
if self.passwordCheckBox.isChecked():
273
self.errors.insertPlainText(os.linesep)
274
self.errors.ensureCursorVisible()
276
self.errors.insertPlainText(input)
277
self.errors.ensureCursorVisible()
279
self.proc.write(input.toLocal8Bit())
281
self.passwordCheckBox.setChecked(False)
284
def on_input_returnPressed(self):
286
Private slot to handle the press of the return key in the input field.
288
self.intercept = True
289
self.on_sendButton_clicked()
291
def keyPressEvent(self, evt):
293
Protected slot to handle a key press event.
295
@param evt the key press event (QKeyEvent)
298
self.intercept = False
301
QWidget.keyPressEvent(self, evt)