|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 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 import os |
|
11 |
|
12 from PyQt4.QtCore import pyqtSlot, QDir |
|
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QFileDialog |
|
14 |
|
15 from E5Gui import E5FileDialog |
|
16 from E5Gui.E5Completers import E5DirCompleter |
|
17 |
|
18 from .Ui_HgExportDialog import Ui_HgExportDialog |
|
19 |
|
20 import Utilities |
|
21 |
|
22 |
|
23 class HgExportDialog(QDialog, Ui_HgExportDialog): |
|
24 """ |
|
25 Class documentation goes here. |
|
26 """ |
|
27 def __init__(self, parent=None): |
|
28 """ |
|
29 Constructor |
|
30 |
|
31 @param parent reference to the parent widget (QWidget) |
|
32 """ |
|
33 super().__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
37 |
|
38 self.__directoryCompleter = E5DirCompleter(self.directoryEdit) |
|
39 |
|
40 # set default values for directory and pattern |
|
41 self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff") |
|
42 self.directoryEdit.setText(QDir.tempPath()) |
|
43 |
|
44 def __updateOK(self): |
|
45 """ |
|
46 Private slot to update the OK button. |
|
47 """ |
|
48 enabled = True |
|
49 |
|
50 if self.directoryEdit.text() == "": |
|
51 enabled = False |
|
52 elif self.patternEdit.text() == "": |
|
53 enabled = False |
|
54 elif self.changesetsEdit.toPlainText() == "": |
|
55 enabled = False |
|
56 |
|
57 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
|
58 |
|
59 @pyqtSlot(str) |
|
60 def on_directoryEdit_textChanged(self, p0): |
|
61 """ |
|
62 Private slot to react on changes of the export directory edit. |
|
63 |
|
64 @param txt contents of the line edit (string) |
|
65 """ |
|
66 self.__updateOK() |
|
67 |
|
68 @pyqtSlot() |
|
69 def on_directoryButton_clicked(self): |
|
70 """ |
|
71 Private slot called by pressing the export directory selection button. |
|
72 """ |
|
73 dn = E5FileDialog.getExistingDirectory( |
|
74 self, |
|
75 self.trUtf8("Export Patches"), |
|
76 self.directoryEdit.text(), |
|
77 QFileDialog.Options(QFileDialog.Option(0))) |
|
78 |
|
79 if dn: |
|
80 self.directoryEdit.setText(Utilities.toNativeSeparators(dn)) |
|
81 |
|
82 @pyqtSlot(str) |
|
83 def on_patternEdit_textChanged(self, p0): |
|
84 """ |
|
85 Private slot to react on changes of the export file name pattern edit. |
|
86 |
|
87 @param txt contents of the line edit (string) |
|
88 """ |
|
89 self.__updateOK() |
|
90 |
|
91 @pyqtSlot() |
|
92 def on_changesetsEdit_textChanged(self): |
|
93 """ |
|
94 Private slot to react on changes of the changesets edit. |
|
95 |
|
96 @param txt contents of the line edit (string) |
|
97 """ |
|
98 self.__updateOK() |
|
99 |
|
100 def getParameters(self): |
|
101 """ |
|
102 Public method to retrieve the export data. |
|
103 |
|
104 @return tuple naming the output file name, the list of revisions to export, |
|
105 and flags indicating to compare against the second parent, to treat all |
|
106 files as text, to omit dates in the diff headers and to use the git extended |
|
107 diff format (string, list of strings, boolean, boolean, boolean, boolean) |
|
108 """ |
|
109 return ( |
|
110 os.path.join(Utilities.toNativeSeparators(self.directoryEdit.text()), |
|
111 self.patternEdit.text()), |
|
112 self.changesetsEdit.toPlainText().splitlines(), |
|
113 self.switchParentCheckBox.isChecked(), |
|
114 self.textCheckBox.isChecked(), |
|
115 self.datesCheckBox.isChecked(), |
|
116 self.gitCheckBox.isChecked() |
|
117 ) |