eric6/Project/AddFoundFilesDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show the found files to the user.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
14
15 from .Ui_AddFoundFilesDialog import Ui_AddFoundFilesDialog
16
17
18 class AddFoundFilesDialog(QDialog, Ui_AddFoundFilesDialog):
19 """
20 Class implementing a dialog to show the found files to the user.
21
22 The found files are displayed in a listview. Pressing the 'Add All' button
23 adds all files to the current project, the 'Add Selected' button adds only
24 the selected files and the 'Cancel' button cancels the operation.
25 """
26 def __init__(self, files, parent=None, name=None):
27 """
28 Constructor
29
30 @param files list of files, that have been found for addition
31 (list of strings)
32 @param parent parent widget of this dialog (QWidget)
33 @param name name of this dialog (string)
34 """
35 super(AddFoundFilesDialog, self).__init__(parent)
36 if name:
37 self.setObjectName(name)
38 self.setupUi(self)
39
40 self.addAllButton = self.buttonBox.addButton(
41 self.tr("Add All"), QDialogButtonBox.AcceptRole)
42 self.addAllButton.setToolTip(self.tr("Add all files."))
43 self.addSelectedButton = self.buttonBox.addButton(
44 self.tr("Add Selected"), QDialogButtonBox.AcceptRole)
45 self.addSelectedButton.setToolTip(
46 self.tr("Add selected files only."))
47
48 self.fileList.addItems(files)
49
50 def on_buttonBox_clicked(self, button):
51 """
52 Private slot called by a button of the button box clicked.
53
54 @param button button that was clicked (QAbstractButton)
55 """
56 if button == self.addAllButton:
57 self.on_addAllButton_clicked()
58 elif button == self.addSelectedButton:
59 self.on_addSelectedButton_clicked()
60
61 @pyqtSlot()
62 def on_addAllButton_clicked(self):
63 """
64 Private slot to handle the 'Add All' button press.
65
66 Always returns the value 1 (integer).
67 """
68 self.done(1)
69
70 @pyqtSlot()
71 def on_addSelectedButton_clicked(self):
72 """
73 Private slot to handle the 'Add Selected' button press.
74
75 Always returns the value 2 (integer).
76 """
77 self.done(2)
78
79 def getSelection(self):
80 """
81 Public method to return the selected items.
82
83 @return list of selected files (list of strings)
84 """
85 list_ = []
86 for itm in self.fileList.selectedItems():
87 list_.append(itm.text())
88 return list_

eric ide

mercurial