MultiProject/MultiProject.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3022
57179e4cdadd
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
205 f.close() 205 f.close()
206 if reader.hasError(): 206 if reader.hasError():
207 return False 207 return False
208 else: 208 else:
209 QApplication.restoreOverrideCursor() 209 QApplication.restoreOverrideCursor()
210 E5MessageBox.critical(self.ui, 210 E5MessageBox.critical(
211 self.ui,
211 self.trUtf8("Read multiproject file"), 212 self.trUtf8("Read multiproject file"),
212 self.trUtf8( 213 self.trUtf8(
213 "<p>The multiproject file <b>{0}</b> could not be" 214 "<p>The multiproject file <b>{0}</b> could not be"
214 " read.</p>").format(fn)) 215 " read.</p>").format(fn))
215 return False 216 return False
247 MultiProjectWriter( 248 MultiProjectWriter(
248 f, self, os.path.splitext(os.path.basename(fn))[0])\ 249 f, self, os.path.splitext(os.path.basename(fn))[0])\
249 .writeXML() 250 .writeXML()
250 res = True 251 res = True
251 else: 252 else:
252 E5MessageBox.critical(self.ui, 253 E5MessageBox.critical(
254 self.ui,
253 self.trUtf8("Save multiproject file"), 255 self.trUtf8("Save multiproject file"),
254 self.trUtf8("<p>The multiproject file <b>{0}</b> could not be " 256 self.trUtf8(
257 "<p>The multiproject file <b>{0}</b> could not be "
255 "written.</p>").format(fn)) 258 "written.</p>").format(fn))
256 res = False 259 res = False
257 260
258 if res: 261 if res:
259 self.pfile = os.path.abspath(fn) 262 self.pfile = os.path.abspath(fn)
488 if not ext: 491 if not ext:
489 ex = selectedFilter.split("(*")[1].split(")")[0] 492 ex = selectedFilter.split("(*")[1].split(")")[0]
490 if ex: 493 if ex:
491 fn += ex 494 fn += ex
492 if QFileInfo(fn).exists(): 495 if QFileInfo(fn).exists():
493 res = E5MessageBox.yesNo(self.parent(), 496 res = E5MessageBox.yesNo(
497 self.parent(),
494 self.trUtf8("Save File"), 498 self.trUtf8("Save File"),
495 self.trUtf8("<p>The file <b>{0}</b> already exists." 499 self.trUtf8("<p>The file <b>{0}</b> already exists."
496 " Overwrite it?</p>").format(fn), 500 " Overwrite it?</p>").format(fn),
497 icon=E5MessageBox.Warning) 501 icon=E5MessageBox.Warning)
498 if not res: 502 if not res:
512 Public method to check the dirty status and open a message window. 516 Public method to check the dirty status and open a message window.
513 517
514 @return flag indicating whether this operation was successful (boolean) 518 @return flag indicating whether this operation was successful (boolean)
515 """ 519 """
516 if self.isDirty(): 520 if self.isDirty():
517 res = E5MessageBox.okToClearData(self.parent(), 521 res = E5MessageBox.okToClearData(
522 self.parent(),
518 self.trUtf8("Close Multiproject"), 523 self.trUtf8("Close Multiproject"),
519 self.trUtf8("The current multiproject has unsaved changes."), 524 self.trUtf8("The current multiproject has unsaved changes."),
520 self.saveMultiProject) 525 self.saveMultiProject)
521 if res: 526 if res:
522 self.setDirty(False) 527 self.setDirty(False)
565 """ 570 """
566 self.actions = [] 571 self.actions = []
567 572
568 self.actGrp1 = createActionGroup(self) 573 self.actGrp1 = createActionGroup(self)
569 574
570 act = E5Action(self.trUtf8('New multiproject'), 575 act = E5Action(
571 UI.PixmapCache.getIcon("multiProjectNew.png"), 576 self.trUtf8('New multiproject'),
572 self.trUtf8('&New...'), 0, 0, 577 UI.PixmapCache.getIcon("multiProjectNew.png"),
573 self.actGrp1, 'multi_project_new') 578 self.trUtf8('&New...'), 0, 0,
579 self.actGrp1, 'multi_project_new')
574 act.setStatusTip(self.trUtf8('Generate a new multiproject')) 580 act.setStatusTip(self.trUtf8('Generate a new multiproject'))
575 act.setWhatsThis(self.trUtf8( 581 act.setWhatsThis(self.trUtf8(
576 """<b>New...</b>""" 582 """<b>New...</b>"""
577 """<p>This opens a dialog for entering the info for a""" 583 """<p>This opens a dialog for entering the info for a"""
578 """ new multiproject.</p>""" 584 """ new multiproject.</p>"""
579 )) 585 ))
580 act.triggered[()].connect(self.__newMultiProject) 586 act.triggered[()].connect(self.__newMultiProject)
581 self.actions.append(act) 587 self.actions.append(act)
582 588
583 act = E5Action(self.trUtf8('Open multiproject'), 589 act = E5Action(
584 UI.PixmapCache.getIcon("multiProjectOpen.png"), 590 self.trUtf8('Open multiproject'),
585 self.trUtf8('&Open...'), 0, 0, 591 UI.PixmapCache.getIcon("multiProjectOpen.png"),
586 self.actGrp1, 'multi_project_open') 592 self.trUtf8('&Open...'), 0, 0,
593 self.actGrp1, 'multi_project_open')
587 act.setStatusTip(self.trUtf8('Open an existing multiproject')) 594 act.setStatusTip(self.trUtf8('Open an existing multiproject'))
588 act.setWhatsThis(self.trUtf8( 595 act.setWhatsThis(self.trUtf8(
589 """<b>Open...</b>""" 596 """<b>Open...</b>"""
590 """<p>This opens an existing multiproject.</p>""" 597 """<p>This opens an existing multiproject.</p>"""
591 )) 598 ))
592 act.triggered[()].connect(self.openMultiProject) 599 act.triggered[()].connect(self.openMultiProject)
593 self.actions.append(act) 600 self.actions.append(act)
594 601
595 self.closeAct = E5Action(self.trUtf8('Close multiproject'), 602 self.closeAct = E5Action(
596 UI.PixmapCache.getIcon("multiProjectClose.png"), 603 self.trUtf8('Close multiproject'),
597 self.trUtf8('&Close'), 0, 0, self, 'multi_project_close') 604 UI.PixmapCache.getIcon("multiProjectClose.png"),
605 self.trUtf8('&Close'), 0, 0, self, 'multi_project_close')
598 self.closeAct.setStatusTip(self.trUtf8( 606 self.closeAct.setStatusTip(self.trUtf8(
599 'Close the current multiproject')) 607 'Close the current multiproject'))
600 self.closeAct.setWhatsThis(self.trUtf8( 608 self.closeAct.setWhatsThis(self.trUtf8(
601 """<b>Close</b>""" 609 """<b>Close</b>"""
602 """<p>This closes the current multiproject.</p>""" 610 """<p>This closes the current multiproject.</p>"""
603 )) 611 ))
604 self.closeAct.triggered[()].connect(self.closeMultiProject) 612 self.closeAct.triggered[()].connect(self.closeMultiProject)
605 self.actions.append(self.closeAct) 613 self.actions.append(self.closeAct)
606 614
607 self.saveAct = E5Action(self.trUtf8('Save multiproject'), 615 self.saveAct = E5Action(
608 UI.PixmapCache.getIcon("multiProjectSave.png"), 616 self.trUtf8('Save multiproject'),
609 self.trUtf8('&Save'), 0, 0, self, 'multi_project_save') 617 UI.PixmapCache.getIcon("multiProjectSave.png"),
618 self.trUtf8('&Save'), 0, 0, self, 'multi_project_save')
610 self.saveAct.setStatusTip(self.trUtf8('Save the current multiproject')) 619 self.saveAct.setStatusTip(self.trUtf8('Save the current multiproject'))
611 self.saveAct.setWhatsThis(self.trUtf8( 620 self.saveAct.setWhatsThis(self.trUtf8(
612 """<b>Save</b>""" 621 """<b>Save</b>"""
613 """<p>This saves the current multiproject.</p>""" 622 """<p>This saves the current multiproject.</p>"""
614 )) 623 ))
615 self.saveAct.triggered[()].connect(self.saveMultiProject) 624 self.saveAct.triggered[()].connect(self.saveMultiProject)
616 self.actions.append(self.saveAct) 625 self.actions.append(self.saveAct)
617 626
618 self.saveasAct = E5Action(self.trUtf8('Save multiproject as'), 627 self.saveasAct = E5Action(
619 UI.PixmapCache.getIcon("multiProjectSaveAs.png"), 628 self.trUtf8('Save multiproject as'),
620 self.trUtf8('Save &as...'), 0, 0, self, 629 UI.PixmapCache.getIcon("multiProjectSaveAs.png"),
621 'multi_project_save_as') 630 self.trUtf8('Save &as...'), 0, 0, self,
631 'multi_project_save_as')
622 self.saveasAct.setStatusTip(self.trUtf8( 632 self.saveasAct.setStatusTip(self.trUtf8(
623 'Save the current multiproject to a new file')) 633 'Save the current multiproject to a new file'))
624 self.saveasAct.setWhatsThis(self.trUtf8( 634 self.saveasAct.setWhatsThis(self.trUtf8(
625 """<b>Save as</b>""" 635 """<b>Save as</b>"""
626 """<p>This saves the current multiproject to a new file.</p>""" 636 """<p>This saves the current multiproject to a new file.</p>"""
641 """ to the current multiproject.</p>""" 651 """ to the current multiproject.</p>"""
642 )) 652 ))
643 self.addProjectAct.triggered[()].connect(self.addProject) 653 self.addProjectAct.triggered[()].connect(self.addProject)
644 self.actions.append(self.addProjectAct) 654 self.actions.append(self.addProjectAct)
645 655
646 self.propsAct = E5Action(self.trUtf8('Multiproject properties'), 656 self.propsAct = E5Action(
647 UI.PixmapCache.getIcon("multiProjectProps.png"), 657 self.trUtf8('Multiproject properties'),
648 self.trUtf8('&Properties...'), 0, 0, self, 658 UI.PixmapCache.getIcon("multiProjectProps.png"),
649 'multi_project_properties') 659 self.trUtf8('&Properties...'), 0, 0, self,
660 'multi_project_properties')
650 self.propsAct.setStatusTip(self.trUtf8( 661 self.propsAct.setStatusTip(self.trUtf8(
651 'Show the multiproject properties')) 662 'Show the multiproject properties'))
652 self.propsAct.setWhatsThis(self.trUtf8( 663 self.propsAct.setWhatsThis(self.trUtf8(
653 """<b>Properties...</b>""" 664 """<b>Properties...</b>"""
654 """<p>This shows a dialog to edit the multiproject""" 665 """<p>This shows a dialog to edit the multiproject"""
760 if idx < 10: 771 if idx < 10:
761 formatStr = '&{0:d}. {1}' 772 formatStr = '&{0:d}. {1}'
762 else: 773 else:
763 formatStr = '{0:d}. {1}' 774 formatStr = '{0:d}. {1}'
764 act = self.recentMenu.addAction( 775 act = self.recentMenu.addAction(
765 formatStr.format(idx, 776 formatStr.format(
777 idx,
766 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen))) 778 Utilities.compactPath(rp, self.ui.maxMenuFilePathLen)))
767 act.setData(rp) 779 act.setData(rp)
768 act.setEnabled(QFileInfo(rp).exists()) 780 act.setEnabled(QFileInfo(rp).exists())
769 idx += 1 781 idx += 1
770 782

eric ide

mercurial