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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
12 12
13 import pysvn 13 import pysvn
14 14
15 from PyQt6.QtCore import pyqtSlot, Qt 15 from PyQt6.QtCore import pyqtSlot, Qt
16 from PyQt6.QtWidgets import ( 16 from PyQt6.QtWidgets import (
17 QWidget, QHeaderView, QApplication, QDialogButtonBox, QTreeWidgetItem 17 QWidget,
18 QHeaderView,
19 QApplication,
20 QDialogButtonBox,
21 QTreeWidgetItem,
18 ) 22 )
19 23
20 from EricUtilities.EricMutexLocker import EricMutexLocker 24 from EricUtilities.EricMutexLocker import EricMutexLocker
21 25
22 from .SvnDialogMixin import SvnDialogMixin 26 from .SvnDialogMixin import SvnDialogMixin
26 class SvnPropListDialog(QWidget, SvnDialogMixin, Ui_SvnPropListDialog): 30 class SvnPropListDialog(QWidget, SvnDialogMixin, Ui_SvnPropListDialog):
27 """ 31 """
28 Class implementing a dialog to show the output of the svn proplist command 32 Class implementing a dialog to show the output of the svn proplist command
29 process. 33 process.
30 """ 34 """
35
31 def __init__(self, vcs, parent=None): 36 def __init__(self, vcs, parent=None):
32 """ 37 """
33 Constructor 38 Constructor
34 39
35 @param vcs reference to the vcs object 40 @param vcs reference to the vcs object
36 @param parent parent widget (QWidget) 41 @param parent parent widget (QWidget)
37 """ 42 """
38 super().__init__(parent) 43 super().__init__(parent)
39 self.setupUi(self) 44 self.setupUi(self)
40 SvnDialogMixin.__init__(self) 45 SvnDialogMixin.__init__(self)
41 46
42 self.refreshButton = self.buttonBox.addButton( 47 self.refreshButton = self.buttonBox.addButton(
43 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole) 48 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole
49 )
44 self.refreshButton.setToolTip( 50 self.refreshButton.setToolTip(
45 self.tr("Press to refresh the properties display")) 51 self.tr("Press to refresh the properties display")
52 )
46 self.refreshButton.setEnabled(False) 53 self.refreshButton.setEnabled(False)
47 self.buttonBox.button( 54 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
48 QDialogButtonBox.StandardButton.Close).setEnabled(False) 55 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
49 self.buttonBox.button( 56
50 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
51
52 self.vcs = vcs 57 self.vcs = vcs
53 58
54 self.propsList.headerItem().setText(self.propsList.columnCount(), "") 59 self.propsList.headerItem().setText(self.propsList.columnCount(), "")
55 self.propsList.header().setSortIndicator( 60 self.propsList.header().setSortIndicator(0, Qt.SortOrder.AscendingOrder)
56 0, Qt.SortOrder.AscendingOrder) 61
57
58 self.client = self.vcs.getClient() 62 self.client = self.vcs.getClient()
59 self.client.callback_cancel = self._clientCancelCallback 63 self.client.callback_cancel = self._clientCancelCallback
60 self.client.callback_get_login = self._clientLoginCallback 64 self.client.callback_get_login = self._clientLoginCallback
61 self.client.callback_ssl_server_trust_prompt = ( 65 self.client.callback_ssl_server_trust_prompt = (
62 self._clientSslServerTrustPromptCallback 66 self._clientSslServerTrustPromptCallback
63 ) 67 )
64 68
65 def __resort(self): 69 def __resort(self):
66 """ 70 """
67 Private method to resort the tree. 71 Private method to resort the tree.
68 """ 72 """
69 self.propsList.sortItems( 73 self.propsList.sortItems(
70 self.propsList.sortColumn(), 74 self.propsList.sortColumn(), self.propsList.header().sortIndicatorOrder()
71 self.propsList.header().sortIndicatorOrder()) 75 )
72 76
73 def __resizeColumns(self): 77 def __resizeColumns(self):
74 """ 78 """
75 Private method to resize the list columns. 79 Private method to resize the list columns.
76 """ 80 """
77 self.propsList.header().resizeSections( 81 self.propsList.header().resizeSections(QHeaderView.ResizeMode.ResizeToContents)
78 QHeaderView.ResizeMode.ResizeToContents)
79 self.propsList.header().setStretchLastSection(True) 82 self.propsList.header().setStretchLastSection(True)
80 83
81 def __generateItem(self, path, propName, propValue): 84 def __generateItem(self, path, propName, propValue):
82 """ 85 """
83 Private method to generate a properties item in the properties list. 86 Private method to generate a properties item in the properties list.
84 87
85 @param path file/directory name the property applies to (string) 88 @param path file/directory name the property applies to (string)
86 @param propName name of the property (string) 89 @param propName name of the property (string)
87 @param propValue value of the property (string) 90 @param propValue value of the property (string)
88 """ 91 """
89 QTreeWidgetItem(self.propsList, [path, propName, propValue]) 92 QTreeWidgetItem(self.propsList, [path, propName, propValue])
90 93
91 def start(self, fn, recursive=False): 94 def start(self, fn, recursive=False):
92 """ 95 """
93 Public slot to start the svn status command. 96 Public slot to start the svn status command.
94 97
95 @param fn filename(s) (string or list of strings) 98 @param fn filename(s) (string or list of strings)
96 @param recursive flag indicating a recursive list is requested 99 @param recursive flag indicating a recursive list is requested
97 """ 100 """
98 self.errorGroup.hide() 101 self.errorGroup.hide()
99 102
100 self.propsList.clear() 103 self.propsList.clear()
101 104
102 self.__args = fn 105 self.__args = fn
103 self.__recursive = recursive 106 self.__recursive = recursive
104 107
105 self.buttonBox.button( 108 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(False)
106 QDialogButtonBox.StandardButton.Close).setEnabled(False) 109 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
107 self.buttonBox.button( 110 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setDefault(True)
108 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
109 self.buttonBox.button(
110 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
111 self.refreshButton.setEnabled(False) 111 self.refreshButton.setEnabled(False)
112 112
113 QApplication.processEvents() 113 QApplication.processEvents()
114 self.propsFound = False 114 self.propsFound = False
115 if isinstance(fn, list): 115 if isinstance(fn, list):
116 dname, fnames = self.vcs.splitPathList(fn) 116 dname, fnames = self.vcs.splitPathList(fn)
117 else: 117 else:
118 dname, fname = self.vcs.splitPath(fn) 118 dname, fname = self.vcs.splitPath(fn)
119 fnames = [fname] 119 fnames = [fname]
120 120
121 cwd = os.getcwd() 121 cwd = os.getcwd()
122 os.chdir(dname) 122 os.chdir(dname)
123 with EricMutexLocker(self.vcs.vcsExecutionMutex): 123 with EricMutexLocker(self.vcs.vcsExecutionMutex):
124 try: 124 try:
125 for name in fnames: 125 for name in fnames:
126 proplist = self.client.proplist(name, recurse=recursive) 126 proplist = self.client.proplist(name, recurse=recursive)
127 for counter, (path, prop) in enumerate(proplist): 127 for counter, (path, prop) in enumerate(proplist):
128 for propName, propVal in list(prop.items()): 128 for propName, propVal in list(prop.items()):
129 self.__generateItem(path, propName, propVal) 129 self.__generateItem(path, propName, propVal)
130 self.propsFound = True 130 self.propsFound = True
131 if ( 131 if counter % 30 == 0 and self._clientCancelCallback():
132 counter % 30 == 0 and
133 self._clientCancelCallback()
134 ):
135 # check for cancel every 30 items 132 # check for cancel every 30 items
136 break 133 break
137 if self._clientCancelCallback(): 134 if self._clientCancelCallback():
138 break 135 break
139 except pysvn.ClientError as e: 136 except pysvn.ClientError as e:
140 self.__showError(e.args[0]) 137 self.__showError(e.args[0])
141 138
142 self.__finish() 139 self.__finish()
143 os.chdir(cwd) 140 os.chdir(cwd)
144 141
145 def __finish(self): 142 def __finish(self):
146 """ 143 """
147 Private slot called when the process finished or the user pressed the 144 Private slot called when the process finished or the user pressed the
148 button. 145 button.
149 """ 146 """
150 if not self.propsFound: 147 if not self.propsFound:
151 self.__generateItem("", self.tr("None"), "") 148 self.__generateItem("", self.tr("None"), "")
152 149
153 self.__resort() 150 self.__resort()
154 self.__resizeColumns() 151 self.__resizeColumns()
155 152
156 self.buttonBox.button( 153 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True)
157 QDialogButtonBox.StandardButton.Close).setEnabled(True) 154 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
158 self.buttonBox.button( 155 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
159 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) 156
160 self.buttonBox.button(
161 QDialogButtonBox.StandardButton.Close).setDefault(True)
162
163 self.refreshButton.setEnabled(True) 157 self.refreshButton.setEnabled(True)
164 158
165 self._cancel() 159 self._cancel()
166 160
167 def on_buttonBox_clicked(self, button): 161 def on_buttonBox_clicked(self, button):
168 """ 162 """
169 Private slot called by a button of the button box clicked. 163 Private slot called by a button of the button box clicked.
170 164
171 @param button button that was clicked (QAbstractButton) 165 @param button button that was clicked (QAbstractButton)
172 """ 166 """
173 if button == self.buttonBox.button( 167 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Close):
174 QDialogButtonBox.StandardButton.Close
175 ):
176 self.close() 168 self.close()
177 elif button == self.buttonBox.button( 169 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
178 QDialogButtonBox.StandardButton.Cancel
179 ):
180 self.__finish() 170 self.__finish()
181 elif button == self.refreshButton: 171 elif button == self.refreshButton:
182 self.on_refreshButton_clicked() 172 self.on_refreshButton_clicked()
183 173
184 @pyqtSlot() 174 @pyqtSlot()
185 def on_refreshButton_clicked(self): 175 def on_refreshButton_clicked(self):
186 """ 176 """
187 Private slot to refresh the status display. 177 Private slot to refresh the status display.
188 """ 178 """
189 self.start(self.__args, recursive=self.__recursive) 179 self.start(self.__args, recursive=self.__recursive)
190 180
191 def __showError(self, msg): 181 def __showError(self, msg):
192 """ 182 """
193 Private slot to show an error message. 183 Private slot to show an error message.
194 184
195 @param msg error message to show (string) 185 @param msg error message to show (string)
196 """ 186 """
197 self.errorGroup.show() 187 self.errorGroup.show()
198 self.errors.insertPlainText(msg) 188 self.errors.insertPlainText(msg)
199 self.errors.ensureCursorVisible() 189 self.errors.ensureCursorVisible()

eric ide

mercurial