Plugins/VcsPlugins/vcsMercurial/HgPhaseDialog.py

Mon, 25 Mar 2013 18:27:06 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 25 Mar 2013 18:27:06 +0100
branch
Py2 comp.
changeset 2546
dd9f912d5bd9
parent 2525
8b507a9a2d40
child 3057
10516539f238
permissions
-rw-r--r--

Fixed an issue introduced by the last changes.
(grafted from 3868561e396213cc9222591938181c6b6d238faa)

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

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

"""
Module implementing a dialog to enter data for the Mercurial Phase operation.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

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

from .Ui_HgPhaseDialog import Ui_HgPhaseDialog


class HgPhaseDialog(QDialog, Ui_HgPhaseDialog):
    """
    Class dimplementing a dialog to enter data for the Mercurial Phase operation.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super(HgPhaseDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.phaseCombo.addItem("", "")
        self.phaseCombo.addItem(self.trUtf8("Public"), "p")
        self.phaseCombo.addItem(self.trUtf8("Draft"), "d")
        self.phaseCombo.addItem(self.trUtf8("Secret"), "s")
        
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
    
    def __updateOk(self):
        """
        Private slot to update the state of the OK button.
        """
        self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
            self.revisionsEdit.toPlainText().strip() != "" and
            self.phaseCombo.currentText().strip() != "")
    
    @pyqtSlot()
    def on_revisionsEdit_textChanged(self):
        """
        Private slot to react upon changes of revisions.
        """
        self.__updateOk()
    
    @pyqtSlot(str)
    def on_phaseCombo_activated(self, txt):
        """
        Private slot to react upon changes of the phase.
        """
        self.__updateOk()
    
    def getData(self):
        """
        Public method to retrieve the entered data.
        
        @return tuple with list of revisions, phase and a flag indicating
            a forced operation (list of strings, string, boolean)
        """
        return (
            self.revisionsEdit.toPlainText().strip().splitlines(),
            self.phaseCombo.itemData(self.phaseCombo.currentIndex()),
            self.forceCheckBox.isChecked()
        )

eric ide

mercurial