Project/NewDialogClassDialog.py

changeset 0
de9c2efb9d02
child 6
52e8c820d0dd
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to ente the data for a new dialog class file.
8 """
9
10 import os
11
12 from PyQt4.QtCore import *
13 from PyQt4.QtGui import *
14
15 from E4Gui.E4Completers import E4DirCompleter
16
17 from Ui_NewDialogClassDialog import Ui_NewDialogClassDialog
18
19 class NewDialogClassDialog(QDialog, Ui_NewDialogClassDialog):
20 """
21 Class implementing a dialog to ente the data for a new dialog class file.
22 """
23 def __init__(self, defaultClassName, defaultFile, defaultPath, parent = None):
24 """
25 Constructor
26
27 @param defaultClassName proposed name for the new class (string)
28 @param defaultFile proposed name for the source file (string)
29 @param defaultPath default path for the new file (string)
30 @param parent parent widget if the dialog (QWidget)
31 """
32 QDialog.__init__(self, parent)
33 self.setupUi(self)
34
35 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
36 self.okButton.setEnabled(False)
37
38 self.pathnameCompleter = E4DirCompleter(self.pathnameEdit)
39
40 self.classnameEdit.setText(defaultClassName)
41 self.filenameEdit.setText(defaultFile)
42 self.pathnameEdit.setText(QDir.toNativeSeparators(defaultPath))
43
44 @pyqtSlot()
45 def on_pathButton_clicked(self):
46 """
47 Private slot called to open a directory selection dialog.
48 """
49 path = QFileDialog.getExistingDirectory(\
50 self,
51 self.trUtf8("Select source directory"),
52 QDir.fromNativeSeparators(self.pathnameEdit.text()),
53 QFileDialog.Options(QFileDialog.Option(0)))
54 if path:
55 self.pathnameEdit.setText(QDir.toNativeSeparators(path))
56
57 def __enableOkButton(self):
58 """
59 Private slot to set the enable state of theok button.
60 """
61 self.okButton.setEnabled(\
62 self.classnameEdit.text() != "" and \
63 self.filenameEdit.text() != "" and \
64 self.pathnameEdit.text() != "")
65
66 def on_classnameEdit_textChanged(self, text):
67 """
68 Private slot called, when thext of the classname edit has changed.
69
70 @param text changed text (string)
71 """
72 self.__enableOkButton()
73
74 def on_filenameEdit_textChanged(self, text):
75 """
76 Private slot called, when thext of the filename edit has changed.
77
78 @param text changed text (string)
79 """
80 self.__enableOkButton()
81
82 def on_pathnameEdit_textChanged(self, text):
83 """
84 Private slot called, when thext of the pathname edit has changed.
85
86 @param text changed text (string)
87 """
88 self.__enableOkButton()
89
90 def getData(self):
91 """
92 Public method to retrieve the data entered into the dialog.
93
94 @return tuple giving the classname (string) and the file name (string)
95 """
96 return unicode(self.classnameEdit.text()), \
97 os.path.join(self.pathnameEdit.text(), \
98 self.filenameEdit.text())

eric ide

mercurial