|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2004 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to confirm deletion of multiple files. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QDialog, QDialogButtonBox |
|
11 |
|
12 from Ui_DeleteFilesConfirmationDialog import Ui_DeleteFilesConfirmationDialog |
|
13 |
|
14 |
|
15 class DeleteFilesConfirmationDialog(QDialog, Ui_DeleteFilesConfirmationDialog): |
|
16 """ |
|
17 Class implementing a dialog to confirm deletion of multiple files. |
|
18 """ |
|
19 def __init__(self, parent, caption, message, files): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param parent parent of this dialog (QWidget) |
|
24 @param caption window title for the dialog (string) |
|
25 @param message message to be shown (string) |
|
26 @param okLabel label for the OK button (string) |
|
27 @param cancelLabel label for the Cancel button (string) |
|
28 @param files list of filenames to be shown (list of strings) |
|
29 """ |
|
30 QDialog.__init__(self,parent) |
|
31 self.setupUi(self) |
|
32 self.setModal(True) |
|
33 |
|
34 self.buttonBox.button(QDialogButtonBox.Yes).setAutoDefault(False) |
|
35 self.buttonBox.button(QDialogButtonBox.No).setDefault(True) |
|
36 self.buttonBox.button(QDialogButtonBox.No).setFocus() |
|
37 |
|
38 self.setWindowTitle(caption) |
|
39 self.message.setText(message) |
|
40 |
|
41 self.filesList.addItems(files) |
|
42 |
|
43 def on_buttonBox_clicked(self, button): |
|
44 """ |
|
45 Private slot called by a button of the button box clicked. |
|
46 |
|
47 @param button button that was clicked (QAbstractButton) |
|
48 """ |
|
49 if button == self.buttonBox.button(QDialogButtonBox.Yes): |
|
50 self.accept() |
|
51 elif button == self.buttonBox.button(QDialogButtonBox.No): |
|
52 self.reject() |