|
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 to be used for a fetch operation. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog |
|
12 |
|
13 from .Ui_HgFetchDialog import Ui_HgFetchDialog |
|
14 |
|
15 import Preferences |
|
16 |
|
17 |
|
18 class HgFetchDialog(QDialog, Ui_HgFetchDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter data to be used for a fetch operation. |
|
21 """ |
|
22 def __init__(self, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param parent reference to the parent widget (QWidget) |
|
27 """ |
|
28 QDialog.__init__(self, parent) |
|
29 self.setupUi(self) |
|
30 |
|
31 self.recentCommitMessages = Preferences.toList( |
|
32 Preferences.Prefs.settings.value('Mercurial/Commits')) |
|
33 self.recentComboBox.clear() |
|
34 self.recentComboBox.addItem("") |
|
35 self.recentComboBox.addItems(self.recentCommitMessages) |
|
36 |
|
37 @pyqtSlot(str) |
|
38 def on_recentComboBox_activated(self, txt): |
|
39 """ |
|
40 Private slot to select a commit message from recent ones. |
|
41 |
|
42 @param txt text of the selected entry (string) |
|
43 """ |
|
44 if txt: |
|
45 self.messageEdit.setPlainText(txt) |
|
46 |
|
47 def getData(self): |
|
48 """ |
|
49 Public method to get the data for the fetch operation. |
|
50 |
|
51 @return tuple with the commit message and a flag indicating to switch |
|
52 the merge order (string, boolean) |
|
53 """ |
|
54 msg = self.messageEdit.toPlainText() |
|
55 if msg: |
|
56 if msg in self.recentCommitMessages: |
|
57 self.recentCommitMessages.remove(msg) |
|
58 self.recentCommitMessages.insert(0, msg) |
|
59 no = int(Preferences.Prefs.settings\ |
|
60 .value('Mercurial/CommitMessages', 20)) |
|
61 del self.recentCommitMessages[no:] |
|
62 Preferences.Prefs.settings.setValue('Mercurial/Commits', |
|
63 self.recentCommitMessages) |
|
64 |
|
65 return msg, self.switchCheckBox.isChecked() |