Plugins/VcsPlugins/vcsMercurial/HgCopyDialog.py

changeset 178
dd9f0bca5e2f
child 564
b3d966393ba9
child 792
a13346916170
equal deleted inserted replaced
177:c822ccc4d138 178:dd9f0bca5e2f
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a copy or rename operation.
8 """
9
10 import os.path
11
12 from PyQt4.QtCore import pyqtSlot
13 from PyQt4.QtGui import QDialog, QFileDialog
14
15 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter
16
17 from .Ui_HgCopyDialog import Ui_HgCopyDialog
18
19 class HgCopyDialog(QDialog, Ui_HgCopyDialog):
20 """
21 Class implementing a dialog to enter the data for a copy or rename 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 = E5DirCompleter(self.targetEdit)
38 else:
39 self.targetCompleter = E5FileCompleter(self.targetEdit)
40
41 if move:
42 self.setWindowTitle(self.trUtf8('Mercurial 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 self,
67 self.trUtf8("Select target"),
68 self.targetEdit.text(),
69 QFileDialog.Options(QFileDialog.ShowDirsOnly))
70 else:
71 target = QFileDialog.getSaveFileName(\
72 self,
73 self.trUtf8("Select target"),
74 self.targetEdit.text(),
75 "",
76 QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
77
78 if target:
79 self.targetEdit.setText(target)

eric ide

mercurial