Project/AddFoundFilesDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2009 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 PyQt4.QtCore import *
11 from PyQt4.QtGui import *
12
13 from Ui_AddFoundFilesDialog import Ui_AddFoundFilesDialog
14
15 class AddFoundFilesDialog(QDialog, Ui_AddFoundFilesDialog):
16 """
17 Class implementing a dialog to show the found files to the user.
18
19 The found files are displayed in a listview.
20 Pressing the 'Add All' button adds all files to the current project,
21 the 'Add Selected' button adds only the selected files and the 'Cancel'
22 button cancels the operation.
23 """
24
25 def __init__(self, files, parent = None, name = None):
26 """
27 Constructor
28
29 @param files list of files, that have been found for addition (list of strings)
30 @param parent parent widget of this dialog (QWidget)
31 @param name name of this dialog (string)
32 """
33 QDialog.__init__(self, parent)
34 if name:
35 self.setObjectName(name)
36 self.setupUi(self)
37
38 self.addAllButton = self.buttonBox.addButton(\
39 self.trUtf8("Add All"), QDialogButtonBox.AcceptRole)
40 self.addAllButton.setToolTip(self.trUtf8("Add all files."))
41 self.addSelectedButton = self.buttonBox.addButton(\
42 self.trUtf8("Add Selected"), QDialogButtonBox.AcceptRole)
43 self.addSelectedButton.setToolTip(self.trUtf8("Add selected files only."))
44
45 self.fileList.addItems(files)
46
47 def on_buttonBox_clicked(self, button):
48 """
49 Private slot called by a button of the button box clicked.
50
51 @param button button that was clicked (QAbstractButton)
52 """
53 if button == self.addAllButton:
54 self.on_addAllButton_clicked()
55 elif button == self.addSelectedButton:
56 self.on_addSelectedButton_clicked()
57
58 @pyqtSlot()
59 def on_addAllButton_clicked(self):
60 """
61 Private slot to handle the 'Add All' button press.
62
63 @return always 1 (int)
64 """
65 self.done(1)
66
67 @pyqtSlot()
68 def on_addSelectedButton_clicked(self):
69 """
70 Private slot to handle the 'Add Selected' button press.
71
72 @return always 2 (int)
73 """
74 self.done(2)
75
76 def getSelection(self):
77 """
78 Public method to return the selected items.
79
80 @return list of selected files (list of strings)
81 """
82 list_ = []
83 for itm in self.fileList.selectedItems():
84 list_.append(itm.text())
85 return list_

eric ide

mercurial