MultiProject/AddProjectDialog.py

changeset 3197
4103c8013c36
parent 3190
a9a94491c4fd
child 3484
645c12de6b0c
equal deleted inserted replaced
3196:cfc025de587c 3197:4103c8013c36
21 21
22 class AddProjectDialog(QDialog, Ui_AddProjectDialog): 22 class AddProjectDialog(QDialog, Ui_AddProjectDialog):
23 """ 23 """
24 Class implementing the add project dialog. 24 Class implementing the add project dialog.
25 """ 25 """
26 def __init__(self, parent=None, startdir=None, project=None): 26 def __init__(self, parent=None, startdir=None, project=None,
27 categories=None):
27 """ 28 """
28 Constructor 29 Constructor
29 30
30 @param parent parent widget of this dialog (QWidget) 31 @param parent parent widget of this dialog (QWidget)
31 @param startdir start directory for the selection dialog (string) 32 @param startdir start directory for the selection dialog (string)
32 @param project dictionary containing project data 33 @param project dictionary containing project data
34 @param categories list of already used categories (list of string)
33 """ 35 """
34 super().__init__(parent) 36 super().__init__(parent)
35 self.setupUi(self) 37 self.setupUi(self)
36 38
37 self.fileButton.setIcon(UI.PixmapCache.getIcon("open.png")) 39 self.fileButton.setIcon(UI.PixmapCache.getIcon("open.png"))
38 40
39 self.fileCompleter = E5FileCompleter(self.filenameEdit) 41 self.fileCompleter = E5FileCompleter(self.filenameEdit)
42
43 if categories:
44 self.categoryComboBox.addItem("")
45 self.categoryComboBox.addItems(sorted(categories))
40 46
41 self.startdir = startdir 47 self.startdir = startdir
42 48
43 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) 49 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
44 self.__okButton.setEnabled(False) 50 self.__okButton.setEnabled(False)
51 57
52 self.nameEdit.setText(project['name']) 58 self.nameEdit.setText(project['name'])
53 self.filenameEdit.setText(project['file']) 59 self.filenameEdit.setText(project['file'])
54 self.descriptionEdit.setPlainText(project['description']) 60 self.descriptionEdit.setPlainText(project['description'])
55 self.masterCheckBox.setChecked(project['master']) 61 self.masterCheckBox.setChecked(project['master'])
62 index = self.categoryComboBox.findText(project['category'])
63 if index == -1:
64 index = 0
65 self.categoryComboBox.setCurrentIndex(index)
56 66
57 @pyqtSlot() 67 @pyqtSlot()
58 def on_fileButton_clicked(self): 68 def on_fileButton_clicked(self):
59 """ 69 """
60 Private slot to display a file selection dialog. 70 Private slot to display a file selection dialog.
74 84
75 def getData(self): 85 def getData(self):
76 """ 86 """
77 Public slot to retrieve the dialogs data. 87 Public slot to retrieve the dialogs data.
78 88
79 @return tuple of four values (string, string, boolean, string) giving 89 @return tuple of five values (string, string, boolean, string, string)
80 the project name, the name of the project file, a flag telling, 90 giving the project name, the name of the project file, a flag
81 whether the project shall be the main project and a short 91 telling whether the project shall be the main project, a short
82 description for the project 92 description for the project and the project category
83 """ 93 """
84 return (self.nameEdit.text(), self.filenameEdit.text(), 94 return (self.nameEdit.text(),
95 self.filenameEdit.text(),
85 self.masterCheckBox.isChecked(), 96 self.masterCheckBox.isChecked(),
86 self.descriptionEdit.toPlainText()) 97 self.descriptionEdit.toPlainText(),
98 self.categoryComboBox.currentText())
87 99
88 @pyqtSlot(str) 100 @pyqtSlot(str)
89 def on_nameEdit_textChanged(self, txt): 101 def on_nameEdit_textChanged(self, txt):
90 """ 102 """
91 Private slot called when the project name has changed. 103 Private slot called when the project name has changed.

eric ide

mercurial