|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to remove sub-repositories. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import pyqtSlot |
|
13 from PyQt5.QtWidgets import QDialog |
|
14 |
|
15 from .Ui_HgRemoveSubrepositoriesDialog import Ui_HgRemoveSubrepositoriesDialog |
|
16 |
|
17 |
|
18 class HgRemoveSubrepositoriesDialog(QDialog, Ui_HgRemoveSubrepositoriesDialog): |
|
19 """ |
|
20 Class implementing a dialog to remove sub-repositories. |
|
21 """ |
|
22 def __init__(self, subrepositories, parent=None): |
|
23 """ |
|
24 Constructor |
|
25 |
|
26 @param subrepositories list of sub-repository entries (list of strings) |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 super(HgRemoveSubrepositoriesDialog, self).__init__(parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 self.subrepositories.addItems(subrepositories) |
|
33 self.__removed = [] |
|
34 |
|
35 @pyqtSlot() |
|
36 def on_subrepositories_itemSelectionChanged(self): |
|
37 """ |
|
38 Private slot handling the selection of entries. |
|
39 """ |
|
40 self.removeButton.setEnabled( |
|
41 len(self.subrepositories.selectedItems()) > 0) |
|
42 |
|
43 @pyqtSlot() |
|
44 def on_removeButton_clicked(self): |
|
45 """ |
|
46 Private slot handling the removal of the selected entries. |
|
47 """ |
|
48 for itm in self.subrepositories.selectedItems(): |
|
49 self.__removed.append(itm.text()) |
|
50 row = self.subrepositories.row(itm) |
|
51 self.subrepositories.takeItem(row) |
|
52 del itm |
|
53 |
|
54 def getData(self): |
|
55 """ |
|
56 Public method to retrieve the data. |
|
57 |
|
58 @return tuple giving the remaining sub-repositories, the removed ones |
|
59 and a flag indicating to delete the removed ones from disc (list |
|
60 of strings, list of strings, boolean) |
|
61 """ |
|
62 return ( |
|
63 [self.subrepositories.item(row).text() |
|
64 for row in range(self.subrepositories.count())], |
|
65 self.__removed, |
|
66 self.deleteCheckBox.isChecked() |
|
67 ) |