RefactoringRope/MoveDialog.py

branch
eric7
changeset 365
f740b50380df
parent 354
a967ff16629a
child 374
958f34e97952
equal deleted inserted replaced
364:a92b3272f4c1 365:f740b50380df
7 Module implementing the Move Method or Module dialog. 7 Module implementing the Move Method or Module dialog.
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt5.QtCore import pyqtSlot 12 from PyQt6.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialogButtonBox, QAbstractButton 13 from PyQt6.QtWidgets import QDialogButtonBox, QAbstractButton
14 14
15 from E5Gui import E5FileDialog, E5MessageBox 15 from EricWidgets import EricFileDialog, EricMessageBox
16 from E5Gui.E5Application import e5App 16 from EricWidgets.EricApplication import ericApp
17 from E5Gui.E5Completers import E5FileCompleter 17 from EricWidgets.EricCompleters import EricFileCompleter
18 18
19 from .Ui_MoveDialog import Ui_MoveDialog 19 from .Ui_MoveDialog import Ui_MoveDialog
20 from .RefactoringDialogBase import RefactoringDialogBase 20 from .RefactoringDialogBase import RefactoringDialogBase
21 21
22 import Utilities 22 import Utilities
44 RefactoringDialogBase.__init__(self, refactoring, title, parent) 44 RefactoringDialogBase.__init__(self, refactoring, title, parent)
45 self.setupUi(self) 45 self.setupUi(self)
46 46
47 self._changeGroupName = "Move" 47 self._changeGroupName = "Move"
48 48
49 self.__destinationCompleter = E5FileCompleter(self.destinationEdit) 49 self.__destinationCompleter = EricFileCompleter(self.destinationEdit)
50 50
51 self.__filename = filename 51 self.__filename = filename
52 self.__offset = offset 52 self.__offset = offset
53 53
54 self.__project = e5App().getObject("Project") 54 self.__project = ericApp().getObject("Project")
55 55
56 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 56 self.__okButton = self.buttonBox.button(
57 QDialogButtonBox.StandardButton.Ok)
57 self.__okButton.setEnabled(False) 58 self.__okButton.setEnabled(False)
58 self.__previewButton = self.buttonBox.addButton( 59 self.__previewButton = self.buttonBox.addButton(
59 self.tr("Preview"), QDialogButtonBox.ActionRole) 60 self.tr("Preview"), QDialogButtonBox.ButtonRole.ActionRole)
60 self.__previewButton.setDefault(True) 61 self.__previewButton.setDefault(True)
61 62
62 self.moveStackWidget.setCurrentIndex(0) 63 self.moveStackWidget.setCurrentIndex(0)
63 64
64 self.__moveType = "" 65 self.__moveType = ""
173 if not dest: 174 if not dest:
174 dest = self.__project.getProjectPath() 175 dest = self.__project.getProjectPath()
175 elif not os.path.isabs(dest): 176 elif not os.path.isabs(dest):
176 dest = os.path.join(self.__project.getProjectPath(), dest) 177 dest = os.path.join(self.__project.getProjectPath(), dest)
177 destination = ( 178 destination = (
178 E5FileDialog.getOpenFileName( 179 EricFileDialog.getOpenFileName(
179 self, 180 self,
180 self.windowTitle(), 181 self.windowTitle(),
181 dest, 182 dest,
182 self.tr("Python Files (*.py *.py3);;All Files (*)")) 183 self.tr("Python Files (*.py *.py3);;All Files (*)"))
183 if self.__moveType == "move_global_method" else 184 if self.__moveType == "move_global_method" else
184 # move_module 185 # move_module
185 E5FileDialog.getExistingDirectory( 186 EricFileDialog.getExistingDirectory(
186 self, 187 self,
187 self.windowTitle(), 188 self.windowTitle(),
188 dest) 189 dest)
189 ) 190 )
190 191
196 """inside the project.""") 197 """inside the project.""")
197 else: 198 else:
198 # move_module 199 # move_module
199 errorMessage = self.tr("""The selected directory must""" 200 errorMessage = self.tr("""The selected directory must"""
200 """ be inside the project.""") 201 """ be inside the project.""")
201 E5MessageBox.critical( 202 EricMessageBox.critical(
202 self, 203 self,
203 self.windowTitle(), 204 self.windowTitle(),
204 errorMessage) 205 errorMessage)
205 return 206 return
206 207
207 if self.__moveType == "move_global_method": 208 if self.__moveType == "move_global_method":
208 if not os.path.exists(destination): 209 if not os.path.exists(destination):
209 E5MessageBox.critical( 210 EricMessageBox.critical(
210 self, 211 self,
211 self.windowTitle(), 212 self.windowTitle(),
212 self.tr("""The selected module <b>{0}</b> does""" 213 self.tr("""The selected module <b>{0}</b> does"""
213 """ not exist.""").format(destination)) 214 """ not exist.""").format(destination))
214 return 215 return
215 else: 216 else:
216 # move_module 217 # move_module
217 if not os.path.exists( 218 if not os.path.exists(
218 os.path.join(destination, "__init__.py")): 219 os.path.join(destination, "__init__.py")):
219 E5MessageBox.critical( 220 EricMessageBox.critical(
220 self, 221 self,
221 self.windowTitle(), 222 self.windowTitle(),
222 self.tr("""The selected directory <b>{0}</b> is""" 223 self.tr("""The selected directory <b>{0}</b> is"""
223 """ not a package.""").format(destination)) 224 """ not a package.""").format(destination))
224 return 225 return
236 destination = os.path.join( 237 destination = os.path.join(
237 self.__project.getProjectPath(), 238 self.__project.getProjectPath(),
238 self.destinationEdit.text()) 239 self.destinationEdit.text())
239 if self.__moveType == "move_global_method": 240 if self.__moveType == "move_global_method":
240 if not os.path.exists(destination): 241 if not os.path.exists(destination):
241 E5MessageBox.critical( 242 EricMessageBox.critical(
242 self, 243 self,
243 self.windowTitle(), 244 self.windowTitle(),
244 self.tr("""The selected module <b>{0}</b> does""" 245 self.tr("""The selected module <b>{0}</b> does"""
245 """ not exist.""").format(destination)) 246 """ not exist.""").format(destination))
246 return False 247 return False
247 else: 248 else:
248 # move_module 249 # move_module
249 if not os.path.exists(os.path.join(destination, "__init__.py")): 250 if not os.path.exists(os.path.join(destination, "__init__.py")):
250 E5MessageBox.critical( 251 EricMessageBox.critical(
251 self, 252 self,
252 self.windowTitle(), 253 self.windowTitle(),
253 self.tr("""The selected directory <b>{0}</b> is""" 254 self.tr("""The selected directory <b>{0}</b> is"""
254 """ not a package.""").format(destination)) 255 """ not a package.""").format(destination))
255 return False 256 return False

eric ide

mercurial