8 """ |
8 """ |
9 |
9 |
10 import os.path |
10 import os.path |
11 |
11 |
12 from PyQt4.QtCore import pyqtSlot |
12 from PyQt4.QtCore import pyqtSlot |
13 from PyQt4.QtGui import QDialog |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox |
14 |
14 |
15 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter |
15 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter |
16 from E5Gui import E5FileDialog |
16 from E5Gui import E5FileDialog |
17 |
17 |
18 from .Ui_SvnCopyDialog import Ui_SvnCopyDialog |
18 from .Ui_SvnCopyDialog import Ui_SvnCopyDialog |
19 |
19 |
20 |
20 |
21 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog): |
21 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog): |
22 """ |
22 """ |
23 Class implementing a dialog to enter the data for a copy operation. |
23 Class implementing a dialog to enter the data for a copy or rename operation. |
24 """ |
24 """ |
25 def __init__(self, source, parent=None, move=False, force=False): |
25 def __init__(self, source, parent=None, move=False, force=False): |
26 """ |
26 """ |
27 Constructor |
27 Constructor |
28 |
28 |
29 @param source name of the source file/directory (string) |
29 @param source name of the source file/directory (string) |
30 @param parent parent widget (QWidget) |
30 @param parent parent widget (QWidget) |
31 @param move flag indicating a move operation |
31 @param move flag indicating a move operation (boolean) |
32 @param force flag indicating a forced operation (boolean) |
32 @param force flag indicating a forced operation (boolean) |
33 """ |
33 """ |
34 super().__init__(parent) |
34 super().__init__(parent) |
35 self.setupUi(self) |
35 self.setupUi(self) |
36 |
36 |
46 self.forceCheckBox.setEnabled(False) |
46 self.forceCheckBox.setEnabled(False) |
47 self.forceCheckBox.setChecked(force) |
47 self.forceCheckBox.setChecked(force) |
48 |
48 |
49 self.sourceEdit.setText(source) |
49 self.sourceEdit.setText(source) |
50 |
50 |
|
51 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
52 |
51 def getData(self): |
53 def getData(self): |
52 """ |
54 """ |
53 Public method to retrieve the copy data. |
55 Public method to retrieve the copy data. |
54 |
56 |
55 @return the target name (string) and a flag indicating |
57 @return the target name (string) and a flag indicating |
56 the operation should be enforced (boolean) |
58 the operation should be enforced (boolean) |
57 """ |
59 """ |
58 # TODO: check if target is an absolute path. If not make it relative to source. |
60 target = self.targetEdit.text() |
59 return self.targetEdit.text(), self.forceCheckBox.isChecked() |
61 if not os.path.isabs(target): |
|
62 sourceDir = os.path.dirname(self.sourceEdit.text()) |
|
63 target = os.path.join(sourceDir, target) |
|
64 return target, self.forceCheckBox.isChecked() |
60 |
65 |
61 @pyqtSlot() |
66 @pyqtSlot() |
62 def on_dirButton_clicked(self): |
67 def on_dirButton_clicked(self): |
63 """ |
68 """ |
64 Private slot to handle the button press for selecting the target via a |
69 Private slot to handle the button press for selecting the target via a |
78 "", |
83 "", |
79 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
84 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
80 |
85 |
81 if target: |
86 if target: |
82 self.targetEdit.setText(target) |
87 self.targetEdit.setText(target) |
|
88 |
|
89 @pyqtSlot(str) |
|
90 def on_targetEdit_textChanged(self, txt): |
|
91 """ |
|
92 Private slot to handle changes of the target. |
|
93 |
|
94 @param txt contents of the target edit (string) |
|
95 """ |
|
96 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
97 os.path.isabs(txt) or os.path.dirname(txt) == "") |