eric6/Plugins/VcsPlugins/vcsSubversion/SvnRepoBrowserDialog.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8143
2c730d5fd177
child 8218
7c09585bd960
equal deleted inserted replaced
8153:e01ae92db699 8176:31965986ecd1
38 @param mode mode of the dialog (string, "browse" or "select") 38 @param mode mode of the dialog (string, "browse" or "select")
39 @param parent parent widget (QWidget) 39 @param parent parent widget (QWidget)
40 """ 40 """
41 super(SvnRepoBrowserDialog, self).__init__(parent) 41 super(SvnRepoBrowserDialog, self).__init__(parent)
42 self.setupUi(self) 42 self.setupUi(self)
43 self.setWindowFlags(Qt.Window) 43 self.setWindowFlags(Qt.WindowType.Window)
44 44
45 self.repoTree.headerItem().setText(self.repoTree.columnCount(), "") 45 self.repoTree.headerItem().setText(self.repoTree.columnCount(), "")
46 self.repoTree.header().setSortIndicator(0, Qt.AscendingOrder) 46 self.repoTree.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
47 47
48 self.vcs = vcs 48 self.vcs = vcs
49 self.mode = mode 49 self.mode = mode
50 50
51 self.__process = E5OverrideCursorProcess() 51 self.__process = E5OverrideCursorProcess()
52 self.__process.finished.connect(self.__procFinished) 52 self.__process.finished.connect(self.__procFinished)
53 self.__process.readyReadStandardOutput.connect(self.__readStdout) 53 self.__process.readyReadStandardOutput.connect(self.__readStdout)
54 self.__process.readyReadStandardError.connect(self.__readStderr) 54 self.__process.readyReadStandardError.connect(self.__readStderr)
55 55
56 if self.mode == "select": 56 if self.mode == "select":
57 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 57 self.buttonBox.button(
58 self.buttonBox.button(QDialogButtonBox.Close).hide() 58 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
59 else: 59 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).hide()
60 self.buttonBox.button(QDialogButtonBox.Ok).hide() 60 else:
61 self.buttonBox.button(QDialogButtonBox.Cancel).hide() 61 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).hide()
62 self.buttonBox.button(
63 QDialogButtonBox.StandardButton.Cancel).hide()
62 64
63 self.__dirIcon = UI.PixmapCache.getIcon("dirClosed") 65 self.__dirIcon = UI.PixmapCache.getIcon("dirClosed")
64 self.__fileIcon = UI.PixmapCache.getIcon("fileMisc") 66 self.__fileIcon = UI.PixmapCache.getIcon("fileMisc")
65 67
66 self.__urlRole = Qt.UserRole 68 self.__urlRole = Qt.ItemDataRole.UserRole
67 self.__ignoreExpand = False 69 self.__ignoreExpand = False
68 self.intercept = False 70 self.intercept = False
69 71
70 self.__rx_dir = re.compile( 72 self.__rx_dir = re.compile(
71 r"""\s*([0-9]+)\s+(\w+)\s+""" 73 r"""\s*([0-9]+)\s+(\w+)\s+"""
80 82
81 @param e close event (QCloseEvent) 83 @param e close event (QCloseEvent)
82 """ 84 """
83 if ( 85 if (
84 self.__process is not None and 86 self.__process is not None and
85 self.__process.state() != QProcess.NotRunning 87 self.__process.state() != QProcess.ProcessState.NotRunning
86 ): 88 ):
87 self.__process.terminate() 89 self.__process.terminate()
88 QTimer.singleShot(2000, self.__process.kill) 90 QTimer.singleShot(2000, self.__process.kill)
89 self.__process.waitForFinished(3000) 91 self.__process.waitForFinished(3000)
90 92
100 102
101 def __resizeColumns(self): 103 def __resizeColumns(self):
102 """ 104 """
103 Private method to resize the tree columns. 105 Private method to resize the tree columns.
104 """ 106 """
105 self.repoTree.header().resizeSections(QHeaderView.ResizeToContents) 107 self.repoTree.header().resizeSections(
108 QHeaderView.ResizeMode.ResizeToContents)
106 self.repoTree.header().setStretchLastSection(True) 109 self.repoTree.header().setStretchLastSection(True)
107 110
108 def __generateItem(self, repopath, revision, author, size, date, 111 def __generateItem(self, repopath, revision, author, size, date,
109 nodekind, url): 112 nodekind, url):
110 """ 113 """
129 sz = "" 132 sz = ""
130 else: 133 else:
131 sz = int(size) 134 sz = int(size)
132 135
133 itm = QTreeWidgetItem(self.parentItem) 136 itm = QTreeWidgetItem(self.parentItem)
134 itm.setData(0, Qt.DisplayRole, path) 137 itm.setData(0, Qt.ItemDataRole.DisplayRole, path)
135 itm.setData(1, Qt.DisplayRole, rev) 138 itm.setData(1, Qt.ItemDataRole.DisplayRole, rev)
136 itm.setData(2, Qt.DisplayRole, author) 139 itm.setData(2, Qt.ItemDataRole.DisplayRole, author)
137 itm.setData(3, Qt.DisplayRole, sz) 140 itm.setData(3, Qt.ItemDataRole.DisplayRole, sz)
138 itm.setData(4, Qt.DisplayRole, date) 141 itm.setData(4, Qt.ItemDataRole.DisplayRole, date)
139 142
140 if nodekind == "dir": 143 if nodekind == "dir":
141 itm.setIcon(0, self.__dirIcon) 144 itm.setIcon(0, self.__dirIcon)
142 itm.setChildIndicatorPolicy(QTreeWidgetItem.ShowIndicator) 145 itm.setChildIndicatorPolicy(
146 QTreeWidgetItem.ChildIndicatorPolicy.ShowIndicator)
143 elif nodekind == "file": 147 elif nodekind == "file":
144 itm.setIcon(0, self.__fileIcon) 148 itm.setIcon(0, self.__fileIcon)
145 149
146 itm.setData(0, self.__urlRole, url) 150 itm.setData(0, self.__urlRole, url)
147 151
148 itm.setTextAlignment(0, Qt.AlignLeft) 152 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignLeft)
149 itm.setTextAlignment(1, Qt.AlignRight) 153 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight)
150 itm.setTextAlignment(2, Qt.AlignLeft) 154 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignLeft)
151 itm.setTextAlignment(3, Qt.AlignRight) 155 itm.setTextAlignment(3, Qt.AlignmentFlag.AlignRight)
152 itm.setTextAlignment(4, Qt.AlignLeft) 156 itm.setTextAlignment(4, Qt.AlignmentFlag.AlignLeft)
153 157
154 return itm 158 return itm
155 159
156 def __repoRoot(self, url): 160 def __repoRoot(self, url):
157 """ 161 """
294 298
295 url = self.__normalizeUrl(url) 299 url = self.__normalizeUrl(url)
296 if self.urlCombo.findText(url) == -1: 300 if self.urlCombo.findText(url) == -1:
297 self.urlCombo.addItem(url) 301 self.urlCombo.addItem(url)
298 302
299 @pyqtSlot(str) 303 @pyqtSlot(int)
300 def on_urlCombo_currentIndexChanged(self, text): 304 def on_urlCombo_currentIndexChanged(self, index):
301 """ 305 """
302 Private slot called, when a new repository URL is entered or selected. 306 Private slot called, when a new repository URL is entered or selected.
303 307
304 @param text the text of the current item (string) 308 @param index index of the current item
305 """ 309 @type int
310 """
311 text = self.urlCombo.itemText(index)
306 url = self.__normalizeUrl(text) 312 url = self.__normalizeUrl(text)
307 if url != self.url: 313 if url != self.url:
308 self.url = url 314 self.url = url
309 self.repoTree.clear() 315 self.repoTree.clear()
310 self.__listRepo(url) 316 self.__listRepo(url)
334 def on_repoTree_itemSelectionChanged(self): 340 def on_repoTree_itemSelectionChanged(self):
335 """ 341 """
336 Private slot called when the selection changes. 342 Private slot called when the selection changes.
337 """ 343 """
338 if self.mode == "select": 344 if self.mode == "select":
339 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(True) 345 self.buttonBox.button(
346 QDialogButtonBox.StandardButton.Ok).setEnabled(True)
340 347
341 def accept(self): 348 def accept(self):
342 """ 349 """
343 Public slot called when the dialog is accepted. 350 Public slot called when the dialog is accepted.
344 """ 351 """
364 Private slot called when the process finished or the user pressed the 371 Private slot called when the process finished or the user pressed the
365 button. 372 button.
366 """ 373 """
367 if ( 374 if (
368 self.__process is not None and 375 self.__process is not None and
369 self.__process.state() != QProcess.NotRunning 376 self.__process.state() != QProcess.ProcessState.NotRunning
370 ): 377 ):
371 self.__process.terminate() 378 self.__process.terminate()
372 QTimer.singleShot(2000, self.__process.kill) 379 QTimer.singleShot(2000, self.__process.kill)
373 self.__process.waitForFinished(3000) 380 self.__process.waitForFinished(3000)
374 381
393 400
394 It reads the output of the process, formats it and inserts it into 401 It reads the output of the process, formats it and inserts it into
395 the contents pane. 402 the contents pane.
396 """ 403 """
397 if self.__process is not None: 404 if self.__process is not None:
398 self.__process.setReadChannel(QProcess.StandardOutput) 405 self.__process.setReadChannel(
406 QProcess.ProcessChannel.StandardOutput)
399 407
400 while self.__process.canReadLine(): 408 while self.__process.canReadLine():
401 s = str(self.__process.readLine(), 409 s = str(self.__process.readLine(),
402 Preferences.getSystem("IOEncoding"), 410 Preferences.getSystem("IOEncoding"),
403 'replace') 411 'replace')
450 Private slot to handle the password checkbox toggled. 458 Private slot to handle the password checkbox toggled.
451 459
452 @param isOn flag indicating the status of the check box (boolean) 460 @param isOn flag indicating the status of the check box (boolean)
453 """ 461 """
454 if isOn: 462 if isOn:
455 self.input.setEchoMode(QLineEdit.Password) 463 self.input.setEchoMode(QLineEdit.EchoMode.Password)
456 else: 464 else:
457 self.input.setEchoMode(QLineEdit.Normal) 465 self.input.setEchoMode(QLineEdit.EchoMode.Normal)
458 466
459 @pyqtSlot() 467 @pyqtSlot()
460 def on_sendButton_clicked(self): 468 def on_sendButton_clicked(self):
461 """ 469 """
462 Private slot to send the input to the subversion process. 470 Private slot to send the input to the subversion process.

eric ide

mercurial