eric6/Plugins/VcsPlugins/vcsPySvn/SvnCopyDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2019 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 from __future__ import unicode_literals
11
12 import os.path
13
14 from PyQt5.QtCore import pyqtSlot
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
16
17 from E5Gui.E5PathPicker import E5PathPickerModes
18
19 from .Ui_SvnCopyDialog import Ui_SvnCopyDialog
20
21
22 class SvnCopyDialog(QDialog, Ui_SvnCopyDialog):
23 """
24 Class implementing a dialog to enter the data for a copy or rename
25 operation.
26 """
27 def __init__(self, source, parent=None, move=False, force=False):
28 """
29 Constructor
30
31 @param source name of the source file/directory (string)
32 @param parent parent widget (QWidget)
33 @param move flag indicating a move operation (boolean)
34 @param force flag indicating a forced operation (boolean)
35 """
36 super(SvnCopyDialog, self).__init__(parent)
37 self.setupUi(self)
38
39 self.source = source
40 if os.path.isdir(self.source):
41 self.targetPicker.setMode(E5PathPickerModes.DirectoryMode)
42 else:
43 self.targetPicker.setMode(E5PathPickerModes.SaveFileMode)
44
45 if move:
46 self.setWindowTitle(self.tr('Subversion Move'))
47 else:
48 self.forceCheckBox.setEnabled(False)
49 self.forceCheckBox.setChecked(force)
50
51 self.sourceEdit.setText(source)
52
53 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
54
55 msh = self.minimumSizeHint()
56 self.resize(max(self.width(), msh.width()), msh.height())
57
58 def getData(self):
59 """
60 Public method to retrieve the copy data.
61
62 @return the target name (string) and a flag indicating
63 the operation should be enforced (boolean)
64 """
65 target = self.targetPicker.text()
66 if not os.path.isabs(target):
67 sourceDir = os.path.dirname(self.sourceEdit.text())
68 target = os.path.join(sourceDir, target)
69 return (target, self.forceCheckBox.isChecked())
70
71 @pyqtSlot(str)
72 def on_targetPicker_textChanged(self, txt):
73 """
74 Private slot to handle changes of the target.
75
76 @param txt contents of the target edit (string)
77 """
78 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
79 os.path.isabs(txt) or os.path.dirname(txt) == "")

eric ide

mercurial