Plugins/VcsPlugins/vcsGit/GitSubmodulesDeinitDialog.py

changeset 6020
baf6da1ae288
child 6026
4773c9469880
equal deleted inserted replaced
6019:58ecdaf0b789 6020:baf6da1ae288
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2017 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to get the data for a submodule deinit operation.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_GitSubmodulesDeinitDialog import Ui_GitSubmodulesDeinitDialog
16
17
18 class GitSubmodulesDeinitDialog(QDialog, Ui_GitSubmodulesDeinitDialog):
19 """
20 Class implementing a dialog to get the data for a submodule deinit
21 operation.
22 """
23 def __init__(self, submodulePaths, parent=None):
24 """
25 Constructor
26
27 @param submodulePaths list of submodule paths
28 @type list of str
29 @param parent reference to the parent widget
30 @type QWidget
31 """
32 super(GitSubmodulesDeinitDialog, self).__init__(parent)
33 self.setupUi(self)
34
35 self.submodulesList.addItems(sorted(submodulePaths))
36
37 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
38
39 def __updateOK(self):
40 """
41 Private slot to update the state of the OK button.
42 """
43 enable = self.allCheckBox.isChecked() or \
44 len(self.submodulesList.selectedItems()) > 0
45 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
46
47 @pyqtSlot(bool)
48 def on_allCheckBox_toggled(self, checked):
49 """
50 Private slot to react on changes of the all checkbox.
51
52 @param checked state of the checkbox
53 @type bool
54 """
55 self.__updateOK()
56
57 @pyqtSlot()
58 def on_submodulesList_itemSelectionChanged(self):
59 """
60 Private slot to react on changes of the submodule selection.
61 """
62 self.__updateOK()
63
64 def getData(self):
65 """
66 Public method to get the entered data.
67
68 @return tuple containing a flag to indicate all submodules, a list of
69 selected submodules and a flag indicating an enforced operation
70 @rtype tuple of (bool, list of str, bool)
71 """
72 submodulePaths = []
73 all = self.allCheckBox.isChecked()
74 if not all:
75 for itm in self.submodulesList.selectedItems():
76 submodulePaths.append(itm.text())
77
78 return all, submodulePaths, self.forceCheckBox.isChecked()

eric ide

mercurial