eric6/Plugins/VcsPlugins/vcsMercurial/LargefilesExtension/LfConvertDataDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8143
2c730d5fd177
permissions
-rw-r--r--

Updated copyright for 2021.

3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4543
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
4 #
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
5
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the data for the repo conversion.
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
15 from E5Gui.E5PathPicker import E5PathPickerModes
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from .Ui_LfConvertDataDialog import Ui_LfConvertDataDialog
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from . import getDefaults
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Utilities
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 class LfConvertDataDialog(QDialog, Ui_LfConvertDataDialog):
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing a dialog to enter the data for the repo conversion.
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, currentPath, mode, parent=None):
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param currentPath directory name of the current project (string)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param mode dialog mode (string, one of 'largefiles' or 'normal')
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param parent reference to the parent widget (QWidget)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
3484
645c12de6b0c Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3366
diff changeset
36 super(LfConvertDataDialog, self).__init__(parent)
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setupUi(self)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
39 self.newProjectPicker.setMode(E5PathPickerModes.DirectoryMode)
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__defaults = getDefaults()
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__currentPath = Utilities.toNativeSeparators(currentPath)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.currentProjectLabel.setPath(currentPath)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
45 self.newProjectPicker.setText(os.path.dirname(currentPath))
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.lfFileSizeSpinBox.setValue(self.__defaults["minsize"])
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.lfFilePatternsEdit.setText(" ".join(self.__defaults["pattern"]))
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 if mode == 'normal':
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.lfFileSizeSpinBox.setEnabled(False)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.lfFilePatternsEdit.setEnabled(False)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3310
diff changeset
54 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3310
diff changeset
55 self.resize(max(self.width(), msh.width()), msh.height())
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @pyqtSlot(str)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
58 def on_newProjectPicker_textChanged(self, txt):
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Private slot to handle editing of the new project directory.
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 @param txt new project directory name (string)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 txt and Utilities.toNativeSeparators(txt) != os.path.dirname(
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__currentPath))
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def getData(self):
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 Public method to retrieve the entered data.
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @return tuple containing the new project directory name (string),
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 minimum file size (integer) and file patterns (list of string)
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 patterns = self.lfFilePatternsEdit.text().split()
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if set(patterns) == set(self.__defaults["pattern"]):
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 patterns = []
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 return (
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
80 self.newProjectPicker.text(),
3310
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.lfFileSizeSpinBox.value(),
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 patterns,
a2032ed66aec Started implementing the Mercurial lfconvert functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 )

eric ide

mercurial