eric6/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7110
948994b4f045
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter data for the Mercurial export command.
8 """
9
10 from __future__ import unicode_literals
11
12 import os
13
14 from PyQt5.QtCore import pyqtSlot, QDir
15 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
16
17 from E5Gui.E5PathPicker import E5PathPickerModes
18
19 from .Ui_HgExportDialog import Ui_HgExportDialog
20
21
22 class HgExportDialog(QDialog, Ui_HgExportDialog):
23 """
24 Class implementing a dialog to enter data for the Mercurial export command.
25 """
26 def __init__(self, bookmarksList, bookmarkAvailable, parent=None):
27 """
28 Constructor
29
30 @param bookmarksList list of defined bookmarks
31 @type list of str
32 @param bookmarkAvailable flag indicating the availability of the
33 "--bookmark" option
34 @type bool
35 @param parent reference to the parent widget
36 @type QWidget
37 """
38 super(HgExportDialog, self).__init__(parent)
39 self.setupUi(self)
40
41 self.directoryPicker.setMode(E5PathPickerModes.DirectoryMode)
42
43 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
44
45 # set default values for directory and pattern
46 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff")
47 self.directoryPicker.setText(QDir.tempPath())
48
49 self.bookmarkCombo.addItem("")
50 self.bookmarkCombo.addItems(sorted(bookmarksList))
51 self.bookmarkCombo.setenabled(bookmarkAvailable)
52
53 def __updateOK(self):
54 """
55 Private slot to update the OK button.
56 """
57 enabled = True
58
59 if self.directoryPicker.text() == "":
60 enabled = False
61 elif self.patternEdit.text() == "":
62 enabled = False
63 elif self.changesetsEdit.toPlainText() == "" and \
64 self.bookmarkCombo.currentText() == "":
65 enabled = False
66
67 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
68
69 @pyqtSlot(str)
70 def on_directoryPicker_textChanged(self, txt):
71 """
72 Private slot to react on changes of the export directory edit.
73
74 @param txt contents of the line edit (string)
75 """
76 self.__updateOK()
77
78 @pyqtSlot(str)
79 def on_patternEdit_textChanged(self, txt):
80 """
81 Private slot to react on changes of the export file name pattern edit.
82
83 @param txt contents of the line edit (string)
84 """
85 self.__updateOK()
86
87 @pyqtSlot()
88 def on_changesetsEdit_textChanged(self):
89 """
90 Private slot to react on changes of the changesets edit.
91 """
92 self.__updateOK()
93
94 def getParameters(self):
95 """
96 Public method to retrieve the export data.
97
98 @return tuple naming the output file name, the list of revisions to
99 export, the name of a bookmarked branch and flags indicating to
100 compare against the second parent, to treat all files as text,
101 to omit dates in the diff headers and to use the git extended
102 diff format
103 @rtype tuple of (str, list of str, str, bool, bool, bool, bool)
104 """
105 return (
106 os.path.join(
107 self.directoryPicker.text(),
108 self.patternEdit.text()),
109 self.changesetsEdit.toPlainText().splitlines(),
110 self.bookmarkCombo.currentText(),
111 self.switchParentCheckBox.isChecked(),
112 self.textCheckBox.isChecked(),
113 self.datesCheckBox.isChecked(),
114 self.gitCheckBox.isChecked()
115 )

eric ide

mercurial