eric7/Plugins/VcsPlugins/vcsGit/GitSubmodulesDeinitDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/eric7/Plugins/VcsPlugins/vcsGit/GitSubmodulesDeinitDialog.py	Sat May 15 18:45:04 2021 +0200
@@ -0,0 +1,80 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to get the data for a submodule deinit operation.
+"""
+
+from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtWidgets import QDialog, QDialogButtonBox
+
+from .Ui_GitSubmodulesDeinitDialog import Ui_GitSubmodulesDeinitDialog
+
+
+class GitSubmodulesDeinitDialog(QDialog, Ui_GitSubmodulesDeinitDialog):
+    """
+    Class implementing a dialog to get the data for a submodule deinit
+    operation.
+    """
+    def __init__(self, submodulePaths, parent=None):
+        """
+        Constructor
+        
+        @param submodulePaths list of submodule paths
+        @type list of str
+        @param parent reference to the parent widget
+        @type QWidget
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+        
+        self.submodulesList.addItems(sorted(submodulePaths))
+        
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+    
+    def __updateOK(self):
+        """
+        Private slot to update the state of the OK button.
+        """
+        enable = (
+            self.allCheckBox.isChecked() or
+            len(self.submodulesList.selectedItems()) > 0
+        )
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
+    
+    @pyqtSlot(bool)
+    def on_allCheckBox_toggled(self, checked):
+        """
+        Private slot to react on changes of the all checkbox.
+        
+        @param checked state of the checkbox
+        @type bool
+        """
+        self.__updateOK()
+    
+    @pyqtSlot()
+    def on_submodulesList_itemSelectionChanged(self):
+        """
+        Private slot to react on changes of the submodule selection.
+        """
+        self.__updateOK()
+    
+    def getData(self):
+        """
+        Public method to get the entered data.
+        
+        @return tuple containing a flag to indicate all submodules, a list of
+            selected submodules and a flag indicating an enforced operation
+        @rtype tuple of (bool, list of str, bool)
+        """
+        submodulePaths = []
+        deinitAll = self.allCheckBox.isChecked()
+        if not deinitAll:
+            for itm in self.submodulesList.selectedItems():
+                submodulePaths.append(itm.text())
+        
+        return all, submodulePaths, self.forceCheckBox.isChecked()

eric ide

mercurial