Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarkRenameDialog.py

Wed, 24 Jul 2013 18:59:34 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 24 Jul 2013 18:59:34 +0200
branch
5_3_x
changeset 2818
add8426ea430
parent 2302
f29e9405c851
child 2525
8b507a9a2d40
child 3034
7ce719013078
child 3163
9f50365a0870
permissions
-rw-r--r--

Fixed an issue in the Mercurial VCS module.
(grafted from 961fba66e01948b082fdf4b3a50b1308ec709c6b)

# -*- coding: utf-8 -*-

# Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to get the data to rename a bookmark.
"""

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog, QDialogButtonBox

from .Ui_HgBookmarkRenameDialog import Ui_HgBookmarkRenameDialog


class HgBookmarkRenameDialog(QDialog, Ui_HgBookmarkRenameDialog):
    """
    Class implementing a dialog to get the data to rename a bookmark.
    """
    def __init__(self, bookmarksList, parent=None):
        """
        Constructor
        
        @param bookmarksList list of bookmarks (list of strings)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
       
        self.bookmarkCombo.addItems(sorted(bookmarksList))
    
    def __updateUI(self):
        """
        Private slot to update the UI.
        """
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
            self.nameEdit.text() != "" and \
            self.bookmarkCombo.currentText() != ""
        )
    
    @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.__updateUI()
    
    @pyqtSlot(str)
    def on_bookmarkCombo_editTextChanged(self, txt):
        """
        Private slot to handle changes of the selected bookmark.
        
        @param txt name of the selected bookmark (string)
        """
        self.__updateUI()
    
    def getData(self):
        """
        Public method to retrieve the entered data.
        
        @return tuple naming the new and old bookmark names
            (string, string)
        """
        return self.nameEdit.text(), self.bookmarkCombo.currentText()

eric ide

mercurial