|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2019 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 __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtWidgets import QDialog |
|
13 |
|
14 from .Ui_GitSubmodulesUpdateOptionsDialog import \ |
|
15 Ui_GitSubmodulesUpdateOptionsDialog |
|
16 |
|
17 |
|
18 class GitSubmodulesUpdateOptionsDialog(QDialog, |
|
19 Ui_GitSubmodulesUpdateOptionsDialog): |
|
20 """ |
|
21 Class implementing a dialog to enter options for a submodule update |
|
22 command. |
|
23 """ |
|
24 def __init__(self, submodulePaths, parent=None): |
|
25 """ |
|
26 Constructor |
|
27 |
|
28 @param submodulePaths list of submodule paths |
|
29 @type list of str |
|
30 @param parent reference to the parent widget |
|
31 @type QWidget |
|
32 """ |
|
33 super(GitSubmodulesUpdateOptionsDialog, self).__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.submodulesList.addItems(sorted(submodulePaths)) |
|
37 |
|
38 def getData(self): |
|
39 """ |
|
40 Public method to get the entered data. |
|
41 |
|
42 @return tuple containing the update procedure, a flag indicating an |
|
43 init, a flag indicating an update with remote, a flag indicating |
|
44 not to fetch the remote, a flag indicating an enforced operation |
|
45 and a list of selected submodules. |
|
46 @rtype tuple of (int, bool, bool, bool, bool, list of str) |
|
47 """ |
|
48 submodulePaths = [] |
|
49 for itm in self.submodulesList.selectedItems(): |
|
50 submodulePaths.append(itm.text()) |
|
51 |
|
52 if self.checkoutButton.isChecked(): |
|
53 procedure = "--checkout" |
|
54 elif self.rebaseButton.isChecked(): |
|
55 procedure = "--rebase" |
|
56 else: |
|
57 procedure = "--merge" |
|
58 |
|
59 if self.remoteCheckBox.isChecked(): |
|
60 nofetch = self.nofetchCheckBox.isChecked() |
|
61 else: |
|
62 nofetch = False |
|
63 |
|
64 return ( |
|
65 procedure, |
|
66 self.initCheckBox.isChecked(), |
|
67 self.remoteCheckBox.isChecked(), |
|
68 nofetch, |
|
69 self.forceCheckBox.isChecked(), |
|
70 submodulePaths, |
|
71 ) |