64 self.__okButton.setEnabled(False) |
65 self.__okButton.setEnabled(False) |
65 |
66 |
66 if project is not None: |
67 if project is not None: |
67 self.setWindowTitle(self.tr("Project Properties")) |
68 self.setWindowTitle(self.tr("Project Properties")) |
68 |
69 |
69 self.nameEdit.setText(project["name"]) |
70 self.nameEdit.setText(project.name) |
70 self.filenamePicker.setText(project["file"]) |
71 self.filenamePicker.setText(project.file) |
71 self.descriptionEdit.setPlainText(project["description"]) |
72 self.descriptionEdit.setPlainText(project.description) |
72 self.mainCheckBox.setChecked(project["master"]) |
73 self.mainCheckBox.setChecked(project.master) |
73 index = self.categoryComboBox.findText(project["category"]) |
74 index = self.categoryComboBox.findText(project.category) |
74 if index == -1: |
75 if index == -1: |
75 index = 0 |
76 index = 0 |
76 self.categoryComboBox.setCurrentIndex(index) |
77 self.categoryComboBox.setCurrentIndex(index) |
77 self.uid = project["uid"] |
78 self.uid = project.uid |
78 |
79 |
79 def getData(self): |
80 def getProjectMetadata(self): |
80 """ |
81 """ |
81 Public slot to retrieve the dialogs data. |
82 Public method to get the entered project metadata. |
82 |
83 |
83 @return tuple of five values giving the project name, the name of the project |
84 @return project metadata iaw. the entered values |
84 file, a flag telling whether the project shall be the main project, a short |
85 @rtype MultiProjectProjectMeta |
85 description for the project and the project category |
|
86 @rtype tuple of (str, str, bool, str, str) |
|
87 """ |
86 """ |
88 if not self.uid: |
87 if not self.uid: |
89 # new project entry |
88 # new project entry |
90 self.uid = QUuid.createUuid().toString() |
89 self.uid = QUuid.createUuid().toString() |
91 |
90 |
|
91 return MultiProjectProjectMeta( |
|
92 name=self.nameEdit.text(), |
|
93 file=self.__getFileName(), |
|
94 uid=self.uid, |
|
95 master=self.mainCheckBox.isChecked(), |
|
96 description=self.descriptionEdit.toPlainText(), |
|
97 category=self.categoryComboBox.currentText(), |
|
98 ) |
|
99 |
|
100 def __getFileName(self): |
|
101 """ |
|
102 Private method to get the file name of the project file. |
|
103 |
|
104 @return project file name |
|
105 @rtype str |
|
106 """ |
92 filename = self.filenamePicker.text() |
107 filename = self.filenamePicker.text() |
93 if not os.path.isabs(filename): |
108 if not os.path.isabs(filename): |
94 filename = FileSystemUtilities.toNativeSeparators( |
109 filename = FileSystemUtilities.toNativeSeparators( |
95 os.path.join(self.startdir, filename) |
110 os.path.join(self.startdir, filename) |
96 ) |
111 ) |
97 return ( |
112 return filename |
98 self.nameEdit.text(), |
|
99 filename, |
|
100 self.mainCheckBox.isChecked(), |
|
101 self.descriptionEdit.toPlainText(), |
|
102 self.categoryComboBox.currentText(), |
|
103 self.uid, |
|
104 ) |
|
105 |
113 |
106 @pyqtSlot(str) |
114 @pyqtSlot(str) |
107 def on_nameEdit_textChanged(self, txt): |
115 def on_nameEdit_textChanged(self, txt): |
108 """ |
116 """ |
109 Private slot called when the project name has changed. |
117 Private slot called when the project name has changed. |