src/eric7/Project/AddFoundFilesDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9290
fc0cbfb71714
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
14 14
15 15
16 class AddFoundFilesDialog(QDialog, Ui_AddFoundFilesDialog): 16 class AddFoundFilesDialog(QDialog, Ui_AddFoundFilesDialog):
17 """ 17 """
18 Class implementing a dialog to show the found files to the user. 18 Class implementing a dialog to show the found files to the user.
19 19
20 The found files are displayed in a listview. Pressing the 'Add All' button 20 The found files are displayed in a listview. Pressing the 'Add All' button
21 adds all files to the current project, the 'Add Selected' button adds only 21 adds all files to the current project, the 'Add Selected' button adds only
22 the selected files and the 'Cancel' button cancels the operation. 22 the selected files and the 'Cancel' button cancels the operation.
23 """ 23 """
24
24 def __init__(self, files, parent=None, name=None): 25 def __init__(self, files, parent=None, name=None):
25 """ 26 """
26 Constructor 27 Constructor
27 28
28 @param files list of files, that have been found for addition 29 @param files list of files, that have been found for addition
29 (list of strings) 30 (list of strings)
30 @param parent parent widget of this dialog (QWidget) 31 @param parent parent widget of this dialog (QWidget)
31 @param name name of this dialog (string) 32 @param name name of this dialog (string)
32 """ 33 """
33 super().__init__(parent) 34 super().__init__(parent)
34 if name: 35 if name:
35 self.setObjectName(name) 36 self.setObjectName(name)
36 self.setupUi(self) 37 self.setupUi(self)
37 38
38 self.addAllButton = self.buttonBox.addButton( 39 self.addAllButton = self.buttonBox.addButton(
39 self.tr("Add All"), QDialogButtonBox.ButtonRole.AcceptRole) 40 self.tr("Add All"), QDialogButtonBox.ButtonRole.AcceptRole
41 )
40 self.addAllButton.setToolTip(self.tr("Add all files.")) 42 self.addAllButton.setToolTip(self.tr("Add all files."))
41 self.addSelectedButton = self.buttonBox.addButton( 43 self.addSelectedButton = self.buttonBox.addButton(
42 self.tr("Add Selected"), QDialogButtonBox.ButtonRole.AcceptRole) 44 self.tr("Add Selected"), QDialogButtonBox.ButtonRole.AcceptRole
43 self.addSelectedButton.setToolTip( 45 )
44 self.tr("Add selected files only.")) 46 self.addSelectedButton.setToolTip(self.tr("Add selected files only."))
45 47
46 self.fileList.addItems(files) 48 self.fileList.addItems(files)
47 49
48 def on_buttonBox_clicked(self, button): 50 def on_buttonBox_clicked(self, button):
49 """ 51 """
50 Private slot called by a button of the button box clicked. 52 Private slot called by a button of the button box clicked.
51 53
52 @param button button that was clicked (QAbstractButton) 54 @param button button that was clicked (QAbstractButton)
53 """ 55 """
54 if button == self.addAllButton: 56 if button == self.addAllButton:
55 self.on_addAllButton_clicked() 57 self.on_addAllButton_clicked()
56 elif button == self.addSelectedButton: 58 elif button == self.addSelectedButton:
57 self.on_addSelectedButton_clicked() 59 self.on_addSelectedButton_clicked()
58 60
59 @pyqtSlot() 61 @pyqtSlot()
60 def on_addAllButton_clicked(self): 62 def on_addAllButton_clicked(self):
61 """ 63 """
62 Private slot to handle the 'Add All' button press. 64 Private slot to handle the 'Add All' button press.
63 65
64 Always returns the value 1 (integer). 66 Always returns the value 1 (integer).
65 """ 67 """
66 self.done(1) 68 self.done(1)
67 69
68 @pyqtSlot() 70 @pyqtSlot()
69 def on_addSelectedButton_clicked(self): 71 def on_addSelectedButton_clicked(self):
70 """ 72 """
71 Private slot to handle the 'Add Selected' button press. 73 Private slot to handle the 'Add Selected' button press.
72 74
73 Always returns the value 2 (integer). 75 Always returns the value 2 (integer).
74 """ 76 """
75 self.done(2) 77 self.done(2)
76 78
77 def getSelection(self): 79 def getSelection(self):
78 """ 80 """
79 Public method to return the selected items. 81 Public method to return the selected items.
80 82
81 @return list of selected files (list of strings) 83 @return list of selected files (list of strings)
82 """ 84 """
83 list_ = [] 85 list_ = []
84 for itm in self.fileList.selectedItems(): 86 for itm in self.fileList.selectedItems():
85 list_.append(itm.text()) 87 list_.append(itm.text())

eric ide

mercurial