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

eric ide

mercurial