Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarkDialog.py

changeset 1011
0b118aefae5b
child 1017
919147f2b518
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarkDialog.py	Mon May 02 19:59:41 2011 +0200
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing the bookmark dialog.
+"""
+
+from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtGui import QDialog, QDialogButtonBox
+
+from .Ui_HgBookmarkDialog import Ui_HgBookmarkDialog
+
+
+class HgBookmarkDialog(QDialog, Ui_HgBookmarkDialog):
+    """
+    Class mplementing the bookmark dialog.
+    """
+    def __init__(self, tagsList, branchesList, bookmarksList, parent=None):
+        """
+        Constructor
+        
+        @param tagsList list of tags (list of strings)
+        @param branchesList list of branches (list of strings)
+        @param bookmarksList list of bookmarks (list of strings)
+        @param parent reference to the parent widget (QWidget)
+        """
+        QDialog.__init__(self, parent)
+        self.setupUi(self)
+        
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
+       
+        self.tagCombo.addItems(sorted(tagsList))
+        self.branchCombo.addItems(["default"] + sorted(branchesList))
+        self.bookmarkCombo.addItems(sorted(bookmarksList))
+    
+    @pyqtSlot(str)
+    def on_nameEdit_textChanged(self, txt):
+        """
+        Private slot to handle changes of the bookmark name.
+        
+        @param txt text of the edit (string)
+        """
+        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(txt != "")
+    
+    def getData(self):
+        """
+        Public method to retrieve the entered data.
+        
+        @return tuple naming the revision and the bookmark name
+            (string, string)
+        """
+        if self.numberButton.isChecked():
+            rev = str(self.numberSpinBox.value())
+        elif self.idButton.isChecked():
+            rev = self.idEdit.text()
+        elif self.tagButton.isChecked():
+            rev = self.tagCombo.currentText()
+        elif self.branchButton.isChecked():
+            rev = self.branchCombo.currentText()
+        elif self.bookmarkButton.isChecked():
+            rev = self.bookmarkCombo.currentText()
+        else:
+            rev = ""
+        
+        return rev, self.nameEdit.text()

eric ide

mercurial