|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter options for a submodule update command. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from .Ui_GitSubmodulesUpdateOptionsDialog import ( |
|
13 Ui_GitSubmodulesUpdateOptionsDialog |
|
14 ) |
|
15 |
|
16 |
|
17 class GitSubmodulesUpdateOptionsDialog(QDialog, |
|
18 Ui_GitSubmodulesUpdateOptionsDialog): |
|
19 """ |
|
20 Class implementing a dialog to enter options for a submodule update |
|
21 command. |
|
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().__init__(parent) |
|
33 self.setupUi(self) |
|
34 |
|
35 self.submodulesList.addItems(sorted(submodulePaths)) |
|
36 |
|
37 def getData(self): |
|
38 """ |
|
39 Public method to get the entered data. |
|
40 |
|
41 @return tuple containing the update procedure, a flag indicating an |
|
42 init, a flag indicating an update with remote, a flag indicating |
|
43 not to fetch the remote, a flag indicating an enforced operation |
|
44 and a list of selected submodules. |
|
45 @rtype tuple of (int, bool, bool, bool, bool, list of str) |
|
46 """ |
|
47 submodulePaths = [] |
|
48 for itm in self.submodulesList.selectedItems(): |
|
49 submodulePaths.append(itm.text()) |
|
50 |
|
51 if self.checkoutButton.isChecked(): |
|
52 procedure = "--checkout" |
|
53 elif self.rebaseButton.isChecked(): |
|
54 procedure = "--rebase" |
|
55 else: |
|
56 procedure = "--merge" |
|
57 |
|
58 nofetch = (self.remoteCheckBox.isChecked() and |
|
59 self.nofetchCheckBox.isChecked()) |
|
60 |
|
61 return ( |
|
62 procedure, |
|
63 self.initCheckBox.isChecked(), |
|
64 self.remoteCheckBox.isChecked(), |
|
65 nofetch, |
|
66 self.forceCheckBox.isChecked(), |
|
67 submodulePaths, |
|
68 ) |