|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a copy operation. |
|
8 """ |
|
9 |
|
10 import os.path |
|
11 |
|
12 from PyQt4.QtCore import * |
|
13 from PyQt4.QtGui import * |
|
14 |
|
15 from E4Gui.E4Completers import E4FileCompleter, E4DirCompleter |
|
16 |
|
17 from Ui_SvnCopyDialog import Ui_SvnCopyDialog |
|
18 |
|
19 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog): |
|
20 """ |
|
21 Class implementing a dialog to enter the data for a copy operation. |
|
22 """ |
|
23 def __init__(self, source, parent = None, move = False, force = False): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param source name of the source file/directory (string) |
|
28 @param parent parent widget (QWidget) |
|
29 @param move flag indicating a move operation |
|
30 @param force flag indicating a forced operation (boolean) |
|
31 """ |
|
32 QDialog.__init__(self, parent) |
|
33 self.setupUi(self) |
|
34 |
|
35 self.source = source |
|
36 if os.path.isdir(self.source): |
|
37 self.targetCompleter = E4DirCompleter(self.targetEdit) |
|
38 else: |
|
39 self.targetCompleter = E4FileCompleter(self.targetEdit) |
|
40 |
|
41 if move: |
|
42 self.setWindowTitle(self.trUtf8('Subversion Move')) |
|
43 else: |
|
44 self.forceCheckBox.setEnabled(False) |
|
45 self.forceCheckBox.setChecked(force) |
|
46 |
|
47 self.sourceEdit.setText(source) |
|
48 |
|
49 def getData(self): |
|
50 """ |
|
51 Public method to retrieve the copy data. |
|
52 |
|
53 @return the target name (string) and a flag indicating |
|
54 the operation should be enforced (boolean) |
|
55 """ |
|
56 return self.targetEdit.text(), self.forceCheckBox.isChecked() |
|
57 |
|
58 @pyqtSlot() |
|
59 def on_dirButton_clicked(self): |
|
60 """ |
|
61 Private slot to handle the button press for selecting the target via a |
|
62 selection dialog. |
|
63 """ |
|
64 if os.path.isdir(self.source): |
|
65 target = QFileDialog.getExistingDirectory(\ |
|
66 None, |
|
67 self.trUtf8("Select target"), |
|
68 self.targetEdit.text(), |
|
69 QFileDialog.Options(QFileDialog.ShowDirsOnly)) |
|
70 else: |
|
71 target = QFileDialog.getSaveFileName(\ |
|
72 None, |
|
73 self.trUtf8("Select target"), |
|
74 self.targetEdit.text(), |
|
75 "", |
|
76 QFileDialog.Options(QFileDialog.DontConfirmOverwrite)) |
|
77 |
|
78 if target: |
|
79 self.targetEdit.setText(target) |