src/eric7/Plugins/VcsPlugins/vcsPySvn/SvnCommitDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 18
19 19
20 class SvnCommitDialog(QWidget, Ui_SvnCommitDialog): 20 class SvnCommitDialog(QWidget, Ui_SvnCommitDialog):
21 """ 21 """
22 Class implementing a dialog to enter the commit message. 22 Class implementing a dialog to enter the commit message.
23 23
24 @signal accepted() emitted, if the dialog was accepted 24 @signal accepted() emitted, if the dialog was accepted
25 @signal rejected() emitted, if the dialog was rejected 25 @signal rejected() emitted, if the dialog was rejected
26 """ 26 """
27
27 accepted = pyqtSignal() 28 accepted = pyqtSignal()
28 rejected = pyqtSignal() 29 rejected = pyqtSignal()
29 30
30 def __init__(self, vcs, parent=None): 31 def __init__(self, vcs, parent=None):
31 """ 32 """
32 Constructor 33 Constructor
33 34
34 @param vcs reference to the vcs object 35 @param vcs reference to the vcs object
35 @param parent parent widget (QWidget) 36 @param parent parent widget (QWidget)
36 """ 37 """
37 super().__init__(parent, Qt.WindowType.Window) 38 super().__init__(parent, Qt.WindowType.Window)
38 self.setupUi(self) 39 self.setupUi(self)
39 40
40 self.__vcs = vcs 41 self.__vcs = vcs
41 42
42 project = ericApp().getObject("Project") 43 project = ericApp().getObject("Project")
43 pwl, pel = project.getProjectDictionaries() 44 pwl, pel = project.getProjectDictionaries()
44 language = project.getProjectSpellLanguage() 45 language = project.getProjectSpellLanguage()
45 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None) 46 self.logEdit.setLanguageWithPWL(language, pwl or None, pel or None)
46 47
47 if pysvn.svn_version < (1, 5, 0) or pysvn.version < (1, 6, 0): 48 if pysvn.svn_version < (1, 5, 0) or pysvn.version < (1, 6, 0):
48 self.changeListsGroup.hide() 49 self.changeListsGroup.hide()
49 else: 50 else:
50 self.changeLists.addItems(sorted(vcs.svnGetChangelists())) 51 self.changeLists.addItems(sorted(vcs.svnGetChangelists()))
51 52
52 def showEvent(self, evt): 53 def showEvent(self, evt):
53 """ 54 """
54 Protected method called when the dialog is about to be shown. 55 Protected method called when the dialog is about to be shown.
55 56
56 @param evt the event (QShowEvent) 57 @param evt the event (QShowEvent)
57 """ 58 """
58 commitMessages = self.__vcs.vcsCommitMessages() 59 commitMessages = self.__vcs.vcsCommitMessages()
59 self.recentComboBox.clear() 60 self.recentComboBox.clear()
60 self.recentComboBox.addItem("") 61 self.recentComboBox.addItem("")
61 self.recentComboBox.addItems(commitMessages) 62 self.recentComboBox.addItems(commitMessages)
62 63
63 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason) 64 self.logEdit.setFocus(Qt.FocusReason.OtherFocusReason)
64 65
65 def logMessage(self): 66 def logMessage(self):
66 """ 67 """
67 Public method to retrieve the log message. 68 Public method to retrieve the log message.
68 69
69 This method has the side effect of saving the 20 most recent 70 This method has the side effect of saving the 20 most recent
70 commit messages for reuse. 71 commit messages for reuse.
71 72
72 @return the log message (string) 73 @return the log message (string)
73 """ 74 """
74 msg = self.logEdit.toPlainText() 75 msg = self.logEdit.toPlainText()
75 if msg: 76 if msg:
76 self.__vcs.vcsAddCommitMessage(msg) 77 self.__vcs.vcsAddCommitMessage(msg)
77 return msg 78 return msg
78 79
79 def hasChangelists(self): 80 def hasChangelists(self):
80 """ 81 """
81 Public method to check, if the user entered some changelists. 82 Public method to check, if the user entered some changelists.
82 83
83 @return flag indicating availability of changelists (boolean) 84 @return flag indicating availability of changelists (boolean)
84 """ 85 """
85 return len(self.changeLists.selectedItems()) > 0 86 return len(self.changeLists.selectedItems()) > 0
86 87
87 def changelistsData(self): 88 def changelistsData(self):
88 """ 89 """
89 Public method to retrieve the changelists data. 90 Public method to retrieve the changelists data.
90 91
91 @return tuple containing the changelists (list of strings) and a flag 92 @return tuple containing the changelists (list of strings) and a flag
92 indicating to keep changelists (boolean) 93 indicating to keep changelists (boolean)
93 """ 94 """
94 slists = [line.text().strip() 95 slists = [
95 for line in self.changeLists.selectedItems() 96 line.text().strip()
96 if line.text().strip() != ""] 97 for line in self.changeLists.selectedItems()
97 98 if line.text().strip() != ""
99 ]
100
98 if len(slists) == 0: 101 if len(slists) == 0:
99 return [], False 102 return [], False
100 103
101 return slists, self.keepChangeListsCheckBox.isChecked() 104 return slists, self.keepChangeListsCheckBox.isChecked()
102 105
103 def on_buttonBox_clicked(self, button): 106 def on_buttonBox_clicked(self, button):
104 """ 107 """
105 Private slot called by a button of the button box clicked. 108 Private slot called by a button of the button box clicked.
106 109
107 @param button button that was clicked (QAbstractButton) 110 @param button button that was clicked (QAbstractButton)
108 """ 111 """
109 if button == self.buttonBox.button( 112 if button == self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel):
110 QDialogButtonBox.StandardButton.Cancel
111 ):
112 self.logEdit.clear() 113 self.logEdit.clear()
113 114
114 def on_buttonBox_accepted(self): 115 def on_buttonBox_accepted(self):
115 """ 116 """
116 Private slot called by the buttonBox accepted signal. 117 Private slot called by the buttonBox accepted signal.
117 """ 118 """
118 self.close() 119 self.close()
119 self.accepted.emit() 120 self.accepted.emit()
120 121
121 def on_buttonBox_rejected(self): 122 def on_buttonBox_rejected(self):
122 """ 123 """
123 Private slot called by the buttonBox rejected signal. 124 Private slot called by the buttonBox rejected signal.
124 """ 125 """
125 self.close() 126 self.close()
126 self.rejected.emit() 127 self.rejected.emit()
127 128
128 @pyqtSlot(int) 129 @pyqtSlot(int)
129 def on_recentComboBox_activated(self, index): 130 def on_recentComboBox_activated(self, index):
130 """ 131 """
131 Private slot to select a commit message from recent ones. 132 Private slot to select a commit message from recent ones.
132 133
133 @param index index of the selected entry 134 @param index index of the selected entry
134 @type int 135 @type int
135 """ 136 """
136 txt = self.recentComboBox.itemText(index) 137 txt = self.recentComboBox.itemText(index)
137 if txt: 138 if txt:

eric ide

mercurial