Plugins/VcsPlugins/vcsSubversion/SvnCommitDialog.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the commit message.
8 """
9
10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import *
12
13 from Ui_SvnCommitDialog import Ui_SvnCommitDialog
14
15 import Preferences
16
17 class SvnCommitDialog(QWidget, Ui_SvnCommitDialog):
18 """
19 Class implementing a dialog to enter the commit message.
20
21 @signal accepted() emitted, if the dialog was accepted
22 @signal rejected() emitted, if the dialog was rejected
23 """
24 def __init__(self, vcs, parent = None):
25 """
26 Constructor
27
28 @param vcs reference to the vcs object
29 @param parent parent widget (QWidget)
30 """
31 QWidget.__init__(self, parent, Qt.WindowFlags(Qt.Window))
32 self.setupUi(self)
33
34 if vcs.versionStr < '1.5.0':
35 self.changeListsGroup.hide()
36
37 def showEvent(self, evt):
38 """
39 Public method called when the dialog is about to be shown.
40
41 @param evt the event (QShowEvent)
42 """
43 self.recentCommitMessages = \
44 Preferences.Prefs.settings.value('Subversion/Commits').toStringList()
45 self.recentComboBox.clear()
46 self.recentComboBox.addItem("")
47 self.recentComboBox.addItems(self.recentCommitMessages)
48
49 def logMessage(self):
50 """
51 Public method to retrieve the log message.
52
53 @return the log message (QString)
54 """
55 msg = self.logEdit.toPlainText()
56 if msg:
57 if msg in self.recentCommitMessages:
58 self.recentCommitMessages.remove(msg)
59 self.recentCommitMessages.insert(0, msg)
60 no = Preferences.Prefs.settings\
61 .value('Subversion/CommitMessages', QVariant(20)).toInt()[0]
62 del self.recentCommitMessages[no:]
63 Preferences.Prefs.settings.setValue('Subversion/Commits',
64 QVariant(self.recentCommitMessages))
65 return msg
66
67 def hasChangelists(self):
68 """
69 Public method to check, if the user entered some changelists.
70
71 @return flag indicating availability of changelists (boolean)
72 """
73 listsTxt = self.changeListsEdit.text()
74 lists = listsTxt.split(';')
75 slists = [l.strip() for l in lists if l.strip() != ""]
76 return len(slists) > 0
77
78 def changelistsData(self):
79 """
80 Public method to retrieve the changelists data.
81
82 @return tuple containing the changelists (QStringList) and a flag
83 indicating to keep changelists (boolean)
84 """
85 listsTxt = self.changeListsEdit.text()
86 lists = listsTxt.split(';')
87 slists = [l.strip() for l in lists if l.strip() != ""]
88
89 if len(slists) == 0:
90 return [], False
91
92 return slists, self.keepChangeListsCheckBox.isChecked()
93
94 def on_buttonBox_clicked(self, button):
95 """
96 Private slot called by a button of the button box clicked.
97
98 @param button button that was clicked (QAbstractButton)
99 """
100 if button == self.buttonBox.button(QDialogButtonBox.Cancel):
101 self.logEdit.clear()
102
103 def on_buttonBox_accepted(self):
104 """
105 Private slot called by the buttonBox accepted signal.
106 """
107 self.close()
108 self.emit(SIGNAL("accepted()"))
109
110 def on_buttonBox_rejected(self):
111 """
112 Private slot called by the buttonBox rejected signal.
113 """
114 self.close()
115 self.emit(SIGNAL("rejected()"))
116
117 @pyqtSlot(str)
118 def on_recentComboBox_activated(self, txt):
119 """
120 Private slot to select a commit message from recent ones.
121 """
122 if txt:
123 self.logEdit.setPlainText(txt)

eric ide

mercurial