Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesGuardsSelectionDialog.py

Wed, 19 Mar 2014 19:26:30 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 19 Mar 2014 19:26:30 +0100
branch
5_4_x
changeset 3409
b7a3455e9ba0
parent 3160
209a07d7e401
child 3178
f25fc1364c88
child 3190
a9a94491c4fd
permissions
-rw-r--r--

Changed some Mercurial dialogs asking for a (tag, branch,...) name to convert spaces to underscores because spaces are not really recommended.
(grafted from b6e6a7062d12752db6c0c0dc68f0f367bb8a94e6)

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

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

"""
Module implementing a dialog to select a list of guards.
"""

from PyQt4.QtGui import QDialog, QDialogButtonBox, QListWidgetItem, \
    QAbstractItemView

from .Ui_HgQueuesGuardsSelectionDialog import Ui_HgQueuesGuardsSelectionDialog


class HgQueuesGuardsSelectionDialog(QDialog, Ui_HgQueuesGuardsSelectionDialog):
    """
    Class implementing a dialog to select a list of guards.
    """
    def __init__(self, guards, activeGuards=None, listOnly=False, parent=None):
        """
        Constructor
        
        @param guards list of guards to select from (list of strings)
        @keyparam activeGuards list of active guards (list of strings)
        @param listOnly flag indicating to only list the guards (boolean)
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        for guard in guards:
            itm = QListWidgetItem(guard, self.guardsList)
            if activeGuards is not None and guard in activeGuards:
                font = itm.font()
                font.setBold(True)
                itm.setFont(font)
        self.guardsList.sortItems()
        
        if listOnly:
            self.buttonBox.button(QDialogButtonBox.Cancel).hide()
            self.guardsList.setSelectionMode(QAbstractItemView.NoSelection)
            self.setWindowTitle(self.trUtf8("Active Guards"))
    
    def getData(self):
        """
        Public method to retrieve the data.
        
        @return list of selected guards (list of strings)
        """
        guardsList = []
        
        for itm in self.guardsList.selectedItems():
            guardsList.append(itm.text())
        
        return guardsList

eric ide

mercurial