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

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

"""
Module implementing a dialog to enter the login data for CVS.
"""

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from Ui_CvsLoginDialog import Ui_CvsLoginDialog
from Config import ConfigCvsProtocols

class CvsLoginDialog(QDialog, Ui_CvsLoginDialog):
    """
    Class implementing a dialog to enter the login data for CVS.
    """
    def __init__(self, parent = None):
        """
        Constructor
        
        @param parent parent widget (QWidget)
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
        
        self.buttonBox.button(QDialogButtonBox.Ok).setText(self.trUtf8("Login"))
        
        self.validator = QIntValidator(self)
        self.validator.setObjectName("portValidator")
        self.portEdit.setValidator(self.validator)
        
        self.protocolComboBox.addItems(ConfigCvsProtocols)
        
    def getData(self):
        """
        Public slot to retrieve the data entered into the dialog.
        
        @return a tuple of 6 strings (protocol, username,
            password, remote hostname, remote port and repository).
        """
        return (unicode(self.protocolComboBox.currentText()),
            unicode(self.usernameEdit.text()),
            unicode(self.passwordEdit.text()),
            unicode(self.hostEdit.text()),
            unicode(self.portEdit.text()),
            unicode(self.repositoryEdit.text())
        )
