Plugins/VcsPlugins/vcsMercurial/FetchExtension/HgFetchDialog.py

changeset 1066
a3dd41fd9ea8
child 1131
7781e396c903
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/VcsPlugins/vcsMercurial/FetchExtension/HgFetchDialog.py	Sat May 28 11:20:25 2011 +0200
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to enter data to be used for a fetch operation.
+"""
+
+from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtGui import QDialog
+
+from .Ui_HgFetchDialog import Ui_HgFetchDialog
+
+import Preferences
+
+
+class HgFetchDialog(QDialog, Ui_HgFetchDialog):
+    """
+    Class implementing a dialog to enter data to be used for a fetch operation.
+    """
+    def __init__(self, parent=None):
+        """
+        Constructor
+        
+        @param parent reference to the parent widget (QWidget)
+        """
+        QDialog.__init__(self, parent)
+        self.setupUi(self)
+        
+        self.recentCommitMessages = Preferences.toList(
+            Preferences.Prefs.settings.value('Mercurial/Commits'))
+        self.recentComboBox.clear()
+        self.recentComboBox.addItem("")
+        self.recentComboBox.addItems(self.recentCommitMessages)
+    
+    @pyqtSlot(str)
+    def on_recentComboBox_activated(self, txt):
+        """
+        Private slot to select a commit message from recent ones.
+        
+        @param txt text of the selected entry (string)
+        """
+        if txt:
+            self.messageEdit.setPlainText(txt)
+    
+    def getData(self):
+        """
+        Public method to get the data for the fetch operation.
+        
+        @return tuple with the commit message and a flag indicating to switch
+            the merge order (string, boolean)
+        """
+        msg = self.messageEdit.toPlainText()
+        if msg:
+            if msg in self.recentCommitMessages:
+                self.recentCommitMessages.remove(msg)
+            self.recentCommitMessages.insert(0, msg)
+            no = int(Preferences.Prefs.settings\
+                .value('Mercurial/CommitMessages', 20))
+            del self.recentCommitMessages[no:]
+            Preferences.Prefs.settings.setValue('Mercurial/Commits',
+                self.recentCommitMessages)
+        
+        return msg, self.switchCheckBox.isChecked()

eric ide

mercurial