eric6/Plugins/VcsPlugins/vcsGit/GitStashBrowserDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
32 DateColumn = 1 32 DateColumn = 1
33 MessageColumn = 2 33 MessageColumn = 2
34 34
35 Separator = "@@||@@" 35 Separator = "@@||@@"
36 36
37 TotalStatisticsRole = Qt.UserRole 37 TotalStatisticsRole = Qt.ItemDataRole.UserRole
38 FileStatisticsRole = Qt.UserRole + 1 38 FileStatisticsRole = Qt.ItemDataRole.UserRole + 1
39 39
40 def __init__(self, vcs, parent=None): 40 def __init__(self, vcs, parent=None):
41 """ 41 """
42 Constructor 42 Constructor
43 43
45 @param parent reference to the parent widget (QWidget) 45 @param parent reference to the parent widget (QWidget)
46 """ 46 """
47 super(GitStashBrowserDialog, self).__init__(parent) 47 super(GitStashBrowserDialog, self).__init__(parent)
48 self.setupUi(self) 48 self.setupUi(self)
49 49
50 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 50 self.buttonBox.button(
51 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 51 QDialogButtonBox.StandardButton.Close).setEnabled(False)
52 self.buttonBox.button(
53 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
52 54
53 self.__position = QPoint() 55 self.__position = QPoint()
54 56
55 self.__fileStatisticsRole = Qt.UserRole 57 self.__fileStatisticsRole = Qt.ItemDataRole.UserRole
56 self.__totalStatisticsRole = Qt.UserRole + 1 58 self.__totalStatisticsRole = Qt.ItemDataRole.UserRole + 1
57 59
58 self.stashList.header().setSortIndicator(0, Qt.AscendingOrder) 60 self.stashList.header().setSortIndicator(
61 0, Qt.SortOrder.AscendingOrder)
59 62
60 self.refreshButton = self.buttonBox.addButton( 63 self.refreshButton = self.buttonBox.addButton(
61 self.tr("&Refresh"), QDialogButtonBox.ActionRole) 64 self.tr("&Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
62 self.refreshButton.setToolTip( 65 self.refreshButton.setToolTip(
63 self.tr("Press to refresh the list of stashes")) 66 self.tr("Press to refresh the list of stashes"))
64 self.refreshButton.setEnabled(False) 67 self.refreshButton.setEnabled(False)
65 68
66 self.vcs = vcs 69 self.vcs = vcs
96 99
97 @param e close event (QCloseEvent) 100 @param e close event (QCloseEvent)
98 """ 101 """
99 if ( 102 if (
100 self.__process is not None and 103 self.__process is not None and
101 self.__process.state() != QProcess.NotRunning 104 self.__process.state() != QProcess.ProcessState.NotRunning
102 ): 105 ):
103 self.__process.terminate() 106 self.__process.terminate()
104 QTimer.singleShot(2000, self.__process.kill) 107 QTimer.singleShot(2000, self.__process.kill)
105 self.__process.waitForFinished(3000) 108 self.__process.waitForFinished(3000)
106 109
126 129
127 def __resizeColumnsStashes(self): 130 def __resizeColumnsStashes(self):
128 """ 131 """
129 Private method to resize the shelve list columns. 132 Private method to resize the shelve list columns.
130 """ 133 """
131 self.stashList.header().resizeSections(QHeaderView.ResizeToContents) 134 self.stashList.header().resizeSections(
135 QHeaderView.ResizeMode.ResizeToContents)
132 self.stashList.header().setStretchLastSection(True) 136 self.stashList.header().setStretchLastSection(True)
133 137
134 def __generateStashEntry(self, name, date, message): 138 def __generateStashEntry(self, name, date, message):
135 """ 139 """
136 Private method to generate the stash items. 140 Private method to generate the stash items.
143 147
144 def __getStashEntries(self): 148 def __getStashEntries(self):
145 """ 149 """
146 Private method to retrieve the list of stashes. 150 Private method to retrieve the list of stashes.
147 """ 151 """
148 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 152 self.buttonBox.button(
149 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 153 QDialogButtonBox.StandardButton.Close).setEnabled(False)
150 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 154 self.buttonBox.button(
155 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
156 self.buttonBox.button(
157 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
151 158
152 self.inputGroup.setEnabled(True) 159 self.inputGroup.setEnabled(True)
153 self.inputGroup.show() 160 self.inputGroup.show()
154 self.refreshButton.setEnabled(False) 161 self.refreshButton.setEnabled(False)
155 162
221 Private slot called when the process finished or the user pressed 228 Private slot called when the process finished or the user pressed
222 the button. 229 the button.
223 """ 230 """
224 if ( 231 if (
225 self.__process is not None and 232 self.__process is not None and
226 self.__process.state() != QProcess.NotRunning 233 self.__process.state() != QProcess.ProcessState.NotRunning
227 ): 234 ):
228 self.__process.terminate() 235 self.__process.terminate()
229 QTimer.singleShot(2000, self.__process.kill) 236 QTimer.singleShot(2000, self.__process.kill)
230 self.__process.waitForFinished(3000) 237 self.__process.waitForFinished(3000)
231 238
232 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 239 self.buttonBox.button(
233 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 240 QDialogButtonBox.StandardButton.Close).setEnabled(True)
234 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 241 self.buttonBox.button(
242 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
243 self.buttonBox.button(
244 QDialogButtonBox.StandardButton.Close).setDefault(True)
235 245
236 self.inputGroup.setEnabled(False) 246 self.inputGroup.setEnabled(False)
237 self.inputGroup.hide() 247 self.inputGroup.hide()
238 self.refreshButton.setEnabled(True) 248 self.refreshButton.setEnabled(True)
239 249
256 """ 266 """
257 Private slot to handle the readyReadStandardOutput signal. 267 Private slot to handle the readyReadStandardOutput signal.
258 268
259 It reads the output of the process and inserts it into a buffer. 269 It reads the output of the process and inserts it into a buffer.
260 """ 270 """
261 self.__process.setReadChannel(QProcess.StandardOutput) 271 self.__process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
262 272
263 while self.__process.canReadLine(): 273 while self.__process.canReadLine():
264 line = str(self.__process.readLine(), self.__ioEncoding, 274 line = str(self.__process.readLine(), self.__ioEncoding,
265 'replace').strip() 275 'replace').strip()
266 if line: 276 if line:
285 """ 295 """
286 Private slot called by a button of the button box clicked. 296 Private slot called by a button of the button box clicked.
287 297
288 @param button button that was clicked (QAbstractButton) 298 @param button button that was clicked (QAbstractButton)
289 """ 299 """
290 if button == self.buttonBox.button(QDialogButtonBox.Close): 300 if button == self.buttonBox.button(
301 QDialogButtonBox.StandardButton.Close
302 ):
291 self.close() 303 self.close()
292 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 304 elif button == self.buttonBox.button(
305 QDialogButtonBox.StandardButton.Cancel
306 ):
293 self.cancelled = True 307 self.cancelled = True
294 self.__finish() 308 self.__finish()
295 elif button == self.refreshButton: 309 elif button == self.refreshButton:
296 self.on_refreshButton_clicked() 310 self.on_refreshButton_clicked()
297 311
354 for dataDict in current.data(0, self.FileStatisticsRole): 368 for dataDict in current.data(0, self.FileStatisticsRole):
355 QTreeWidgetItem(self.statisticsList, [ 369 QTreeWidgetItem(self.statisticsList, [
356 dataDict["file"], dataDict["total"], 370 dataDict["file"], dataDict["total"],
357 dataDict["added"], dataDict["deleted"]]) 371 dataDict["added"], dataDict["deleted"]])
358 self.statisticsList.header().resizeSections( 372 self.statisticsList.header().resizeSections(
359 QHeaderView.ResizeToContents) 373 QHeaderView.ResizeMode.ResizeToContents)
360 self.statisticsList.header().setStretchLastSection(True) 374 self.statisticsList.header().setStretchLastSection(True)
361 375
362 totals = current.data(0, self.TotalStatisticsRole) 376 totals = current.data(0, self.TotalStatisticsRole)
363 self.filesLabel.setText( 377 self.filesLabel.setText(
364 self.tr("%n file(s) changed", None, totals["files"])) 378 self.tr("%n file(s) changed", None, totals["files"]))
426 Private slot to handle the password checkbox toggled. 440 Private slot to handle the password checkbox toggled.
427 441
428 @param checked flag indicating the status of the check box (boolean) 442 @param checked flag indicating the status of the check box (boolean)
429 """ 443 """
430 if checked: 444 if checked:
431 self.input.setEchoMode(QLineEdit.Password) 445 self.input.setEchoMode(QLineEdit.EchoMode.Password)
432 else: 446 else:
433 self.input.setEchoMode(QLineEdit.Normal) 447 self.input.setEchoMode(QLineEdit.EchoMode.Normal)
434 448
435 def keyPressEvent(self, evt): 449 def keyPressEvent(self, evt):
436 """ 450 """
437 Protected slot to handle a key press event. 451 Protected slot to handle a key press event.
438 452

eric ide

mercurial