1 # -*- coding: iso-8859-1 -*-
4 REPINI=os.path.dirname(os.path.abspath(__file__))
5 INSTALLDIR=os.path.join(REPINI,'..')
6 sys.path.append(INSTALLDIR)
7 sys.path.append(INSTALLDIR+"/UiQT4")
8 sys.path.append(INSTALLDIR+"/InterfaceQT4")
10 from PyQt4.QtGui import *
11 from PyQt4.QtCore import *
12 from PyQt4.QtAssistant import *
13 from myMain import Ui_Eficas
14 from viewManager import MyTabview
16 from Editeur import configuration
17 from Editeur import session
21 class Appli(Ui_Eficas,QMainWindow):
23 Class implementing the main user interface.
25 def __init__(self,code="ASTER",salome=0,parent=None):
32 self.top = self #(pour CONFIGURATION)
35 self.CONFIGURATION = configuration.make_config(self,prefs.REPINI)
36 self.CONFIGStyle = configuration.make_config_style(self,prefs.REPINI)
38 QMainWindow.__init__(self)
39 Ui_Eficas.__init__(self)
41 self.viewmanager = MyTabview(self)
42 self.recentMenu=self.menuFichier.addMenu(self.trUtf8('&Recents'))
43 self.connecterSignaux()
46 #self.monAssistant=QAssistantClient(QString(""), self.viewmanager)
49 # from Editeur import session
50 # self.ouvreFichiers()
51 from Editeur import session
57 self.recent = QStringList()
62 self.MenuBar.removeItem(5)
63 self.MenuBar.removeItem(6)
64 self.MenuBar.removeItem(7)
67 def connecterSignaux(self) :
68 self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu)
70 self.connect(self.action_Nouveau,SIGNAL("activated()"),self.fileNew)
71 self.connect(self.actionNouvel_Include,SIGNAL("activated()"),self.NewInclude)
72 self.connect(self.action_Ouvrir,SIGNAL("activated()"),self.fileOpen)
73 self.connect(self.actionEnregistrer,SIGNAL("activated()"),self.fileSave)
74 self.connect(self.actionEnregistrer_sous,SIGNAL("activated()"),self.fileSaveAs)
75 self.connect(self.actionFermer,SIGNAL("activated()"),self.fileClose)
76 self.connect(self.actionFermer_tout,SIGNAL("activated()"),self.fileCloseAll)
77 self.connect(self.actionQuitter,SIGNAL("activated()"),self.fileExit)
79 self.connect(self.actionCouper,SIGNAL("activated()"),self.editCut)
80 self.connect(self.actionCopier,SIGNAL("activated()"),self.editCopy)
81 self.connect(self.actionColler,SIGNAL("activated()"),self.editPaste)
83 self.connect(self.actionRapport_de_Validation,SIGNAL("activated()"),self.jdcRapport)
84 self.connect(self.actionFichier_Source,SIGNAL("activated()"),self.jdcFichierSource)
85 self.connect(self.actionFichier_Resultat,SIGNAL("activated()"),self.visuJdcPy)
87 self.connect(self.actionParametres_Eficas,SIGNAL("activated()"),self.optionEditeur)
88 self.connect(self.actionLecteur_Pdf,SIGNAL("activated()"),self.optionPdf)
90 self.connect(self.actionTraduitV7V8,SIGNAL("activated()"),self.traductionV7V8)
91 self.connect(self.actionTraduitV8V9,SIGNAL("activated()"),self.traductionV8V9)
93 #self.connect(self.helpIndexAction,SIGNAL("activated()"),self.helpIndex)
94 #self.connect(self.helpContentsAction,SIGNAL("activated()"),self.helpContents)
95 #self.connect(self.helpAboutAction,SIGNAL("activated()"),self.helpAbout)
96 #self.connect(self.aidenew_itemAction,SIGNAL("activated()"),self.helpAbout)
99 def ouvreFichiers(self) :
100 # Ouverture des fichiers de commandes donnes sur la ligne de commande
103 for study in session.d_env.studies:
105 d=session.get_unit(study,self)
106 self.viewmanager.handleOpen(fichier=study["comm"],units=d)
108 def get_source(self,file):
109 # appele par Editeur/session.py
111 p=convert.plugins['python']()
113 texte=p.convert('execnoparseur')
118 def initPatrons(self) :
119 # Mise à jour du menu des fichiers recemment ouverts
120 from Editeur import listePatrons
121 self.listePatrons = listePatrons.listePatrons(self.code)
123 for nomSsMenu in self.listePatrons.liste.keys():
124 ssmenu=self.menuPatrons.addMenu(nomSsMenu)
125 for fichier in self.listePatrons.liste[nomSsMenu]:
126 id = ssmenu.addAction(fichier)
127 self.ficPatrons[id]=fichier
128 self.connect(id, SIGNAL('triggered()'),self.handleOpenPatrons)
129 # self.Patrons.setItemParameter(id,idx)
132 def initRecents(self):
135 rep=self.CONFIGURATION.rep_user
136 monFichier=rep+"/listefichiers_"+self.code
142 l=(ligne.split("\n"))[0]
143 self.recent.append(l)
152 def addToRecentList(self, fn):
154 Public slot to add a filename to the list of recently opened files.
156 @param fn name of the file to be added
158 self.recent.removeAll(fn)
159 self.recent.prepend(fn)
160 if len(self.recent) > 9:
161 self.recent = self.recent[:9]
163 def sauveRecents(self) :
164 rep=self.CONFIGURATION.rep_user
165 monFichier=rep+"/listefichiers_"+self.code
167 f=open(monFichier,'w')
168 if len(self.recent) == 0 : return
170 while ( index < len(self.recent)):
171 ligne=str(self.recent[index])+"\n"
183 def traductionV7V8(self):
184 from gereTraduction import traduction
185 traduction(self.CONFIGURATION.rep_user,self.viewmanager,"V7V8")
187 def traductionV8V9(self):
188 from gereTraduction import traduction
189 traduction(self.CONFIGURATION.rep_user,self.viewmanager,"V8V9")
192 from desVisu import DVisu
194 monVisu=DVisu(parent=self.viewmanager)
195 monVisu.setCaption(titre)
196 monVisu.TB.setText("Eficas V1.13")
201 maD=INSTALLDIR+"/AIDE/fichiers"
202 docsPath = QDir(maD).absPath()
203 self.monAssistant.showPage( QString("%1/index.html").arg(docsPath) )
205 def optionEditeur(self) :
206 from monOptionsEditeur import Options
207 monOption=Options(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
210 def optionPdf(self) :
211 from monOptionsPdf import OptionPdf
212 monOption=OptionPdf(parent=self,modal = 0 ,configuration=self.CONFIGURATION)
215 def handleShowRecentMenu(self):
217 Private method to set up recent files menu.
219 self.recentMenu.clear()
221 for rp in self.recent:
222 id = self.recentMenu.addAction(rp)
223 self.ficRecents[id]=rp
224 self.connect(id, SIGNAL('triggered()'),self.handleOpenRecent)
225 self.recentMenu.addSeparator()
226 self.recentMenu.addAction(self.trUtf8('&Clear'), self.handleClearRecent)
228 def handleOpenPatrons(self):
230 fichier=REPINI+"/../Editeur/Patrons/"+self.code+"/"+self.ficPatrons[idx]
231 self.viewmanager.handleOpen(fichier=fichier, patron = 1)
233 def handleOpenRecent(self):
235 fichier=self.ficRecents[idx]
236 self.viewmanager.handleOpen(fichier=fichier, patron =0 )
238 def handleClearRecent(self):
239 self.recent = QStringList()
242 self.viewmanager.newEditor()
245 self.viewmanager.handleOpen()
248 self.viewmanager.saveCurrentEditor()
250 def fileSaveAs(self):
251 self.viewmanager.saveAsCurrentEditor()
254 self.viewmanager.handleClose()
256 def fileCloseAll(self):
257 self.viewmanager.handleCloseAll()
260 # On peut sortir sur Abort
261 self.viewmanager.handleCloseAll()
265 qApp.closeAllWindows()
268 self.viewmanager.handleEditCopy()
271 self.viewmanager.handleEditCut()
274 self.viewmanager.handleEditPaste()
276 def jdcFichierSource(self):
277 self.viewmanager.handleViewJdcFichierSource()
279 def jdcRapport(self):
280 self.viewmanager.handleViewJdcRapport()
283 self.viewmanager.handleViewJdcPy()
287 AIDE.go3(parent=self)
289 def NewInclude(self):
290 self.viewmanager.newIncludeEditor()
294 from Aster import prefs
296 sys.path.append(INSTALLDIR+"/Aster")
301 apply(Appli.__dict__[code],(self,))
305 if hasattr(prefs,'encoding'):
308 sys.setdefaultencoding(prefs.encoding)
310 if __name__=='__main__':
313 sys.path.append(INSTALLDIR+"/Aster")
314 from Aster import prefs
315 if hasattr(prefs,'encoding'):
316 # Hack pour changer le codage par defaut des strings
319 sys.setdefaultencoding(prefs.encoding)
320 del sys.setdefaultencoding
323 from Editeur import import_code
324 from Editeur import session
326 # Analyse des arguments de la ligne de commande
327 options=session.parse(sys.argv)
331 app = QApplication(sys.argv)
332 #app.setMainWidget(mw) (qt3)
336 #app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))