216 break |
216 break |
217 |
217 |
218 if not self.project.closeProject(): |
218 if not self.project.closeProject(): |
219 return |
219 return |
220 |
220 |
221 self.project.pdata["VCS"] = vcsSystem |
221 vcs = self.project.initVCS(vcsSystem) |
222 self.project.vcs = self.project.initVCS(vcsSystem) |
222 if vcs is not None: |
223 if self.project.vcs is not None: |
223 vcsdlg = vcs.vcsNewProjectOptionsDialog() |
224 vcsdlg = self.project.vcs.vcsNewProjectOptionsDialog() |
|
225 if vcsdlg.exec_() == QDialog.Accepted: |
224 if vcsdlg.exec_() == QDialog.Accepted: |
226 projectdir, vcsDataDict = vcsdlg.getData() |
225 projectdir, vcsDataDict = vcsdlg.getData() |
227 # edit VCS command options |
226 # edit VCS command options |
228 if self.project.vcs.vcsSupportCommandOptions(): |
227 if vcs.vcsSupportCommandOptions(): |
229 vcores = E5MessageBox.yesNo( |
228 vcores = E5MessageBox.yesNo( |
230 self.parent(), |
229 self.parent(), |
231 QCoreApplication.translate( |
230 QCoreApplication.translate( |
232 "VcsProjectHelper", "New Project"), |
231 "VcsProjectHelper", "New Project"), |
233 QCoreApplication.translate( |
232 QCoreApplication.translate( |
238 vcores = False |
237 vcores = False |
239 if vcores: |
238 if vcores: |
240 from .CommandOptionsDialog import VcsCommandOptionsDialog |
239 from .CommandOptionsDialog import VcsCommandOptionsDialog |
241 codlg = VcsCommandOptionsDialog(self.project.vcs) |
240 codlg = VcsCommandOptionsDialog(self.project.vcs) |
242 if codlg.exec_() == QDialog.Accepted: |
241 if codlg.exec_() == QDialog.Accepted: |
243 self.project.vcs.vcsSetOptions(codlg.getOptions()) |
242 vcs.vcsSetOptions(codlg.getOptions()) |
244 |
243 |
245 # create the project directory if it doesn't exist already |
244 # create the project directory if it doesn't exist already |
246 if not os.path.isdir(projectdir): |
245 if not os.path.isdir(projectdir): |
247 try: |
246 try: |
248 os.makedirs(projectdir) |
247 os.makedirs(projectdir) |
254 "Create project directory"), |
253 "Create project directory"), |
255 QCoreApplication.translate( |
254 QCoreApplication.translate( |
256 "VcsProjectHelper", |
255 "VcsProjectHelper", |
257 "<p>The project directory <b>{0}</b> could not" |
256 "<p>The project directory <b>{0}</b> could not" |
258 " be created.</p>").format(projectdir)) |
257 " be created.</p>").format(projectdir)) |
259 self.project.pdata["VCS"] = 'None' |
|
260 self.project.vcs = self.project.initVCS() |
|
261 return |
258 return |
262 |
259 |
263 # create the project from the VCS |
260 # create the project from the VCS |
264 self.project.vcs.vcsSetDataFromDict(vcsDataDict) |
261 vcs.vcsSetDataFromDict(vcsDataDict) |
265 if export: |
262 if export: |
266 ok = self.project.vcs.vcsExport(vcsDataDict, projectdir) |
263 ok = vcs.vcsExport(vcsDataDict, projectdir) |
267 else: |
264 else: |
268 ok = self.project.vcs.vcsCheckout(vcsDataDict, projectdir, |
265 ok = vcs.vcsCheckout(vcsDataDict, projectdir, |
269 False) |
266 False) |
270 if ok: |
267 if ok: |
271 projectdir = os.path.normpath(projectdir) |
268 projectdir = os.path.normpath(projectdir) |
272 filters = ["*.e4p"] |
269 filters = ["*.e4p"] |
273 d = QDir(projectdir) |
270 d = QDir(projectdir) |
274 plist = d.entryInfoList(filters) |
271 plist = d.entryInfoList(filters) |
275 if len(plist): |
272 if len(plist): |
276 if len(plist) == 1: |
273 if len(plist) == 1: |
277 self.project.openProject( |
274 self.project.openProject( |
278 plist[0].absoluteFilePath()) |
275 plist[0].absoluteFilePath()) |
279 self.project.newProject.emit() |
|
280 else: |
276 else: |
281 pfilenamelist = d.entryList(filters) |
277 pfilenamelist = d.entryList(filters) |
282 pfilename, ok = QInputDialog.getItem( |
278 pfilename, ok = QInputDialog.getItem( |
283 None, |
279 None, |
284 QCoreApplication.translate( |
280 QCoreApplication.translate( |
289 "Select a project file to open."), |
285 "Select a project file to open."), |
290 pfilenamelist, 0, False) |
286 pfilenamelist, 0, False) |
291 if ok: |
287 if ok: |
292 self.project.openProject( |
288 self.project.openProject( |
293 QFileInfo(d, pfilename).absoluteFilePath()) |
289 QFileInfo(d, pfilename).absoluteFilePath()) |
294 self.project.newProject.emit() |
|
295 if export: |
290 if export: |
296 self.project.pdata["VCS"] = 'None' |
291 self.project.pdata["VCS"] = 'None' |
297 self.project.vcs = self.project.initVCS() |
292 self.project.vcs = self.project.initVCS() |
298 self.project.setDirty(True) |
293 self.project.setDirty(True) |
299 self.project.saveProject() |
294 self.project.saveProject() |
317 PropertiesDialog |
312 PropertiesDialog |
318 dlg = PropertiesDialog(self.project, False) |
313 dlg = PropertiesDialog(self.project, False) |
319 if dlg.exec_() == QDialog.Accepted: |
314 if dlg.exec_() == QDialog.Accepted: |
320 dlg.storeData() |
315 dlg.storeData() |
321 self.project.initFileTypes() |
316 self.project.initFileTypes() |
|
317 self.project.pdata["VCS"] = vcsSystem |
322 self.project.setDirty(True) |
318 self.project.setDirty(True) |
323 try: |
319 if self.project.pdata["MAINSCRIPT"]: |
324 ms = os.path.join( |
320 ms = os.path.join( |
325 self.project.ppath, |
321 self.project.ppath, |
326 self.project.pdata["MAINSCRIPT"]) |
322 self.project.pdata["MAINSCRIPT"]) |
327 if os.path.exists(ms): |
323 if os.path.exists(ms): |
328 self.project.appendFile(ms) |
324 self.project.appendFile(ms) |
329 except IndexError: |
325 else: |
330 ms = "" |
326 ms = "" |
331 self.project.newProjectAddFiles(ms) |
327 self.project.newProjectAddFiles(ms) |
332 self.project.createProjectManagementDir() |
328 self.project.createProjectManagementDir() |
333 self.project.saveProject() |
329 self.project.saveProject() |
334 self.project.openProject(self.project.pfile) |
330 self.project.openProject(self.project.pfile) |
353 "VcsProjectHelper", "New project from repository"), |
349 "VcsProjectHelper", "New project from repository"), |
354 QCoreApplication.translate( |
350 QCoreApplication.translate( |
355 "VcsProjectHelper", |
351 "VcsProjectHelper", |
356 """The project could not be retrieved from""" |
352 """The project could not be retrieved from""" |
357 """ the repository.""")) |
353 """ the repository.""")) |
358 self.project.pdata["VCS"] = 'None' |
|
359 self.project.vcs = self.project.initVCS() |
|
360 else: |
|
361 self.project.pdata["VCS"] = 'None' |
|
362 self.project.vcs = self.project.initVCS() |
|
363 |
354 |
364 def _vcsExport(self): |
355 def _vcsExport(self): |
365 """ |
356 """ |
366 Protected slot used to export a project from the repository. |
357 Protected slot used to export a project from the repository. |
367 """ |
358 """ |