1105 "<p>The project session file <b>{0}</b> could" |
1107 "<p>The project session file <b>{0}</b> could" |
1106 " not be deleted.</p>").format(fn)) |
1108 " not be deleted.</p>").format(fn)) |
1107 |
1109 |
1108 def __readTasks(self): |
1110 def __readTasks(self): |
1109 """ |
1111 """ |
1110 Private method to read in the project tasks file (.e6t). |
1112 Private method to read in the project tasks file (.etj or .e6t). |
1111 """ |
1113 """ |
1112 if self.pfile is None: |
1114 if self.pfile is None: |
1113 E5MessageBox.critical( |
1115 E5MessageBox.critical( |
1114 self.ui, |
1116 self.ui, |
1115 self.tr("Read Tasks"), |
1117 self.tr("Read Tasks"), |
1116 self.tr("Please save the project first.")) |
1118 self.tr("Please save the project first.")) |
1117 return |
1119 return |
1118 |
1120 |
1119 # TODO: read project tasks |
|
1120 base, ext = os.path.splitext(os.path.basename(self.pfile)) |
1121 base, ext = os.path.splitext(os.path.basename(self.pfile)) |
1121 fn = os.path.join(self.getProjectManagementDir(), |
1122 fn = os.path.join(self.getProjectManagementDir(), |
1122 '{0}.e6t'.format(base)) |
1123 '{0}.etj'.format(base)) |
1123 if not os.path.exists(fn): |
1124 if os.path.exists(fn): |
1124 # try again with the old extension |
1125 # try new style JSON file first |
|
1126 self.__tasksFile.readFile(fn) |
|
1127 else: |
|
1128 # try old style XML file second |
1125 fn = os.path.join(self.getProjectManagementDir(), |
1129 fn = os.path.join(self.getProjectManagementDir(), |
1126 '{0}.e4t'.format(base)) |
1130 '{0}.e6t'.format(base)) |
1127 if not os.path.exists(fn): |
1131 if os.path.exists(fn): |
1128 return |
1132 f = QFile(fn) |
1129 f = QFile(fn) |
1133 if f.open(QIODevice.ReadOnly): |
1130 if f.open(QIODevice.ReadOnly): |
1134 from E5XML.TasksReader import TasksReader |
1131 from E5XML.TasksReader import TasksReader |
1135 reader = TasksReader(f, True) |
1132 reader = TasksReader(f, True) |
1136 reader.readXML() |
1133 reader.readXML() |
1137 f.close() |
1134 f.close() |
1138 else: |
1135 else: |
1139 E5MessageBox.critical( |
1136 E5MessageBox.critical( |
1140 self.ui, |
1137 self.ui, |
1141 self.tr("Read Tasks"), |
1138 self.tr("Read Tasks"), |
1142 self.tr( |
1139 self.tr( |
1143 "<p>The tasks file <b>{0}</b> could not be read." |
1140 "<p>The tasks file <b>{0}</b> could not be read.</p>") |
1144 "</p>") |
1141 .format(fn)) |
1145 .format(fn)) |
1142 |
1146 |
1143 def writeTasks(self): |
1147 def writeTasks(self): |
1144 """ |
1148 """ |
1145 Public method to write the tasks data to an XML file (.e6t). |
1149 Public method to write the tasks data to an JSON file (.etj). |
1146 """ |
1150 """ |
1147 if self.pfile is None: |
1151 if self.pfile is None: |
1148 return |
1152 return |
1149 |
1153 |
1150 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1154 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1151 |
1155 |
1152 # TODO: write project tasks |
1156 fn = os.path.join(self.getProjectManagementDir(), |
1153 fn = os.path.join(self.getProjectManagementDir(), '{0}.e6t'.format(fn)) |
1157 '{0}.etj'.format(fn)) |
1154 f = QFile(fn) |
1158 self.__tasksFile.writeFile(fn) |
1155 ok = f.open(QIODevice.WriteOnly) |
1159 |
1156 if not ok: |
|
1157 E5MessageBox.critical( |
|
1158 self.ui, |
|
1159 self.tr("Save Tasks"), |
|
1160 self.tr( |
|
1161 "<p>The tasks file <b>{0}</b> could not be written.</p>") |
|
1162 .format(fn)) |
|
1163 return |
|
1164 |
|
1165 from E5XML.TasksWriter import TasksWriter |
|
1166 TasksWriter( |
|
1167 f, True, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
|
1168 f.close() |
|
1169 |
|
1170 def __showContextMenuDebugger(self): |
1160 def __showContextMenuDebugger(self): |
1171 """ |
1161 """ |
1172 Private slot called before the Debugger menu is shown. |
1162 Private slot called before the Debugger menu is shown. |
1173 """ |
1163 """ |
1174 enable = True |
1164 enable = True |