Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.py

changeset 3310
a2032ed66aec
child 3366
6084bb3c3911
equal deleted inserted replaced
3309:b5f782f7d43b 3310:a2032ed66aec
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing a dialog to enter the data for the repo conversion.
5 """
6
7 import os
8
9 from PyQt4.QtCore import pyqtSlot
10 from PyQt4.QtGui import QDialog, QDialogButtonBox
11
12 from E5Gui import E5FileDialog
13 from E5Gui.E5Completers import E5DirCompleter
14
15 from .Ui_LfConvertDataDialog import Ui_LfConvertDataDialog
16
17 from . import getDefaults
18
19 import Utilities
20 import UI.PixmapCache
21
22
23 class LfConvertDataDialog(QDialog, Ui_LfConvertDataDialog):
24 """
25 Class implementing a dialog to enter the data for the repo conversion.
26 """
27 def __init__(self, currentPath, mode, parent=None):
28 """
29 Constructor
30
31 @param currentPath directory name of the current project (string)
32 @param mode dialog mode (string, one of 'largefiles' or 'normal')
33 @param parent reference to the parent widget (QWidget)
34 """
35 super().__init__(parent)
36 self.setupUi(self)
37
38 self.newProjectButton.setIcon(UI.PixmapCache.getIcon("open.png"))
39
40 self.__newProjectCompleter = E5DirCompleter(self.newProjectEdit)
41
42 self.__defaults = getDefaults()
43 self.__currentPath = Utilities.toNativeSeparators(currentPath)
44
45 self.currentProjectLabel.setPath(currentPath)
46 self.newProjectEdit.setText(os.path.dirname(currentPath))
47
48 self.lfFileSizeSpinBox.setValue(self.__defaults["minsize"])
49 self.lfFilePatternsEdit.setText(" ".join(self.__defaults["pattern"]))
50
51 if mode == 'normal':
52 self.lfFileSizeSpinBox.setEnabled(False)
53 self.lfFilePatternsEdit.setEnabled(False)
54
55 self.resize(self.width(), self.minimumSizeHint().height())
56
57 @pyqtSlot(str)
58 def on_newProjectEdit_textChanged(self, txt):
59 """
60 Private slot to handle editing of the new project directory.
61
62 @param txt new project directory name (string)
63 """
64 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
65 txt and Utilities.toNativeSeparators(txt) != os.path.dirname(
66 self.__currentPath))
67
68 @pyqtSlot()
69 def on_newProjectButton_clicked(self):
70 """
71 Private slot to select the new project directory name via a directory
72 selection dialog.
73 """
74 directory = Utilities.fromNativeSeparators(self.newProjectEdit.text())
75 directory = E5FileDialog.getExistingDirectory(
76 self,
77 self.tr("New Project Directory"),
78 directory,
79 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
80 if directory:
81 self.newProjectEdit.setText(
82 Utilities.toNativeSeparators(directory))
83
84 def getData(self):
85 """
86 Public method to retrieve the entered data.
87
88 @return tuple containing the new project directory name (string),
89 minimum file size (integer) and file patterns (list of string)
90 """
91 patterns = self.lfFilePatternsEdit.text().split()
92 if set(patterns) == set(self.__defaults["pattern"]):
93 patterns = []
94
95 return (
96 Utilities.toNativeSeparators(self.newProjectEdit.text()),
97 self.lfFileSizeSpinBox.value(),
98 patterns,
99 )

eric ide

mercurial