Project/Project.py

changeset 608
d8fea1e76975
parent 607
d95d60ba16aa
child 609
463fc2891cbf
child 610
3a625b0793d8
equal deleted inserted replaced
607:d95d60ba16aa 608:d8fea1e76975
566 self.pdata[index].remove(file) 566 self.pdata[index].remove(file)
567 self.setDirty(True) 567 self.setDirty(True)
568 568
569 def __readProject(self, fn): 569 def __readProject(self, fn):
570 """ 570 """
571 Private method to read in a project (.e4p, .e4pz) file. 571 Private method to read in a project (.e4p) file.
572 572
573 @param fn filename of the project file to be read (string) 573 @param fn filename of the project file to be read (string)
574 @return flag indicating success 574 @return flag indicating success
575 """ 575 """
576 try: 576 try:
928 self.trUtf8("Please save the project first.")) 928 self.trUtf8("Please save the project first."))
929 return 929 return
930 930
931 fname, ext = os.path.splitext(os.path.basename(self.pfile)) 931 fname, ext = os.path.splitext(os.path.basename(self.pfile))
932 932
933 for fn in [os.path.join(self.getProjectManagementDir(), "{0}.e4sz".format(fname)), 933 for fn in [os.path.join(self.getProjectManagementDir(), "{0}.e4s".format(fname))]:
934 os.path.join(self.getProjectManagementDir(), "{0}.e4s".format(fname))]:
935 if os.path.exists(fn): 934 if os.path.exists(fn):
936 try: 935 try:
937 os.remove(fn) 936 os.remove(fn)
938 except OSError: 937 except OSError:
939 E5MessageBox.critical(self.ui, 938 E5MessageBox.critical(self.ui,
1058 self.trUtf8("Please save the project first.")) 1057 self.trUtf8("Please save the project first."))
1059 return 1058 return
1060 1059
1061 fname, ext = os.path.splitext(os.path.basename(self.pfile)) 1060 fname, ext = os.path.splitext(os.path.basename(self.pfile))
1062 1061
1063 for fn in [os.path.join(self.getProjectManagementDir(), "{0}.e4dz".format(fname)), 1062 for fn in [os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fname))]:
1064 os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fname))]:
1065 if os.path.exists(fn): 1063 if os.path.exists(fn):
1066 try: 1064 try:
1067 os.remove(fn) 1065 os.remove(fn)
1068 except OSError: 1066 except OSError:
1069 E5MessageBox.critical(self.ui, 1067 E5MessageBox.critical(self.ui,
2321 if fn is None: 2319 if fn is None:
2322 fn = QFileDialog.getOpenFileName( 2320 fn = QFileDialog.getOpenFileName(
2323 self.parent(), 2321 self.parent(),
2324 self.trUtf8("Open project"), 2322 self.trUtf8("Open project"),
2325 "", 2323 "",
2326 self.trUtf8("Project Files (*.e4p *.e4pz)")) 2324 self.trUtf8("Project Files (*.e4p)"))
2327 2325
2328 QApplication.processEvents() 2326 QApplication.processEvents()
2329 2327
2330 if fn: 2328 if fn:
2331 if self.closeProject(): 2329 if self.closeProject():
2477 """ 2475 """
2478 Public slot to save the current project to a different file. 2476 Public slot to save the current project to a different file.
2479 2477
2480 @return flag indicating success (boolean) 2478 @return flag indicating success (boolean)
2481 """ 2479 """
2482 if Preferences.getProject("CompressedProjectFiles"): 2480 defaultFilter = self.trUtf8("Project Files (*.e4p)")
2483 defaultFilter = self.trUtf8("Compressed Project Files (*.e4pz)")
2484 else:
2485 defaultFilter = self.trUtf8("Project Files (*.e4p)")
2486 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 2481 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
2487 self.parent(), 2482 self.parent(),
2488 self.trUtf8("Save project as"), 2483 self.trUtf8("Save project as"),
2489 self.ppath, 2484 self.ppath,
2490 self.trUtf8("Project Files (*.e4p);;" 2485 self.trUtf8("Project Files (*.e4p)"),
2491 "Compressed Project Files (*.e4pz)"),
2492 defaultFilter, 2486 defaultFilter,
2493 QFileDialog.Options(QFileDialog.DontConfirmOverwrite)) 2487 QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
2494 2488
2495 if fn: 2489 if fn:
2496 ext = QFileInfo(fn).suffix() 2490 ext = QFileInfo(fn).suffix()

eric ide

mercurial