eric6/Plugins/VcsPlugins/vcsMercurial/HgGraftDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a graft session.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot, QDateTime
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_HgGraftDialog import Ui_HgGraftDialog
16
17
18 class HgGraftDialog(QDialog, Ui_HgGraftDialog):
19 """
20 Class implementing a dialog to enter the data for a graft session.
21 """
22 def __init__(self, vcs, revs=None, parent=None):
23 """
24 Constructor
25
26 @param vcs reference to the VCS object
27 @type Hg
28 @param revs list of revisions to show in the revisions pane
29 @type list of str
30 @param parent reference to the parent widget
31 @type QWidget
32 """
33 super(HgGraftDialog, self).__init__(parent)
34 self.setupUi(self)
35
36 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
37
38 if revs:
39 self.revisionsEdit.setPlainText("\n".join(sorted(revs)))
40
41 self.noCommitCheckBox.setEnabled(vcs.version >= (4, 7, 0))
42
43 self.__updateOk()
44
45 def __updateOk(self):
46 """
47 Private slot to update the state of the OK button.
48 """
49 enable = self.revisionsEdit.toPlainText() != ""
50 if self.userGroup.isChecked():
51 enable = enable and \
52 (self.currentUserCheckBox.isChecked() or
53 self.userEdit.text() != "")
54
55 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
56
57 @pyqtSlot()
58 def on_revisionsEdit_textChanged(self):
59 """
60 Private slot to react upon changes of revisions.
61 """
62 self.__updateOk()
63
64 @pyqtSlot(bool)
65 def on_userGroup_toggled(self, checked):
66 """
67 Private slot to handle changes of the user group state.
68
69 @param checked flag giving the checked state
70 @type bool
71 """
72 self.__updateOk()
73
74 @pyqtSlot(bool)
75 def on_currentUserCheckBox_toggled(self, checked):
76 """
77 Private slot to handle changes of the current user state.
78
79 @param checked flag giving the checked state
80 @type bool
81 """
82 self.__updateOk()
83
84 @pyqtSlot(str)
85 def on_userEdit_textChanged(self, txt):
86 """
87 Private slot to handle changes of the user name.
88
89 @param txt text of the edit (string)
90 """
91 self.__updateOk()
92
93 def getData(self):
94 """
95 Public method to retrieve the entered data.
96
97 @return tuple with list of revisions, a tuple giving a
98 flag indicating to set the user, a flag indicating to use the
99 current user and the user name, another tuple giving a flag
100 indicating to set the date, a flag indicating to use the
101 current date and the date, a flag indicating to append graft info
102 to the log message, a flag indicating a dry-run and a flag
103 indicating to not commit the copied changesets
104 @rtype tuple of (list of str, (bool, bool, str), (bool, bool, str),
105 bool, bool, bool)
106 """
107 userData = (
108 self.userGroup.isChecked(),
109 self.currentUserCheckBox.isChecked(),
110 self.userEdit.text(),
111 )
112
113 dateData = (
114 self.dateGroup.isChecked(),
115 self.currentDateCheckBox.isChecked(),
116 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"),
117 )
118
119 return (
120 self.revisionsEdit.toPlainText().strip().splitlines(),
121 userData,
122 dateData,
123 self.logCheckBox.isChecked(),
124 self.dryRunCheckBox.isChecked(),
125 self.noCommitCheckBox.isChecked(),
126 )

eric ide

mercurial