45 if categories: |
45 if categories: |
46 self.categoryComboBox.addItem("") |
46 self.categoryComboBox.addItem("") |
47 self.categoryComboBox.addItems(sorted(categories)) |
47 self.categoryComboBox.addItems(sorted(categories)) |
48 |
48 |
49 self.startdir = startdir |
49 self.startdir = startdir |
|
50 self.uid = "" |
50 |
51 |
51 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
52 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
52 self.__okButton.setEnabled(False) |
53 self.__okButton.setEnabled(False) |
53 |
54 |
54 if project is not None: |
55 if project is not None: |
55 self.setWindowTitle(self.tr("Project Properties")) |
56 self.setWindowTitle(self.tr("Project Properties")) |
56 |
|
57 self.filenameEdit.setReadOnly(True) |
|
58 self.fileButton.setEnabled(False) |
|
59 |
57 |
60 self.nameEdit.setText(project['name']) |
58 self.nameEdit.setText(project['name']) |
61 self.filenameEdit.setText(project['file']) |
59 self.filenameEdit.setText(project['file']) |
62 self.descriptionEdit.setPlainText(project['description']) |
60 self.descriptionEdit.setPlainText(project['description']) |
63 self.masterCheckBox.setChecked(project['master']) |
61 self.masterCheckBox.setChecked(project['master']) |
64 index = self.categoryComboBox.findText(project['category']) |
62 index = self.categoryComboBox.findText(project['category']) |
65 if index == -1: |
63 if index == -1: |
66 index = 0 |
64 index = 0 |
67 self.categoryComboBox.setCurrentIndex(index) |
65 self.categoryComboBox.setCurrentIndex(index) |
|
66 self.uid = project["uid"] |
68 |
67 |
69 @pyqtSlot() |
68 @pyqtSlot() |
70 def on_fileButton_clicked(self): |
69 def on_fileButton_clicked(self): |
71 """ |
70 """ |
72 Private slot to display a file selection dialog. |
71 Private slot to display a file selection dialog. |
73 """ |
72 """ |
74 startdir = self.filenameEdit.text() |
73 startdir = self.filenameEdit.text() |
75 if not startdir and self.startdir is not None: |
74 if startdir or self.startdir is not None: |
76 startdir = self.startdir |
75 if not startdir: |
|
76 startdir = self.startdir |
77 projectFile = E5FileDialog.getOpenFileName( |
77 projectFile = E5FileDialog.getOpenFileName( |
78 self, |
78 self, |
79 self.tr("Add Project"), |
79 self.tr("Add Project"), |
80 startdir, |
80 startdir, |
81 self.tr("Project Files (*.e4p)")) |
81 self.tr("Project Files (*.e4p)")) |
91 @return tuple of five values (string, string, boolean, string, string) |
91 @return tuple of five values (string, string, boolean, string, string) |
92 giving the project name, the name of the project file, a flag |
92 giving the project name, the name of the project file, a flag |
93 telling whether the project shall be the main project, a short |
93 telling whether the project shall be the main project, a short |
94 description for the project and the project category |
94 description for the project and the project category |
95 """ |
95 """ |
|
96 if not self.uid: |
|
97 # new project entry |
|
98 from PyQt4.QtCore import QUuid |
|
99 self.uid = QUuid.createUuid().toString() |
|
100 |
96 return (self.nameEdit.text(), |
101 return (self.nameEdit.text(), |
97 self.filenameEdit.text(), |
102 self.filenameEdit.text(), |
98 self.masterCheckBox.isChecked(), |
103 self.masterCheckBox.isChecked(), |
99 self.descriptionEdit.toPlainText(), |
104 self.descriptionEdit.toPlainText(), |
100 self.categoryComboBox.currentText()) |
105 self.categoryComboBox.currentText(), |
|
106 self.uid) |
101 |
107 |
102 @pyqtSlot(str) |
108 @pyqtSlot(str) |
103 def on_nameEdit_textChanged(self, txt): |
109 def on_nameEdit_textChanged(self, txt): |
104 """ |
110 """ |
105 Private slot called when the project name has changed. |
111 Private slot called when the project name has changed. |