Plugins/VcsPlugins/vcsSubversion/SvnCopyDialog.py

changeset 4597
46be8d9c4dd8
parent 4021
195a471c327b
child 4631
5c1a96925da4
equal deleted inserted replaced
4595:f0e48b3e31d4 4597:46be8d9c4dd8
12 import os.path 12 import os.path
13 13
14 from PyQt5.QtCore import pyqtSlot 14 from PyQt5.QtCore import pyqtSlot
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox 15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
16 16
17 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter 17 from E5Gui.E5PathPicker import E5PathPickerModes
18 from E5Gui import E5FileDialog
19 18
20 from .Ui_SvnCopyDialog import Ui_SvnCopyDialog 19 from .Ui_SvnCopyDialog import Ui_SvnCopyDialog
21
22 import Utilities
23 import UI.PixmapCache
24 20
25 21
26 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog): 22 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog):
27 """ 23 """
28 Class implementing a dialog to enter the data for a copy or rename 24 Class implementing a dialog to enter the data for a copy or rename
38 @param force flag indicating a forced operation (boolean) 34 @param force flag indicating a forced operation (boolean)
39 """ 35 """
40 super(SvnCopyDialog, self).__init__(parent) 36 super(SvnCopyDialog, self).__init__(parent)
41 self.setupUi(self) 37 self.setupUi(self)
42 38
43 self.dirButton.setIcon(UI.PixmapCache.getIcon("open.png"))
44
45 self.source = source 39 self.source = source
46 if os.path.isdir(self.source): 40 if os.path.isdir(self.source):
47 self.targetCompleter = E5DirCompleter(self.targetEdit) 41 self.targetPicker.setMode(E5PathPickerModes.DirectoryMode)
48 else: 42 else:
49 self.targetCompleter = E5FileCompleter(self.targetEdit) 43 self.targetPicker.setMode(E5PathPickerModes.SaveFileMode)
50 44
51 if move: 45 if move:
52 self.setWindowTitle(self.tr('Subversion Move')) 46 self.setWindowTitle(self.tr('Subversion Move'))
53 else: 47 else:
54 self.forceCheckBox.setEnabled(False) 48 self.forceCheckBox.setEnabled(False)
66 Public method to retrieve the copy data. 60 Public method to retrieve the copy data.
67 61
68 @return the target name (string) and a flag indicating 62 @return the target name (string) and a flag indicating
69 the operation should be enforced (boolean) 63 the operation should be enforced (boolean)
70 """ 64 """
71 target = self.targetEdit.text() 65 target = self.targetPicker.text()
72 if not os.path.isabs(target): 66 if not os.path.isabs(target):
73 sourceDir = os.path.dirname(self.sourceEdit.text()) 67 sourceDir = os.path.dirname(self.sourceEdit.text())
74 target = os.path.join(sourceDir, target) 68 target = os.path.join(sourceDir, target)
75 return (Utilities.toNativeSeparators(target), 69 return (target, self.forceCheckBox.isChecked())
76 self.forceCheckBox.isChecked())
77
78 @pyqtSlot()
79 def on_dirButton_clicked(self):
80 """
81 Private slot to handle the button press for selecting the target via a
82 selection dialog.
83 """
84 if os.path.isdir(self.source):
85 target = E5FileDialog.getExistingDirectory(
86 None,
87 self.tr("Select target"),
88 self.targetEdit.text(),
89 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
90 else:
91 target = E5FileDialog.getSaveFileName(
92 None,
93 self.tr("Select target"),
94 self.targetEdit.text(),
95 "",
96 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
97
98 if target:
99 self.targetEdit.setText(Utilities.toNativeSeparators(target))
100 70
101 @pyqtSlot(str) 71 @pyqtSlot(str)
102 def on_targetEdit_textChanged(self, txt): 72 def on_targetPicker_textChanged(self, txt):
103 """ 73 """
104 Private slot to handle changes of the target. 74 Private slot to handle changes of the target.
105 75
106 @param txt contents of the target edit (string) 76 @param txt contents of the target edit (string)
107 """ 77 """

eric ide

mercurial