src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnCopyDialog.py

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

eric ide

mercurial