84 self.pfile = "" # name of the multi project file |
85 self.pfile = "" # name of the multi project file |
85 self.ppath = "" # name of the multi project directory |
86 self.ppath = "" # name of the multi project directory |
86 self.description = "" # description of the multi project |
87 self.description = "" # description of the multi project |
87 self.name = "" |
88 self.name = "" |
88 self.opened = False |
89 self.opened = False |
89 self.projects = [] # list of project info; each info entry is a dictionary |
90 self.projects = [] # list of project info; each info entry is |
|
91 # a dictionary |
90 # 'name' : Name of the project |
92 # 'name' : Name of the project |
91 # 'file' : project filename |
93 # 'file' : project filename |
92 # 'master' : flag indicating the master project |
94 # 'master' : flag indicating the master |
|
95 # project |
93 # 'description' : description of the project |
96 # 'description' : description of the project |
94 |
97 |
95 def __loadRecent(self): |
98 def __loadRecent(self): |
96 """ |
99 """ |
97 Private method to load the recently opened multi project filenames. |
100 Private method to load the recently opened multi project filenames. |
106 |
109 |
107 def __saveRecent(self): |
110 def __saveRecent(self): |
108 """ |
111 """ |
109 Private method to save the list of recently opened filenames. |
112 Private method to save the list of recently opened filenames. |
110 """ |
113 """ |
111 Preferences.Prefs.rsettings.setValue(recentNameMultiProject, self.recent) |
114 Preferences.Prefs.rsettings.setValue( |
|
115 recentNameMultiProject, self.recent) |
112 Preferences.Prefs.rsettings.sync() |
116 Preferences.Prefs.rsettings.sync() |
113 |
117 |
114 def getMostRecent(self): |
118 def getMostRecent(self): |
115 """ |
119 """ |
116 Public method to get the most recently opened multiproject. |
120 Public method to get the most recently opened multiproject. |
201 return False |
205 return False |
202 else: |
206 else: |
203 QApplication.restoreOverrideCursor() |
207 QApplication.restoreOverrideCursor() |
204 E5MessageBox.critical(self.ui, |
208 E5MessageBox.critical(self.ui, |
205 self.trUtf8("Read multiproject file"), |
209 self.trUtf8("Read multiproject file"), |
206 self.trUtf8("<p>The multiproject file <b>{0}</b> could not be read.</p>")\ |
210 self.trUtf8( |
207 .format(fn)) |
211 "<p>The multiproject file <b>{0}</b> could not be" |
|
212 " read.</p>").format(fn)) |
208 return False |
213 return False |
209 |
214 |
210 self.pfile = os.path.abspath(fn) |
215 self.pfile = os.path.abspath(fn) |
211 self.ppath = os.path.abspath(os.path.dirname(fn)) |
216 self.ppath = os.path.abspath(os.path.dirname(fn)) |
212 |
217 |
223 def __writeMultiProject(self, fn=None): |
228 def __writeMultiProject(self, fn=None): |
224 """ |
229 """ |
225 Private method to save the multi project infos to a multi project file. |
230 Private method to save the multi project infos to a multi project file. |
226 |
231 |
227 @param fn optional filename of the multi project file to be written. |
232 @param fn optional filename of the multi project file to be written. |
228 If fn is None, the filename stored in the multi project object |
233 If fn is None, the filename stored in the multi project object |
229 is used. This is the 'save' action. If fn is given, this filename |
234 is used. This is the 'save' action. If fn is given, this filename |
230 is used instead of the one in the multi project object. This is the |
235 is used instead of the one in the multi project object. This is the |
231 'save as' action. |
236 'save as' action. |
232 @return flag indicating success |
237 @return flag indicating success |
233 """ |
238 """ |
234 if fn is None: |
239 if fn is None: |
235 fn = self.pfile |
240 fn = self.pfile |
236 |
241 |
237 f = QFile(fn) |
242 f = QFile(fn) |
238 if f.open(QIODevice.WriteOnly): |
243 if f.open(QIODevice.WriteOnly): |
239 from E5XML.MultiProjectWriter import MultiProjectWriter |
244 from E5XML.MultiProjectWriter import MultiProjectWriter |
240 MultiProjectWriter(f, self, os.path.splitext(os.path.basename(fn))[0])\ |
245 MultiProjectWriter( |
|
246 f, self, os.path.splitext(os.path.basename(fn))[0])\ |
241 .writeXML() |
247 .writeXML() |
242 res = True |
248 res = True |
243 else: |
249 else: |
244 E5MessageBox.critical(self.ui, |
250 E5MessageBox.critical(self.ui, |
245 self.trUtf8("Save multiproject file"), |
251 self.trUtf8("Save multiproject file"), |
347 |
353 |
348 def removeProject(self, fn): |
354 def removeProject(self, fn): |
349 """ |
355 """ |
350 Public slot to remove a project from the multi project. |
356 Public slot to remove a project from the multi project. |
351 |
357 |
352 @param fn filename of the project to be removed from the multi project (string) |
358 @param fn filename of the project to be removed from the multi |
|
359 project (string) |
353 """ |
360 """ |
354 for project in self.projects: |
361 for project in self.projects: |
355 if project['file'] == fn: |
362 if project['file'] == fn: |
356 self.projects.remove(project) |
363 self.projects.remove(project) |
357 self.projectRemoved.emit(project) |
364 self.projectRemoved.emit(project) |
394 |
401 |
395 def openMultiProject(self, fn=None, openMaster=True): |
402 def openMultiProject(self, fn=None, openMaster=True): |
396 """ |
403 """ |
397 Public slot to open a multi project. |
404 Public slot to open a multi project. |
398 |
405 |
399 @param fn optional filename of the multi project file to be read (string) |
406 @param fn optional filename of the multi project file to be |
|
407 read (string) |
400 @param openMaster flag indicating, that the master project |
408 @param openMaster flag indicating, that the master project |
401 should be opened depending on the configuration (boolean) |
409 should be opened depending on the configuration (boolean) |
402 """ |
410 """ |
403 if not self.checkDirty(): |
411 if not self.checkDirty(): |
404 return |
412 return |
405 |
413 |
406 if fn is None: |
414 if fn is None: |
407 fn = E5FileDialog.getOpenFileName( |
415 fn = E5FileDialog.getOpenFileName( |
408 self.parent(), |
416 self.parent(), |
409 self.trUtf8("Open multiproject"), |
417 self.trUtf8("Open multiproject"), |
410 Preferences.getMultiProject("Workspace") or Utilities.getHomeDir(), |
418 Preferences.getMultiProject("Workspace") or \ |
|
419 Utilities.getHomeDir(), |
411 self.trUtf8("Multiproject Files (*.e4m)")) |
420 self.trUtf8("Multiproject Files (*.e4m)")) |
412 |
421 |
413 if fn == "": |
422 if fn == "": |
414 fn = None |
423 fn = None |
415 |
424 |
429 self.addProjectAct.setEnabled(True) |
438 self.addProjectAct.setEnabled(True) |
430 self.propsAct.setEnabled(True) |
439 self.propsAct.setEnabled(True) |
431 |
440 |
432 self.multiProjectOpened.emit() |
441 self.multiProjectOpened.emit() |
433 |
442 |
434 if openMaster and Preferences.getMultiProject("OpenMasterAutomatically"): |
443 if openMaster and Preferences.getMultiProject( |
|
444 "OpenMasterAutomatically"): |
435 self.__openMasterProject(False) |
445 self.__openMasterProject(False) |
436 else: |
446 else: |
437 QApplication.restoreOverrideCursor() |
447 QApplication.restoreOverrideCursor() |
438 |
448 |
439 def saveMultiProject(self): |
449 def saveMultiProject(self): |
581 self.actions.append(act) |
591 self.actions.append(act) |
582 |
592 |
583 self.closeAct = E5Action(self.trUtf8('Close multiproject'), |
593 self.closeAct = E5Action(self.trUtf8('Close multiproject'), |
584 UI.PixmapCache.getIcon("multiProjectClose.png"), |
594 UI.PixmapCache.getIcon("multiProjectClose.png"), |
585 self.trUtf8('&Close'), 0, 0, self, 'multi_project_close') |
595 self.trUtf8('&Close'), 0, 0, self, 'multi_project_close') |
586 self.closeAct.setStatusTip(self.trUtf8('Close the current multiproject')) |
596 self.closeAct.setStatusTip(self.trUtf8( |
|
597 'Close the current multiproject')) |
587 self.closeAct.setWhatsThis(self.trUtf8( |
598 self.closeAct.setWhatsThis(self.trUtf8( |
588 """<b>Close</b>""" |
599 """<b>Close</b>""" |
589 """<p>This closes the current multiproject.</p>""" |
600 """<p>This closes the current multiproject.</p>""" |
590 )) |
601 )) |
591 self.closeAct.triggered[()].connect(self.closeMultiProject) |
602 self.closeAct.triggered[()].connect(self.closeMultiProject) |
602 self.saveAct.triggered[()].connect(self.saveMultiProject) |
613 self.saveAct.triggered[()].connect(self.saveMultiProject) |
603 self.actions.append(self.saveAct) |
614 self.actions.append(self.saveAct) |
604 |
615 |
605 self.saveasAct = E5Action(self.trUtf8('Save multiproject as'), |
616 self.saveasAct = E5Action(self.trUtf8('Save multiproject as'), |
606 UI.PixmapCache.getIcon("multiProjectSaveAs.png"), |
617 UI.PixmapCache.getIcon("multiProjectSaveAs.png"), |
607 self.trUtf8('Save &as...'), 0, 0, self, 'multi_project_save_as') |
618 self.trUtf8('Save &as...'), 0, 0, self, |
|
619 'multi_project_save_as') |
608 self.saveasAct.setStatusTip(self.trUtf8( |
620 self.saveasAct.setStatusTip(self.trUtf8( |
609 'Save the current multiproject to a new file')) |
621 'Save the current multiproject to a new file')) |
610 self.saveasAct.setWhatsThis(self.trUtf8( |
622 self.saveasAct.setWhatsThis(self.trUtf8( |
611 """<b>Save as</b>""" |
623 """<b>Save as</b>""" |
612 """<p>This saves the current multiproject to a new file.</p>""" |
624 """<p>This saves the current multiproject to a new file.</p>""" |
613 )) |
625 )) |
614 self.saveasAct.triggered[()].connect(self.saveMultiProjectAs) |
626 self.saveasAct.triggered[()].connect(self.saveMultiProjectAs) |
615 self.actions.append(self.saveasAct) |
627 self.actions.append(self.saveasAct) |
616 |
628 |
617 self.addProjectAct = E5Action(self.trUtf8('Add project to multiproject'), |
629 self.addProjectAct = E5Action( |
618 UI.PixmapCache.getIcon("fileProject.png"), |
630 self.trUtf8('Add project to multiproject'), |
619 self.trUtf8('Add &project...'), 0, 0, |
631 UI.PixmapCache.getIcon("fileProject.png"), |
620 self, 'multi_project_add_project') |
632 self.trUtf8('Add &project...'), 0, 0, |
|
633 self, 'multi_project_add_project') |
621 self.addProjectAct.setStatusTip(self.trUtf8( |
634 self.addProjectAct.setStatusTip(self.trUtf8( |
622 'Add a project to the current multiproject')) |
635 'Add a project to the current multiproject')) |
623 self.addProjectAct.setWhatsThis(self.trUtf8( |
636 self.addProjectAct.setWhatsThis(self.trUtf8( |
624 """<b>Add project...</b>""" |
637 """<b>Add project...</b>""" |
625 """<p>This opens a dialog for adding a project""" |
638 """<p>This opens a dialog for adding a project""" |
628 self.addProjectAct.triggered[()].connect(self.addProject) |
641 self.addProjectAct.triggered[()].connect(self.addProject) |
629 self.actions.append(self.addProjectAct) |
642 self.actions.append(self.addProjectAct) |
630 |
643 |
631 self.propsAct = E5Action(self.trUtf8('Multiproject properties'), |
644 self.propsAct = E5Action(self.trUtf8('Multiproject properties'), |
632 UI.PixmapCache.getIcon("multiProjectProps.png"), |
645 UI.PixmapCache.getIcon("multiProjectProps.png"), |
633 self.trUtf8('&Properties...'), 0, 0, self, 'multi_project_properties') |
646 self.trUtf8('&Properties...'), 0, 0, self, |
634 self.propsAct.setStatusTip(self.trUtf8('Show the multiproject properties')) |
647 'multi_project_properties') |
|
648 self.propsAct.setStatusTip(self.trUtf8( |
|
649 'Show the multiproject properties')) |
635 self.propsAct.setWhatsThis(self.trUtf8( |
650 self.propsAct.setWhatsThis(self.trUtf8( |
636 """<b>Properties...</b>""" |
651 """<b>Properties...</b>""" |
637 """<p>This shows a dialog to edit the multiproject properties.</p>""" |
652 """<p>This shows a dialog to edit the multiproject""" |
|
653 """ properties.</p>""" |
638 )) |
654 )) |
639 self.propsAct.triggered[()].connect(self.__showProperties) |
655 self.propsAct.triggered[()].connect(self.__showProperties) |
640 self.actions.append(self.propsAct) |
656 self.actions.append(self.propsAct) |
641 |
657 |
642 self.closeAct.setEnabled(False) |
658 self.closeAct.setEnabled(False) |
650 Public slot to initialize the multi project menu. |
666 Public slot to initialize the multi project menu. |
651 |
667 |
652 @return the menu generated (QMenu) |
668 @return the menu generated (QMenu) |
653 """ |
669 """ |
654 menu = QMenu(self.trUtf8('&Multiproject'), self.parent()) |
670 menu = QMenu(self.trUtf8('&Multiproject'), self.parent()) |
655 self.recentMenu = QMenu(self.trUtf8('Open &Recent Multiprojects'), menu) |
671 self.recentMenu = QMenu(self.trUtf8('Open &Recent Multiprojects'), |
|
672 menu) |
656 |
673 |
657 self.__menus = { |
674 self.__menus = { |
658 "Main": menu, |
675 "Main": menu, |
659 "Recent": self.recentMenu, |
676 "Recent": self.recentMenu, |
660 } |
677 } |
683 |
700 |
684 def initToolbar(self, toolbarManager): |
701 def initToolbar(self, toolbarManager): |
685 """ |
702 """ |
686 Public slot to initialize the multi project toolbar. |
703 Public slot to initialize the multi project toolbar. |
687 |
704 |
688 @param toolbarManager reference to a toolbar manager object (E5ToolBarManager) |
705 @param toolbarManager reference to a toolbar manager object |
|
706 (E5ToolBarManager) |
689 @return the toolbar generated (QToolBar) |
707 @return the toolbar generated (QToolBar) |
690 """ |
708 """ |
691 tb = QToolBar(self.trUtf8("Multiproject"), self.ui) |
709 tb = QToolBar(self.trUtf8("Multiproject"), self.ui) |
692 tb.setIconSize(UI.Config.ToolBarIconSize) |
710 tb.setIconSize(UI.Config.ToolBarIconSize) |
693 tb.setObjectName("MultiProjectToolbar") |
711 tb.setObjectName("MultiProjectToolbar") |
713 |
731 |
714 self.showMenu.emit("Main", self.__menus["Main"]) |
732 self.showMenu.emit("Main", self.__menus["Main"]) |
715 |
733 |
716 def __syncRecent(self): |
734 def __syncRecent(self): |
717 """ |
735 """ |
718 Private method to synchronize the list of recently opened multi projects |
736 Private method to synchronize the list of recently opened multi |
719 with the central store. |
737 projects with the central store. |
720 """ |
738 """ |
721 for recent in self.recent[:]: |
739 for recent in self.recent[:]: |
722 if Utilities.samepath(self.pfile, recent): |
740 if Utilities.samepath(self.pfile, recent): |
723 self.recent.remove(recent) |
741 self.recent.remove(recent) |
724 self.recent.insert(0, self.pfile) |
742 self.recent.insert(0, self.pfile) |