eric6/Plugins/VcsPlugins/vcsMercurial/HgRemoveSubrepositoriesDialog.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8218
7c09585bd960
permissions
-rw-r--r--

Updated copyright for 2021.

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

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

"""
Module implementing a dialog to remove sub-repositories.
"""

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QDialog

from .Ui_HgRemoveSubrepositoriesDialog import Ui_HgRemoveSubrepositoriesDialog


class HgRemoveSubrepositoriesDialog(QDialog, Ui_HgRemoveSubrepositoriesDialog):
    """
    Class implementing a dialog to remove sub-repositories.
    """
    def __init__(self, subrepositories, parent=None):
        """
        Constructor
        
        @param subrepositories list of sub-repository entries (list of strings)
        @param parent reference to the parent widget (QWidget)
        """
        super(HgRemoveSubrepositoriesDialog, self).__init__(parent)
        self.setupUi(self)
        
        self.subrepositories.addItems(subrepositories)
        self.__removed = []
    
    @pyqtSlot()
    def on_subrepositories_itemSelectionChanged(self):
        """
        Private slot handling the selection of entries.
        """
        self.removeButton.setEnabled(
            len(self.subrepositories.selectedItems()) > 0)
    
    @pyqtSlot()
    def on_removeButton_clicked(self):
        """
        Private slot handling the removal of the selected entries.
        """
        for itm in self.subrepositories.selectedItems():
            self.__removed.append(itm.text())
            row = self.subrepositories.row(itm)
            self.subrepositories.takeItem(row)
            del itm
    
    def getData(self):
        """
        Public method to retrieve the data.
        
        @return tuple giving the remaining sub-repositories, the removed ones
            and a flag indicating to delete the removed ones from disc (list
            of strings, list of strings, boolean)
        """
        return (
            [self.subrepositories.item(row).text()
             for row in range(self.subrepositories.count())],
            self.__removed,
            self.deleteCheckBox.isChecked()
        )

eric ide

mercurial