src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnChangeListsDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
25 25
26 class SvnChangeListsDialog(QDialog, SvnDialogMixin, Ui_SvnChangeListsDialog): 26 class SvnChangeListsDialog(QDialog, SvnDialogMixin, Ui_SvnChangeListsDialog):
27 """ 27 """
28 Class implementing a dialog to browse the change lists. 28 Class implementing a dialog to browse the change lists.
29 """ 29 """
30
30 def __init__(self, vcs, parent=None): 31 def __init__(self, vcs, parent=None):
31 """ 32 """
32 Constructor 33 Constructor
33 34
34 @param vcs reference to the vcs object 35 @param vcs reference to the vcs object
35 @param parent parent widget (QWidget) 36 @param parent parent widget (QWidget)
36 """ 37 """
37 super().__init__(parent) 38 super().__init__(parent)
38 self.setupUi(self) 39 self.setupUi(self)
39 SvnDialogMixin.__init__(self) 40 SvnDialogMixin.__init__(self)
40 self.setWindowFlags(Qt.WindowType.Window) 41 self.setWindowFlags(Qt.WindowType.Window)
41 42
42 self.buttonBox.button( 43 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
43 QDialogButtonBox.StandardButton.Close).setEnabled(False) 44 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
44 self.buttonBox.button( 45
45 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
46
47 self.vcs = vcs 46 self.vcs = vcs
48 47
49 self.client = self.vcs.getClient() 48 self.client = self.vcs.getClient()
50 self.client.callback_cancel = self._clientCancelCallback 49 self.client.callback_cancel = self._clientCancelCallback
51 self.client.callback_get_login = self._clientLoginCallback 50 self.client.callback_get_login = self._clientLoginCallback
52 self.client.callback_ssl_server_trust_prompt = ( 51 self.client.callback_ssl_server_trust_prompt = (
53 self._clientSslServerTrustPromptCallback 52 self._clientSslServerTrustPromptCallback
54 ) 53 )
55 54
56 @pyqtSlot(QListWidgetItem, QListWidgetItem) 55 @pyqtSlot(QListWidgetItem, QListWidgetItem)
57 def on_changeLists_currentItemChanged(self, current, previous): 56 def on_changeLists_currentItemChanged(self, current, previous):
58 """ 57 """
59 Private slot to handle the selection of a new item. 58 Private slot to handle the selection of a new item.
60 59
61 @param current current item (QListWidgetItem) 60 @param current current item (QListWidgetItem)
62 @param previous previous current item (QListWidgetItem) 61 @param previous previous current item (QListWidgetItem)
63 """ 62 """
64 self.filesList.clear() 63 self.filesList.clear()
65 if current is not None: 64 if current is not None:
66 changelist = current.text() 65 changelist = current.text()
67 if changelist in self.changeListsDict: 66 if changelist in self.changeListsDict:
68 self.filesList.addItems( 67 self.filesList.addItems(sorted(self.changeListsDict[changelist]))
69 sorted(self.changeListsDict[changelist])) 68
70
71 def start(self, path): 69 def start(self, path):
72 """ 70 """
73 Public slot to populate the data. 71 Public slot to populate the data.
74 72
75 @param path directory name to show change lists for (string) 73 @param path directory name to show change lists for (string)
76 """ 74 """
77 self.changeListsDict = {} 75 self.changeListsDict = {}
78 self.cancelled = False 76 self.cancelled = False
79 77
80 self.filesLabel.setText( 78 self.filesLabel.setText(self.tr("Files (relative to {0}):").format(path))
81 self.tr("Files (relative to {0}):").format(path)) 79
82
83 with EricOverrideCursor(): 80 with EricOverrideCursor():
84 try: 81 try:
85 with EricMutexLocker(self.vcs.vcsExecutionMutex): 82 with EricMutexLocker(self.vcs.vcsExecutionMutex):
86 entries = self.client.get_changelist( 83 entries = self.client.get_changelist(
87 path, depth=pysvn.depth.infinity) 84 path, depth=pysvn.depth.infinity
85 )
88 for entry in entries: 86 for entry in entries:
89 file = entry[0] 87 file = entry[0]
90 changelist = entry[1] 88 changelist = entry[1]
91 if changelist not in self.changeListsDict: 89 if changelist not in self.changeListsDict:
92 self.changeListsDict[changelist] = [] 90 self.changeListsDict[changelist] = []
94 if filename not in self.changeListsDict[changelist]: 92 if filename not in self.changeListsDict[changelist]:
95 self.changeListsDict[changelist].append(filename) 93 self.changeListsDict[changelist].append(filename)
96 except pysvn.ClientError as e: 94 except pysvn.ClientError as e:
97 self.__showError(e.args[0]) 95 self.__showError(e.args[0])
98 self.__finish() 96 self.__finish()
99 97
100 def __finish(self): 98 def __finish(self):
101 """ 99 """
102 Private slot called when the user pressed the button. 100 Private slot called when the user pressed the button.
103 """ 101 """
104 self.changeLists.addItems(sorted(self.changeListsDict.keys())) 102 self.changeLists.addItems(sorted(self.changeListsDict.keys()))
105 103
106 self.buttonBox.button( 104 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
107 QDialogButtonBox.StandardButton.Close).setEnabled(True) 105 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
108 self.buttonBox.button( 106 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
109 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) 107
110 self.buttonBox.button(
111 QDialogButtonBox.StandardButton.Close).setDefault(True)
112
113 if len(self.changeListsDict) == 0: 108 if len(self.changeListsDict) == 0:
114 self.changeLists.addItem(self.tr("No changelists found")) 109 self.changeLists.addItem(self.tr("No changelists found"))
115 self.buttonBox.button( 110 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus(
116 QDialogButtonBox.StandardButton.Close).setFocus( 111 Qt.FocusReason.OtherFocusReason
117 Qt.FocusReason.OtherFocusReason) 112 )
118 else: 113 else:
119 self.changeLists.setCurrentRow(0) 114 self.changeLists.setCurrentRow(0)
120 self.changeLists.setFocus(Qt.FocusReason.OtherFocusReason) 115 self.changeLists.setFocus(Qt.FocusReason.OtherFocusReason)
121 116
122 def on_buttonBox_clicked(self, button): 117 def on_buttonBox_clicked(self, button):
123 """ 118 """
124 Private slot called by a button of the button box clicked. 119 Private slot called by a button of the button box clicked.
125 120
126 @param button button that was clicked (QAbstractButton) 121 @param button button that was clicked (QAbstractButton)
127 """ 122 """
128 if button == self.buttonBox.button( 123 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
129 QDialogButtonBox.StandardButton.Close
130 ):
131 self.close() 124 self.close()
132 elif button == self.buttonBox.button( 125 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
133 QDialogButtonBox.StandardButton.Cancel
134 ):
135 self.cancelled = True 126 self.cancelled = True
136 self.__finish() 127 self.__finish()

eric ide

mercurial