|
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 list the defined submodules. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import Qt |
|
11 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QHeaderView |
|
12 |
|
13 from .Ui_GitSubmodulesListDialog import Ui_GitSubmodulesListDialog |
|
14 |
|
15 |
|
16 class GitSubmodulesListDialog(QDialog, Ui_GitSubmodulesListDialog): |
|
17 """ |
|
18 Class implementing a dialog to list the defined submodules. |
|
19 """ |
|
20 def __init__(self, submodules, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param submodules list of submodule data to be shown |
|
25 @type list of dictionaries with submodule name, path, URL and branch |
|
26 @param parent reference to the parent widget |
|
27 @type QWidget |
|
28 """ |
|
29 super().__init__(parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 for submodule in submodules: |
|
33 QTreeWidgetItem(self.submodulesList, [ |
|
34 submodule["name"], |
|
35 submodule["path"], |
|
36 submodule["url"], |
|
37 submodule["branch"] |
|
38 ]) |
|
39 self.submodulesList.header().resizeSections( |
|
40 QHeaderView.ResizeMode.ResizeToContents) |
|
41 self.submodulesList.header().setStretchLastSection(True) |
|
42 |
|
43 self.submodulesList.setSortingEnabled(True) |
|
44 self.submodulesList.sortItems(0, Qt.SortOrder.AscendingOrder) |
|
45 self.submodulesList.setSortingEnabled(False) |