From: Pascale Noyret Date: Tue, 23 Oct 2007 09:06:18 +0000 (+0000) Subject: Pour QT : fichiers pour QT X-Git-Tag: V1_13_InstallationQT~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae7b2137b0a86839ccfef3b48158609da86b88d1;p=modules%2Feficas.git Pour QT : fichiers pour QT --- diff --git a/InterfaceQT/__init__.py b/InterfaceQT/__init__.py new file mode 100644 index 00000000..21d22fbc --- /dev/null +++ b/InterfaceQT/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce package contient les fonctionnalités nécessaires + pour l'éditeur graphique QT +""" diff --git a/InterfaceQT/browser.py b/InterfaceQT/browser.py new file mode 100644 index 00000000..bb83b5b4 --- /dev/null +++ b/InterfaceQT/browser.py @@ -0,0 +1,475 @@ +# -*- coding: utf-8 -*- +import os,sys,string,re,types,traceback + +from qt import * + + +from InterfaceQT import utilIcons + + +class JDCTree( QListView ): + def __init__( self, jdc_item, parent = None ): + QListView.__init__( self, parent ) + + self.item = jdc_item + self.tree = self + self.editor = parent + self.racine = self + self.node_selected = None + self.children = self.build_children() + + self.setCaption(self.trUtf8('Browser')) + self.setRootIsDecorated(1) + self.setSorting(-1) + self.addColumn(self.trUtf8('Name')) + self.addColumn(self.trUtf8('Value')) + + self.setMinimumSize(QSize(400,500)) + self.connect(self,SIGNAL('contextMenuRequested(QListViewItem *, const QPoint &, int)'), + self.handleContextMenu) + + self.connect(self, SIGNAL("onItem ( QListViewItem * ) "), self.handleOnItem) + + + def handleContextMenu(self,itm,coord,col): + """ + Private slot to show the context menu of the listview. + + @param itm the selected listview item (QListViewItem) + @param coord the position of the mouse pointer (QPoint) + @param col the column of the mouse pointer (int) + """ + try: + if itm.menu: + itm.menu.popup(coord) + except: + pass + + def handleOnItem(self, item ): + fr = item.item.get_fr() + if self.editor: + self.editor.affiche_infos(fr) + + def build_children(self): + """ Construit la liste des enfants de self """ + children = [] + child = self.item.itemNode(self,self.item) + children.append(child) + child.state='expanded' + return children + + def supprime(self): + """ supprime tous les elements de l'arbre """ + raise RuntimeError, 'Not implemented' + self.tree = None + self.racine = None + self.node_selected = None + self.item = None + self.scrolledcanvas = None + for child in self.children: + child.supprime() + self.children=[] + + def showEvent(self, event): + """ QT : pour afficher le 1er niveau d'arborescence de l''arbre""" + self.children[0].select() + + def update(self): + """ Update tous les elements de l'arbre """ + print 'TREE update' + for child in self.children: + child.update() + + def update_valid(self) : + """Cette methode a pour but de mettre a jour la validite du noeud + et de propager la demande de mise a jour a son parent + """ + print 'TREE update_valid' + +# type de noeud +COMMENT = "COMMENTAIRE" +PARAMETERS = "PARAMETRE" + + +class JDCNode(QListViewItem): + def __init__( self, parent, item, after=None, bold=0): + """ + Constructor + + @param parent parent Browser or BrowserNode + @param text text to be displayed by this node (string or QString) + @param after sibling this node is positioned after + @param bold flag indicating a highlighted font + """ + self.item = item + self.parent = parent + self.tree = self.parent.tree + self.editor = self.parent.tree.editor + self.bold = bold + + name = self.tree.trUtf8( str( item.GetLabelText()[0] ) ) + value = self.tree.trUtf8( str( item.GetText() ) ) + + if after is None: + QListViewItem.__init__(self,parent) + self.setText(0, name ) + self.setText(1, value ) + else: + QListViewItem.__init__(self,parent, after) + self.setText(0, name ) + self.setText(1, value) + + p = utilIcons.getPixmap(item.GetIconName() + ".gif") + self.setPixmap(0,p) + self.setExpandable(item.IsExpandable()) + + self.connect() + self.init() + self.createPopUpMenu() + + + def paintCell(self, p, cg, column, width, alignment): + """ + Overwritten class to set a different text color, if bold is true. + + @param p the painter (QPainter) + @param cg the color group (QColorGroup) + @param column the column (int) + @param width width of the cell (int) + @param alignment alignment of the cell (int) + """ + _cg = QColorGroup(cg) + c = _cg.text() + + if self.bold and column == 0: + _cg.setColor(QColorGroup.Text, Qt.red) + + QListViewItem.paintCell(self, p, _cg, column, width, alignment) + + _cg.setColor(QColorGroup.Text, c) + + + def setOpen(self, o): + """ + Public slot to set/reset the open state. + + @param o flag indicating the open state + """ + if o: + if not self.children : + self.build_children() + self.selected = 1 + self.tree.node_selected = self + else: + + for child in self.children: + self.takeItem(child) + del child + self.children = [] + QListViewItem.setOpen(self,o) + self.tree.setSelected(self,o) + + + #---------------------------------------------------------- + # interface a implementer par les noeuds derives (debut) + #---------------------------------------------------------- + def getPanel(self): + print self.__class__ + return None + + def createPopUpMenu(self): + pass + + #---------------------------------------------------- + # interface a implementer par les noeuds derives (fin) + #---------------------------------------------------- + + def init(self): #CS_pbruno toclean + self.state='collapsed' + self.displayed = 0 + self.selected = 0 + self.x = self.y =None + self.lasty = 0 + self.children = [] + self.id = [] + if self.parent is self.tree: + self.racine=self + else: + self.racine = self.parent.racine + + def connect(self): + self.item.connect("add",self.onAdd,()) + self.item.connect("supp",self.onSupp,()) + self.item.connect("valid",self.onValid,()) + + def commentIt(self): + """ + Cette methode a pour but de commentariser la commande pointee par self + """ + # On traite par une exception le cas ou l'utilisateur final cherche a désactiver + # (commentariser) un commentaire. + try : + pos=self.parent.children.index(self) + commande_comment = self.item.get_objet_commentarise() + # On signale au parent du panel (le JDCDisplay) une modification + self.editor.init_modif() + self.parent.children[pos].select() + except Exception,e: + traceback.print_exc() + QMessageBox.critical( self.parent, "TOO BAD",str(e)) + return + + def unCommentIt(self): + """ + Realise la decommentarisation de self + """ + try : + pos=self.parent.children.index(self) + commande,nom = self.item.uncomment() + self.editor.init_modif() + self.parent.children[pos].select() + except Exception,e: + QMessageBox.critical( self.editor, "Erreur !",str(e)) + return + + def addComment( self, after=True ): + """ + Ajoute un commentaire a l'interieur du JDC : + """ + self.editor.init_modif() + if after: + pos = 'after' + else: + pos = 'before' + return self.append_brother( COMMENT, pos ) + + def addParameters( self, after=True ): + """ + Ajoute un parametre a l'interieur du JDC : + """ + self.editor.init_modif() + if after: + pos = 'after' + else: + pos = 'before' + return self.append_brother( PARAMETERS, pos ) + + + + def select( self ): + """ + Rend le noeud courant (self) selectionne et deselectionne + tous les autres + """ + self.setOpen( True ) + + #------------------------------------------------------------------ + # Methodes de creation et destruction de noeuds + # Certaines de ces methodes peuvent etre appelees depuis l'externe + #------------------------------------------------------------------ + def append_brother(self,name,pos='after',retour='non'): + """ + Permet d'ajouter un objet frere a l'objet associe au noeud self + par defaut on l'ajoute immediatement apres + Methode externe + """ + # on veut ajouter le frere de nom name directement avant ou apres self +## print "*********** append_brother ", self.item.GetLabelText() + index = self.parent.children.index(self) + if pos == 'before': + index = index + elif pos == 'after': + index = index +1 + else: + print str(pos)," n'est pas un index valide pour append_brother" + return 0 + return self.parent.append_child(name,pos=index) + + def append_child(self,name,pos=None,verif='oui',retour='non'): + """ + Methode pour ajouter un objet fils a l'objet associe au noeud self. + On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last') + ou en position intermediaire. + Si pos vaut None, on le place a la position du catalogue. + """ +## print "************** append_child ",self.item.GetLabelText() + if pos == 'first': + index = 0 + elif pos == 'last': + index = len(self.children) + elif type(pos) == types.IntType : + # position fixee + index = pos + elif type(pos) == types.InstanceType: + # pos est un item. Il faut inserer name apres pos + index = self.item.get_index(pos) +1 + elif type(name) == types.InstanceType: + index = self.item.get_index_child(name.nom) + else: + index = self.item.get_index_child(name) + obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add' + #print obj + if obj is None:obj=0 + if obj == 0:return 0 + #print "append_child",index,self.children + child=self.children[index] + child.select() + return child + + def delete(self): + """ + Methode externe pour la destruction de l'objet associe au noeud + La mise a jour des noeuds est faite par onSupp sur notification + """ + self.editor.init_modif() + index = self.parent.children.index(self) - 1 + if index < 0 : index =0 + + parent=self.parent + ret=parent.item.suppitem(self.item) + if ret == 0:return + + brothers=parent.children + if brothers: + toselect=brothers[index] + else: + toselect=parent + toselect.select() + + #------------------------------------------------------------------ + def onValid(self): + self.update_node_valid() + self.update_node_label() + self.update_node_texte() + + + def onAdd(self,objet): + #print "NODE onAdd : un objet a ete ajoute aux fils de l'item ",self.item.GetLabelText() + old_nodes=self.children + self.update_nodes() + #self.select() + + def onSupp(self,objet): + #print "NODE onSupp : un objet a ete supprime des fils de l'item ",self.item.object,objet + old_nodes=self.children + self.update_nodes() + #self.select() + + def update_node_valid(self): + """Cette methode remet a jour la validite du noeud (icone) + Elle appelle isvalid + """ + #print 'NODE update_node_valid', self.item.GetLabelText() + p = utilIcons.getPixmap(self.item.GetIconName() + ".gif") + self.setPixmap(0,p) + + def update_node_label(self): #CS_pbruno todo + """ Met a jour le label du noeud """ + #print "NODE update_node_label", self.item.GetLabelText() + labeltext,fonte,couleur = self.item.GetLabelText() + self.setText(0, labeltext) + + def update_node_texte(self): + """ Met a jour les noms des SD et valeurs des mots-cles """ + #print "NODE update_node_texte", self.item.GetLabelText() + value = self.item.GetText() + self.setText(1, value) + + def update_nodes(self): + #print "NODE update_nodes ", self.item.GetLabelText() + self.setOpen( False ) + self.setOpen( True ) + #self.select() + + def update_texte(self): + """ Met a jour les noms des SD et valeurs des mots-cles """ + #print "NODE update_texte", self.item.GetLabelText() + self.update_node_texte() + if self.state == 'expanded' : + for child in self.children: + if child.displayed != 0 : child.update_texte() + + def update_valid(self) : + """Cette methode a pour but de mettre a jour la validite du noeud + et de propager la demande de mise a jour a son parent + """ + #print "NODE update_valid", self.item.GetLabelText() + self.update_node_valid() + self.parent.update_valid() + + def supprime(self): + #print "NODE supprime",self.item.GetLabelText() + self.efface_node() + self.racine = None + if not self.children : return + for child in self.children: + child.supprime() + self.children=None + + def build_children(self): + """ Construit la liste des enfants de self """ + #print "NODE : Construit la liste des enfants de", self.item.GetLabelText() + self.children = [] + sublist = self.item._GetSubList() + if sublist : + last = None + for item in sublist : + child = item.itemNode(self, item, last) + last = child + self.children.append(child) + + + + +if __name__=='__main__': + from qt import * + + + sys.path[:0]=['..','../Aster','../Aster/Cata' ] + + app = QApplication(sys.argv) + + fn = 'azAster.comm' + jdcName = os.path.basename(fn) + f=open(fn,'r') + text=f.read() + f.close() + print 'text',text + + from autre_analyse_cata import analyse_catalogue + from Cata import cataSTA8 + cata=cataSTA8 + fic_cata="../../Aster/Cata/cataSTA8/cata.py" + cata_ordonne ,list_simp_reel = analyse_catalogue(cata) + + + + j=cata.JdC( procedure=text, cata=cata, nom=jdcName, + cata_ord_dico=cata_ordonne ) + + j.compile() + if not j.cr.estvide(): + print j.cr + sys.exit() + + j.exec_compile() + if not j.cr.estvide(): + print j.cr + sys.exit() + + from Editeur import comploader + comploader.charger_composants(QT) + from Editeur import Objecttreeitem + jdc_item=Objecttreeitem.make_objecttreeitem( app, "nom", j) + + if jdc_item: + tree = JDCTree( jdc_item, None ) + + app.setMainWidget(tree) + app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + tree.show() + + res = app.exec_loop() + sys.exit(res) + + diff --git a/InterfaceQT/compobase.py b/InterfaceQT/compobase.py new file mode 100644 index 00000000..a287b7d2 --- /dev/null +++ b/InterfaceQT/compobase.py @@ -0,0 +1,3 @@ +from Editeur import Objecttreeitem +treeitem = Objecttreeitem.ObjectTreeItem +objet = None diff --git a/InterfaceQT/compobloc.py b/InterfaceQT/compobloc.py new file mode 100644 index 00000000..ff386c51 --- /dev/null +++ b/InterfaceQT/compobloc.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from Editeur import Objecttreeitem +from InterfaceQT import compofact +from InterfaceQT import browser +from qt import * + + +class Node(browser.JDCNode): + def getPanel(self): + """ + """ + from monMCFactPanel import MonMCFactPanel + return MonMCFactPanel(self,parent=self.editor) + + +class BLOCTreeItem(compofact.FACTTreeItem): + itemNode=Node + + def get_objet(self,name) : + for v in self.object.mc_liste: + if v.nom == name : return v + return None + + def iscopiable(self): + return 0 + + +import Accas +treeitem = BLOCTreeItem +objet = Accas.MCBLOC diff --git a/InterfaceQT/compocomm.py b/InterfaceQT/compocomm.py new file mode 100644 index 00000000..4ff1e58c --- /dev/null +++ b/InterfaceQT/compocomm.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import string +from qt import * + +from Editeur import Objecttreeitem +from InterfaceQT import browser +from InterfaceQT import typeNode + + +class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): + def getPanel( self ): + """ + """ + from monCommentairePanel import MonCommentairePanel + return MonCommentairePanel(self,parent=self.editor) + + def createPopUpMenu(self): + typeNode.PopUpMenuNodePartiel.createPopUpMenu(self) + self.menu.insertItem( qApp.translate('Browser','Uncomment'), self.unCommentIt ) + + def update_node_label(self) : + """ + """ + debComm=self.item.GetText() + self.setText(1,debComm) + + +class COMMTreeItem(Objecttreeitem.ObjectTreeItem): + itemNode=Node + + def init(self): + self.setfunction = self.set_valeur + + def GetIconName(self): + """ + Retourne le nom de l'icône associée au noeud qui porte self, + dépendant de la validité de l'objet + NB : un commentaire est toujours valide ... + """ + return "ast-white-percent" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + return 'commentaire' #CS_pbruno,Fonte_Commentaire,None + + def get_valeur(self): + """ + Retourne la valeur de l'objet Commentaire cad son texte + """ + return self.object.get_valeur() or '' + + def GetText(self): + texte = self.object.valeur + texte = string.split(texte,'\n')[0] + if len(texte) < 25 : + return texte + else : + return texte[0:24] + + def set_valeur(self,valeur): + """ + Afecte valeur à l'objet COMMENTAIRE + """ + self.object.set_valeur(valeur) + + def GetSubList(self): + """ + Retourne la liste des fils de self + """ + return [] + + + def get_objet_commentarise(self): + """ + La méthode get_objet_commentarise() de la classe compocomm.COMMTreeItem + surcharge la méthode get_objet_commentarise de la classe Objecttreeitem.ObjectTreeItem + elle a pour but d'empecher l'utilisateur final de commentariser un commentaire. + """ + raise Exception( 'Impossible de commentariser un commentaire' ) + +import Extensions +treeitem =COMMTreeItem +objet = Extensions.commentaire.COMMENTAIRE diff --git a/InterfaceQT/compocommandecomm.py b/InterfaceQT/compocommandecomm.py new file mode 100644 index 00000000..c28756a9 --- /dev/null +++ b/InterfaceQT/compocommandecomm.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +import traceback +import string + +from Editeur import Objecttreeitem +from InterfaceQT import compocomm + +class COMMANDE_COMMTreeItem(Objecttreeitem.ObjectTreeItem): + itemNode=compocomm.Node + + def init(self): + self.setfunction = self.set_valeur + + def GetIconName(self): + """ + Retourne le nom de l'icône associée au noeud qui porte self, + dépendant de la validité de l'objet + NB : une commande commentarisée est toujours valide ... + """ + if self.isvalid(): + return "ast-green-percent" + else: + return "ast-red-percent" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + return 'commentaire' + + def get_valeur(self): + """ + Retourne la valeur de la commande commentarisée cad son texte + """ + return self.object.get_valeur() or '' + + def GetText(self): + texte = self.object.valeur + texte = string.split(texte,'\n')[0] + if len(texte) < 25 : + return texte + else : + return texte[0:24] + + def set_valeur(self,valeur): + """ + Afefcte valeur à l'objet commande commentarisée + """ + self.object.set_valeur(valeur) + + def GetSubList(self): + """ + Retourne la liste des fils de self + """ + return [] + + def uncomment(self): + """ + Demande à l'objet commande commentarisée de se décommentariser. + Si l'opération s'effectue correctement, retourne l'objet commande + et éventuellement le nom de la sd produite, sinon lève une exception + """ + try: + commande,nom = self.object.uncomment() + #self.parent.children[pos].select() + except Exception,e: + traceback.print_exc() + raise e + return commande,nom + +import Accas +treeitem =COMMANDE_COMMTreeItem +objet = Accas.COMMANDE_COMM diff --git a/InterfaceQT/compoerror.py b/InterfaceQT/compoerror.py new file mode 100644 index 00000000..2f1821dc --- /dev/null +++ b/InterfaceQT/compoerror.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +from Tkinter import Label,Button + +#Modules Eficas +from Noyau.N_OBJECT import ErrorObj +from Editeur import Objecttreeitem +from desError import DError + +class ERRORTreeItem(Objecttreeitem.AtomicObjectTreeItem): + + panel = DError + def GetIconName(self): + return "ast-red-ball" + + +treeitem =ERRORTreeItem +objet = ErrorObj + diff --git a/InterfaceQT/compofact.py b/InterfaceQT/compofact.py new file mode 100644 index 00000000..26f97a77 --- /dev/null +++ b/InterfaceQT/compofact.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +from Editeur import Objecttreeitem +from InterfaceQT import browser +from qt import * + + +class Node(browser.JDCNode): + def getPanel(self): + """ + """ + from monMCFactPanel import MonMCFactPanel + return MonMCFactPanel(self,parent=self.editor) + + def doPaste(self,node_selected): + objetACopier = self.item.get_copie_objet() + child=node_selected.doPasteMCF(objetACopier) + return child + + def doPaste_MCF(self,objetACopier): + child = self.parent.append_child(objetACopier, + pos=self.item, + retour='oui') + return child + + +class FACTTreeItem(Objecttreeitem.ObjectTreeItem): + itemNode=Node + + def IsExpandable(self): + return 1 + + def GetText(self): + return '' + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + # None --> fonte et couleur par défaut + return self.object.getlabeltext(),None,None + + def isvalid(self): + return self.object.isvalid() + + def iscopiable(self): + return 1 + + def GetIconName(self): + if self.object.isvalid(): + return "ast-green-los" + elif self.object.isoblig(): + return "ast-red-los" + else: + return "ast-yel-los" + + def keys(self): + keys=self.object.mc_dict.keys() + return keys + + def GetSubList(self): + """ + Reactualise la liste des items fils stockes dans self.sublist + """ + liste=self.object.mc_liste + sublist=[None]*len(liste) + # suppression des items lies aux objets disparus + for item in self.sublist: + old_obj=item.getObject() + if old_obj in liste: + pos=liste.index(old_obj) + sublist[pos]=item + else: + pass # objets supprimes ignores + # ajout des items lies aux nouveaux objets + pos=0 + for obj in liste: + if sublist[pos] is None: + # nouvel objet : on cree un nouvel item + def setfunction(value, object=obj): + object.setval(value) + item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction) + sublist[pos]=item + pos=pos+1 + + self.sublist=sublist + return self.sublist + + def additem(self,name,pos): + objet = self.object.addentite(name,pos) + return objet + + def suppitem(self,item) : + """ + Cette methode a pour fonction de supprimer l'item passee en argument + des fils de l'item FACT qui est son pere + - item = item du MOCLE a supprimer du MOCLE pere + - item.getObject() = MCSIMP ou MCBLOC + """ + itemobject=item.getObject() + if itemobject.isoblig() : + self.appli.affiche_infos('Impossible de supprimer un mot-clé obligatoire ') + return 0 + + if self.object.suppentite(itemobject): + message = "Mot-clé " + itemobject.nom + " supprimé" + self.appli.affiche_infos(message) + return 1 + else: + self.appli.affiche_infos('Pb interne : impossible de supprimer ce mot-clé') + return 0 + +import Accas +objet = Accas.MCFACT +treeitem = FACTTreeItem diff --git a/InterfaceQT/compoformule.py b/InterfaceQT/compoformule.py new file mode 100644 index 00000000..d314ba1e --- /dev/null +++ b/InterfaceQT/compoformule.py @@ -0,0 +1,175 @@ +# -*- coding: utf-8 -*- + +""" +Ce module contient les classes permettant de définir les objets graphiques +représentant un objet de type FORMULE, cad le panneau et l'item de l'arbre +d'EFICAS +""" + +import string +from qt import * +from InterfaceQT import compooper +from InterfaceQT import browser +from InterfaceQT import typeNode + + +class FormuleNode(browser.JDCNode,typeNode.PopUpMenuNode): + + def getPanel(self): + + from monFormulePanel import MonFormulePanel + return MonFormulePanel(self,parent=self.editor) + + +class FORMULETreeItem(compooper.EtapeTreeItem): + """ + Classe servant a définir l'item porté par le noeud de l'arbre d'EFICAS + qui représente la FORMULE + """ + itemNode=Node =FormuleNode + + def init(self): + self.setfunction = self.set_valeur + +# --------------------------------------------------------------------------- +# API de FORMULE pour l'arbre +# --------------------------------------------------------------------------- + def GetSubList(self): + """ + Retourne la liste des fils de self + On considére que FORMULE n'a pas de fils + --> modification par rapport a MACRO classique + """ + # dans EFICAS on ne souhaite pas afficher les mots-clés fils de FORMULE + # de façon traditionnelle + return [] + + def GetIconName(self): + """ + Retourne le nom de l'icone à afficher dans l'arbre + Ce nom dépend de la validité de l'objet + """ + if self.object.isactif(): + self.object.state="modified" + if self.object.isvalid(): + return "ast-green-square" + else: + return "ast-red-square" + else: + return "ast-white-text" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte a afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + if self.object.isactif(): + # None --> fonte et couleur par défaut + return self.labeltext,None,None + else: + return self.labeltext,fontes.standard_italique,None + +# --------------------------------------------------------------------------- +# Méthodes permettant la modification et la lecture des attributs +# du paramètre = API graphique de la FORMULE pour Panel et EFICAS +# --------------------------------------------------------------------------- + + def get_nom(self): + """ + Retourne le nom de la FORMULE + """ + return self.object.get_nom() + + def get_type(self): + """ + Retourne le type de la valeur retournée par la FORMULE + """ + return self.object.type_retourne + + def get_args(self): + """ + Retourne les arguments de la FORMULE + """ + args="" + for mot in self.object.mc_liste: + if mot.nom == 'NOM_PARA': + args=mot.valeur + break + if args : + if args[0] == "(" and args[-1] ==")": + args=args[1:-1] + # transforme en tuple si ce n est pas déja le casa + try : + args=string.split(args,',') + except : + pass + return args + + def get_corps(self): + """ + Retourne le corps de la FORMULE + """ + corps="" + for mot in self.object.mc_liste: + if mot.nom == 'VALE': + corps=mot.valeur + break + return corps + + + def get_liste_types_autorises(self): + """ + Retourne la liste des types autorises pour les valeurs de sortie + d'une FORMULE + """ + return self.object.l_types_autorises + + def save_formule(self,new_nom,new_typ,new_arg,new_exp): + """ + Vérifie si (new_nom,new_typ,new_arg,new_exp) définit bien une FORMULE + licite : + - si oui, stocke ces paramètres comme nouveaux paramètres de la + FORMULE courante et retourne 1 + - si non, laisse les paramètres anciens de la FORMULE inchangés et + retourne 0 + """ + test,erreur = self.object.verif_formule_python(formule=(new_nom,new_typ,new_arg, + new_exp)) + if test : + # la formule est bien correcte : on sauve les nouveaux paramètres + test=self.object.update_formule_python(formule=(new_nom,new_typ,new_exp,new_arg)) + return test,erreur + +# --------------------------------------------------------------------------- +# Accès aux méthodes de vérification de l'objet FORM_ETAPE +# --------------------------------------------------------------------------- + + def verif_nom(self,nom): + """ + Lance la vérification du nom passé en argument + """ + return self.object.verif_nom(nom) + + def verif_arguments(self,arguments): + """ + Lance la vérification des arguments passés en argument + """ + return self.object.verif_arguments('('+arguments+')') + + def verif_formule(self,formule): + """ + Lance la vérification de FORMULE passée en argument + """ + return self.object.verif_formule(formule=formule) + + + def verif_formule_python(self,formule): + """ + Lance la vérification de FORMULE passée en argument + """ + return self.object.verif_formule_python(formule=formule) + +import Accas +treeitem =FORMULETreeItem +objet = Accas.FORM_ETAPE diff --git a/InterfaceQT/compojdc.py b/InterfaceQT/compojdc.py new file mode 100644 index 00000000..288e4bec --- /dev/null +++ b/InterfaceQT/compojdc.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- + +from qt import * +from Editeur import Objecttreeitem +from InterfaceQT import browser + + +class Node(browser.JDCNode): + def getPanel(self): + """ + """ + from monRacinePanel import MonRacinePanel + return MonRacinePanel(self,parent=self.editor) + + def doPasteCommande(self,objet_a_copier): + """ + Réalise la copie de l'objet passé en argument qui est nécessairement + une commande + """ + child = self.append_child(objet_a_copier,pos='first',retour='oui') + return child + + +class JDCTreeItem(Objecttreeitem.ObjectTreeItem): + itemNode=Node + + def IsExpandable(self): + return 1 + + def GetText(self): + return " " + + def GetLabelText(self): + # None --> fonte et couleur par défaut + return self.object.nom,None,None + + def get_jdc(self): + """ + Retourne l'objet pointé par self + """ + return self.object + + def GetIconName(self): + if self.object.isvalid(): + return "ast-green-square" + else: + return "ast-red-square" + + def keys(self): + if self.object.etapes_niveaux != []: + return range(len(self.object.etapes_niveaux)) + else: + return range(len(self.object.etapes)) + + def additem(self,name,pos): + cmd = self._object.addentite(name,pos) + return cmd + + def suppitem(self,item) : + # item = item de l'ETAPE à supprimer du JDC + # item.getObject() = ETAPE ou COMMENTAIRE + # self.object = JDC + + itemobject=item.getObject() + if self.object.suppentite(itemobject): + if itemobject.nature == "COMMENTAIRE" : + message = "Commentaire supprimé" + else : + message = "Commande " + itemobject.nom + " supprimée" + self.appli.affiche_infos(message) + return 1 + else: + self.appli.affiche_infos("Pb interne : impossible de supprimer cet objet") + return 0 + + def GetSubList(self): + """ + Retourne la liste des items fils de l'item jdc. + Cette liste est conservee et mise a jour a chaque appel + """ + if self.object.etapes_niveaux != []: + liste = self.object.etapes_niveaux + else: + liste = self.object.etapes + sublist=[None]*len(liste) + # suppression des items lies aux objets disparus + for item in self.sublist: + old_obj=item.getObject() + if old_obj in liste: + pos=liste.index(old_obj) + sublist[pos]=item + else: + pass # objets supprimes ignores + # ajout des items lies aux nouveaux objets + pos=0 + for obj in liste: + if sublist[pos] is None: + # nouvel objet : on cree un nouvel item + item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj) + sublist[pos]=item + pos=pos+1 + + self.sublist=sublist + return self.sublist + + def get_l_noms_etapes(self): + """ Retourne la liste des noms des étapes de self.object""" + return self.object.get_l_noms_etapes() + + def get_liste_cmd(self): + listeCmd = self.object.niveau.definition.get_liste_cmd() + return listeCmd + +import Accas +treeitem =JDCTreeItem +objet = Accas.JDC diff --git a/InterfaceQT/compomacro.py b/InterfaceQT/compomacro.py new file mode 100644 index 00000000..5c959402 --- /dev/null +++ b/InterfaceQT/compomacro.py @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- + +# Modules Python +import os,sys,string +import types +import traceback +from qt import * + +# Modules Eficas +from Editeur import Objecttreeitem +from InterfaceQT import compooper +from InterfaceQT import browser +from InterfaceQT import typeNode + + +class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode): + def getPanel(self): + from monMacroPanel import MonMacroPanel + return MonMacroPanel (self,parent=self.editor ) + + def createPopUpMenu(self): + typeNode.PopUpMenuNode.createPopUpMenu(self) + + +class MACROTreeItem(compooper.EtapeTreeItem): +# """ Cette classe hérite d'une grande partie des comportements +# de la classe compooper.EtapeTreeItem +# """ + itemNode=MACRONode + +# ------------------------------------ +# Classes necessaires à INCLUDE +# ------------------------------------ + +class INCLUDETreeItemBase(MACROTreeItem): + + def __init__(self,appli, labeltext, object, setfunction): + MACROTreeItem.__init__(self,appli, labeltext, object, setfunction) + + def iscopiable(self): + """ + Retourne 1 si l'objet est copiable, 0 sinon + """ + return 0 + + +class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode): + def getPanel(self): + from monIncludePanel import MonIncludePanel + return MonIncludePanel (self,parent=self.editor ) + + def createPopUpMenu(self): + typeNode.PopUpMenuNode.createPopUpMenu(self) + self.menu.insertItem( qApp.translate('Browser','Edit'), self.makeEdit ) + + + def makeEdit(self): #,appli,node + if self.item.object.text_converted == 0: + # Le texte du fichier inclus n'a pas pu etre converti par le module convert + msg="Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n" + msg=msg+self.item.object.text_error + return + + if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None: + #L'include n'est pas initialise + self.item.object.build_include(None,"") + + # On cree un nouvel onglet dans le bureau + self.editor.vm.displayJDC( self.item.object.jdc_aux ) #, self.item.object.jdc_aux.nom ) + + def makeView(self):#,appli,node): + pass #CS_pbruno todo + + + +class INCLUDETreeItem(INCLUDETreeItemBase): + itemNode=INCLUDENode + + +# ------------------------------------ +# Classes necessaires à POURSUITE +# ------------------------------------ + +class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode): +## def getPanel(self): +## """ +## """ +## return INCLUDEPanel( self, self.editor ) + + def makeEdit(self): #,appli,node + if self.item.object.text_converted == 0: + # Le texte du fichier inclus n'a pas pu etre converti par le module convert + msg="Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n" + msg=msg+self.item.object.text_error +## Fenetre(self,titre="Poursuite non editable",texte=msg,wrap='none') #CS_pbruno todo + return + + if not hasattr(self.item.object,"jdc_aux") or self.item.object.jdc_aux is None: + #La poursuite n'est pas initialisee + text="""DEBUT() + FIN()""" + self.object.build_poursuite(None,text) + + # On cree un nouvel onglet dans le bureau +## appli.bureau.ShowJDC( self.item.object.jdc_aux, +## self.item.object.jdc_aux.nom, +## label_onglet=None, +## JDCDISPLAY=macrodisplay.MACRODISPLAY) + self.editor.vm.displayJDC( self.item.object.jdc_aux ) #, self.item.object.jdc_aux.nom ) + + def makeView(self):#,appli,node): + pass #CS_pbruno todo + + + +class POURSUITETreeItem(INCLUDETreeItemBase): + itemNode=POURSUITENode +## def makeEdit(self,appli,node): +## if self.object.text_converted == 0: +## # Le texte du fichier inclus n'a pas pu etre converti par le module convert +## msg="Le fichier de commande n'a pas pu etre converti pour etre editable par Eficas\n\n" +## msg=msg+self.object.text_error +## Fenetre(self,titre="Poursuite non editable",texte=msg,wrap='none') +## return +## +## if not hasattr(self.object,"jdc_aux") or self.object.jdc_aux is None: +## #La poursuite n'est pas initialisee +## text="""DEBUT() +##FIN()""" +## self.object.build_poursuite(None,text) +## +## # On cree un nouvel onglet dans le bureau +## appli.bureau.ShowJDC(self.object.jdc_aux,self.object.jdc_aux.nom, +## label_onglet=None, +## JDCDISPLAY=macrodisplay.MACRODISPLAY) +## +## def makeView(self,appli,node): +## if not hasattr(self.object,"jdc_aux") or self.object.jdc_aux is None: +## showerror("Poursuite vide","Une POURSUITE doit etre correctement initialisée pour etre visualisée") +## return +## nom=self.object.nom +## if hasattr(self.object,'fichier_ini'): +## if self.object.fichier_ini is None: +## nom=nom+' '+"Fichier non défini" +## else: +## nom=nom+' '+self.object.fichier_ini +## macdisp=macrodisplay.makeMacroDisplay(appli,self,nom) + +class INCLUDE_MATERIAUTreeItem(INCLUDETreeItemBase): + rmenu_specs=[("View","makeView"), + ] + def iscopiable(self): + """ + Retourne 1 si l'objet est copiable, 0 sinon + """ + return 1 + + +def treeitem(appli, labeltext, object, setfunction=None): + """ Factory qui retourne l'item adapté au type de macro : + INCLUDE, POURSUITE, MACRO + """ + if object.nom == "INCLUDE_MATERIAU": + return INCLUDE_MATERIAUTreeItem(appli, labeltext, object, setfunction) + elif object.nom == "INCLUDE": + return INCLUDETreeItem(appli, labeltext, object, setfunction) + elif object.nom == "POURSUITE": + return POURSUITETreeItem(appli, labeltext, object, setfunction) + else: + return MACROTreeItem(appli, labeltext, object, setfunction) + +import Accas +objet=Accas.MACRO_ETAPE + +#import macrodisplay + diff --git a/InterfaceQT/compomclist.py b/InterfaceQT/compomclist.py new file mode 100644 index 00000000..6a3102a0 --- /dev/null +++ b/InterfaceQT/compomclist.py @@ -0,0 +1,205 @@ +# -*- coding: utf-8 -*- + +import types +import traceback + +from qt import * + +from InterfaceQT import compofact +from InterfaceQT import browser +from Editeur import Objecttreeitem +from Noyau.N_OBJECT import ErrorObj +#import compoerror + + +class Node(browser.JDCNode): + def getPanel(self): + """ + """ + if self.item.isMCList() : + if self.item.ajout_possible(): + from monMCListAjoutPanel import MonMCListAjoutPanel + return MonMCListAjoutPanel(self,parent=self.editor) + else : + print "MCList" + elif self.item.isMCFact() : + from monMCFactPanel import MonMCFactPanel + return MonMCFactPanel(self,parent=self.editor) + else : + print "MCList" + + def doPaste(self,node_selected): + objet_a_copier = self.item.get_copie_objet() + child=node_selected.doPaste_MCF(objet_a_copier) + #print "doPaste",child + return child + + def doPaste_MCF(self,objet_a_copier): + child=None + # le noeud courant est une MCList + if self.item.isMCList() : + child = self.append_child(objet_a_copier,pos='first',retour='oui') + + # le noeud courant est un MCFACT + elif self.item.isMCFact() : + # le noeud selectionne est un MCFACT dans une MCList + if self.parent.item.isMCList(): + child = self.parent.append_child(objet_a_copier, + pos=self.item, + retour='oui') + + # le noeud MCFACT selectionne n'est pas dans une MCList + else: + child = self.parent.append_child(objet_a_copier,retour='oui') + + else: + QMessageBox.information( self, "Copie impossible", + "Vous ne pouvez coller le mot-clé facteur copié à ce niveau de l'arborescence !") + self.editor.affiche_infos("Copie refusée") + + return child + +class MCListTreeItem(Objecttreeitem.SequenceTreeItem,compofact.FACTTreeItem): + """ La classe MCListTreeItem joue le role d'un adaptateur pour les objets + du noyau Accas instances de la classe MCLIST. + Elle adapte ces objets pour leur permettre d'etre intégrés en tant que + noeuds dans un arbre graphique (voir treewidget.py et ObjectTreeItem.py). + Cette classe délègue les appels de méthode et les accès + aux attributs à l'objet du noyau soit manuellement soit + automatiquement (voir classe Delegate et attribut object). + """ + itemNode=Node + + def init(self): + # Si l'objet Accas (MCList) a moins d'un mot cle facteur + # on utilise directement ce mot cle facteur comme delegue + self.updateDelegate() + + def updateDelegate(self): + if len(self._object) > 1: + self.setdelegate(self._object) + else: + self.setdelegate(self._object.data[0]) + + def panel(self,jdcdisplay,pane,node): + """ Retourne une instance de l'objet panneau associe a l'item (self) + Si la liste ne contient qu'un mot clé facteur, on utilise le panneau + FACTPanel. + Si la liste est plus longue on utilise le panneau MCLISTPanel. + """ + if len(self._object) > 1: + return MCLISTPanel(jdcdisplay,pane,node) + elif isinstance(self._object.data[0],ErrorObj): + return compoerror.ERRORPanel(jdcdisplay,pane,node) + else: + return compofact.FACTPanel(jdcdisplay,pane,node) + + def IsExpandable(self): + if len(self._object) > 1: + return Objecttreeitem.SequenceTreeItem.IsExpandable(self) + else: + return compofact.FACTTreeItem.IsExpandable(self) + + def GetSubList(self): + self.updateDelegate() + if len(self._object) <= 1: + self._object.data[0].alt_parent=self._object + return compofact.FACTTreeItem.GetSubList(self) + + liste=self._object.data + sublist=[None]*len(liste) + # suppression des items lies aux objets disparus + for item in self.sublist: + old_obj=item.getObject() + if old_obj in liste: + pos=liste.index(old_obj) + sublist[pos]=item + else: + pass # objets supprimes ignores + # ajout des items lies aux nouveaux objets + pos=0 + for obj in liste: + if sublist[pos] is None: + # nouvel objet : on cree un nouvel item + def setfunction(value, object=obj): + object=value + item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction) + sublist[pos]=item + #Attention : on ajoute une information supplementaire pour l'actualisation de + # la validite. L'attribut parent d'un MCFACT pointe sur le parent de la MCLISTE + # et pas sur la MCLISTE elle meme ce qui rompt la chaine de remontee des + # informations de validite. alt_parent permet de remedier a ce defaut. + obj.alt_parent=self._object + pos=pos+1 + + self.sublist=sublist + return self.sublist + + def GetIconName(self): + if self._object.isvalid(): + return "ast-green-los" + elif self._object.isoblig(): + return "ast-red-los" + else: + return "ast-yel-los" + + def get_docu(self): + """ Retourne la clef de doc de l'objet pointé par self """ + return self.object.get_docu() + + def iscopiable(self): + if len(self._object) > 1: + return Objecttreeitem.SequenceTreeItem.iscopiable(self) + else: + return compofact.FACTTreeItem.iscopiable(self) + + def isMCFact(self): + """ + Retourne 1 si l'objet pointé par self est un MCFact, 0 sinon + """ + return len(self._object) <= 1 + + def isMCList(self): + """ + Retourne 1 si l'objet pointé par self est une MCList, 0 sinon + """ + return len(self._object) > 1 + + def get_copie_objet(self): + return self._object.data[0].copy() + + def additem(self,obj,pos): + #print "compomclist.additem",obj,pos + if len(self._object) <= 1: + return compofact.FACTTreeItem.additem(self,obj,pos) + + o= self.object.addentite(obj,pos) + return o + + def suppitem(self,item): + """ + Retire un objet MCFACT de la MCList (self.object) + """ + #print "compomclist.suppitem",item + obj=item.getObject() + if len(self._object) <= 1: + return compofact.FACTTreeItem.suppitem(self,item) + + if self.object.suppentite(obj): + if len(self._object) == 1: self.updateDelegate() + message = "Mot-clef " + obj.nom + " supprimé" + self.appli.affiche_infos(message) + return 1 + else: + self.appli.affiche_infos('Impossible de supprimer ce mot-clef') + return 0 + + +import Accas +objet = Accas.MCList + +def treeitem(appli,labeltext,object,setfunction): + """ Factory qui produit un objet treeitem adapte a un objet + Accas.MCList (attribut objet de ce module) + """ + return MCListTreeItem(appli,labeltext,object,setfunction) diff --git a/InterfaceQT/componiveau.py b/InterfaceQT/componiveau.py new file mode 100644 index 00000000..37b38b7f --- /dev/null +++ b/InterfaceQT/componiveau.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- + +from qt import * +from Editeur import Objecttreeitem +from Extensions import commentaire +from InterfaceQT import browser + +class Node(browser.JDCNode): pass +## def getPanel(self): +## """ +## """ +## return NIVEAUPanel( self, self.editor ) + +class NIVEAUTreeItem(Objecttreeitem.ObjectTreeItem): +## panel = NIVEAUPanel + itemNode=Node + + def isactif(self): + return self.object.isactif() + + def IsExpandable(self): + return 1 + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + if self.isactif(): + fonte = Fonte_Niveau + else : + fonte = Fonte_Niveau_inactif + return self.labeltext,fonte,'#00008b' + + def GetIconName(self): + if self.isactif(): + if self.object.isvalid(): + return "ast-green-text" + else: + return "ast-red-text" + else: + return "ast-white-text" + + def keys(self): + if self.object.etapes_niveaux != []: + return range(len(self.object.etapes_niveaux)) + else: + return range(len(self.object.etapes)) + + def GetSubList(self): + sublist=[] + for key in self.keys(): + if self.object.etapes_niveaux != []: + liste = self.object.etapes_niveaux + else: + liste = self.object.etapes + try: + value = liste[key] + except KeyError: + continue + def setfunction(value, key=key, object=liste): + object[key] = value + item =self.make_objecttreeitem(self.appli,value.ident() + " : ", value, setfunction) + sublist.append(item) + return sublist + + def additem(self,name,pos): + if isinstance(name,Objecttreeitem.TreeItem) : + cmd=self.object.addentite(name.getObject(),pos) + else : + cmd = self.object.addentite(name,pos) + item = self.make_objecttreeitem(self.appli,cmd.nom + " : ", cmd) + return item + + def suppitem(self,item) : + # item = item de l'ETAPE à supprimer du JDC + # item.getObject() = ETAPE ou COMMENTAIRE + # self.object = JDC + itemobject=item.getObject() + if self.object.suppentite(itemobject): + if isinstance(item.object,commentaire.COMMENTAIRE): + message = "Commentaire supprimé" + else : + message = "Commande " + itemobject.nom + " supprimée" + self.appli.affiche_infos(message) + return 1 + else: + self.appli.affiche_infos("Pb interne : impossible de supprimer cet objet") + return 0 + + def GetText(self): + return '' + + +import Accas +treeitem = NIVEAUTreeItem +objet = Accas.ETAPE_NIVEAU diff --git a/InterfaceQT/componuplet.py b/InterfaceQT/componuplet.py new file mode 100644 index 00000000..649ce0e2 --- /dev/null +++ b/InterfaceQT/componuplet.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import types +from repr import Repr +from copy import copy,deepcopy + +# Modules Eficas +from Editeur import Objecttreeitem + +myrepr = Repr() +myrepr.maxstring = 100 +myrepr.maxother = 100 + +# Si Expandable vaut 1 les éléments du nuplet apparaissent dans l'arbre +# Si Expandable vaut 0 les éléments n'apparaissent pas +Expandable=1 + + +import browser +from qt import * + +class Node(browser.JDCNode): pass +## def getPanel(self): +## """ +## """ +## return NUPLETPanel( self, self.editor ) + + +class NUPLETTreeItem(Objecttreeitem.ObjectTreeItem): +## panel=NUPLETPanel + itemNode=Node + + def IsExpandable(self): + return Expandable + + def GetText(self): + return '' + + def isvalid(self): + return self.object.isvalid() + + def GetIconName(self): + if self.object.isvalid(): + return "ast-green-los" + elif self.object.isoblig(): + return "ast-red-los" + else: + return "ast-yel-los" + + def GetSubList(self): + if not Expandable:return [] + sublist=[] + for obj in self.object.mc_liste: + item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, None) + sublist.append(item) + return sublist + + def additem(self,name,pos): + raise "NUPLET" + + def suppitem(self,item) : + raise "NUPLET" + +import Accas +treeitem=NUPLETTreeItem +objet=Accas.MCNUPLET diff --git a/InterfaceQT/compooper.py b/InterfaceQT/compooper.py new file mode 100644 index 00000000..1611cea1 --- /dev/null +++ b/InterfaceQT/compooper.py @@ -0,0 +1,245 @@ +# -*- coding: utf-8 -*- + +import traceback +import string + +from qt import * + +from Editeur import Objecttreeitem +from InterfaceQT import browser +from InterfaceQT import typeNode + +class Node(browser.JDCNode, typeNode.PopUpMenuNode): + def getPanel( self ): + """ + """ + from monCommandePanel import MonCommandePanel + return MonCommandePanel(self,parent=self.editor) + + def createPopUpMenu(self): + typeNode.PopUpMenuNode.createPopUpMenu(self) + + def doPaste(self,node_selected): + """ + Déclenche la copie de l'objet item avec pour cible + l'objet passé en argument : node_selected + """ + objet_a_copier = self.item.get_copie_objet() + child=node_selected.doPaste_Commande(objet_a_copier) + return child + + def doPasteCommande(self,objet_a_copier): + """ + Réalise la copie de l'objet passé en argument qui est nécessairement + une commande + """ + parent=self.parent + #child = parent.item.append_child(objet_a_copier,self.item.getObject()) + child = self.append_brother(objet_a_copier,retour='oui') + #if child is None:return 0 + return child + + def doPaste_MCF(self,objet_a_copier): + """ + Réalise la copie de l'objet passé en argument (objet_a_copier) + Il s'agit forcément d'un mot clé facteur + """ + child = self.append_child(objet_a_copier,pos='first',retour='oui') + return child + + +class EtapeTreeItem(Objecttreeitem.ObjectTreeItem): + """ La classe EtapeTreeItem est un adaptateur des objets ETAPE du noyau + Accas. Elle leur permet d'etre affichés comme des noeuds + d'un arbre graphique. + Cette classe a entre autres deux attributs importants : + - _object qui est un pointeur vers l'objet du noyau + - object qui pointe vers l'objet auquel sont délégués les + appels de méthode et les acces aux attributs + Dans le cas d'une ETAPE, _object et object pointent vers le + meme objet. + """ + itemNode=Node + + def IsExpandable(self): + return 1 + + def GetIconName(self): + """ + Retourne le nom de l'icône à afficher dans l'arbre + Ce nom dépend de la validité de l'objet + """ + if not self.object.isactif(): + return "ast-white-square" + elif self.object.isvalid(): + return "ast-green-square" + else: + return "ast-red-square" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + if self.object.isactif(): + # None --> fonte et couleur par défaut + return self.labeltext,None,None + else: + return self.labeltext, None, None #CS_pbruno todo + + def get_objet(self,name) : + for v in self.object.mc_liste: + if v.nom == name : return v + return None + + def get_type_sd_prod(self): + """ + Retourne le nom du type du concept résultat de l'étape + """ + sd_prod=self.object.get_type_produit() + if sd_prod: + return sd_prod.__name__ + else: + return "" + + def additem(self,name,pos): + print "CS_PBRUNO compooper.additem",name,pos + mcent = self._object.addentite(name,pos) + print "CS_PBRUNO mcent ",mcent + return mcent + + + def suppitem(self,item) : + # item : item du MOCLE de l'ETAPE a supprimer + # item.getObject() = MCSIMP, MCFACT, MCBLOC ou MCList + itemobject=item.getObject() + if itemobject.isoblig() : + self.appli.affiche_infos('Impossible de supprimer un mot-clé obligatoire ') + return 0 + if self.object.suppentite(itemobject): + message = "Mot-clé " + itemobject.nom + " supprimé" + self.appli.affiche_infos(message) + return 1 + else : + self.appli.affiche_infos('Pb interne : impossible de supprimer ce mot-clé') + return 0 + + def GetText(self): + try: + return self.object.get_sdname() + except: + return '' + + def keys(self): + keys=self.object.mc_dict.keys() + return keys + + def GetSubList(self): + """ + Reactualise la liste des items fils stockes dans self.sublist + """ + if self.isactif(): + liste=self.object.mc_liste + else: + liste=[] + + sublist=[None]*len(liste) + # suppression des items lies aux objets disparus + for item in self.sublist: + old_obj=item.getObject() + if old_obj in liste: + pos=liste.index(old_obj) + sublist[pos]=item + else: + pass # objets supprimes ignores + + # ajout des items lies aux nouveaux objets + pos=0 + for obj in liste: + if sublist[pos] is None: + # nouvel objet : on cree un nouvel item + def setfunction(value, object=obj): + object.setval(value) + item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction) + sublist[pos]=item + pos=pos+1 + + self.sublist=sublist + return self.sublist + + def isvalid(self): + return self.object.isvalid() + + def iscopiable(self): + """ + Retourne 1 si l'objet est copiable, 0 sinon + """ + return 1 + + def update(self,item): + if item.sd and item.sd.nom: + self.nomme_sd(item.sd.nom) + + def nomme_sd(self,nom): + """ Lance la méthode de nommage de la SD """ + oldnom="" + if self.object.sd != None : + oldnom=self.object.sd.nom + test,mess= self.object.nomme_sd(nom) + if test:self.object.parent.reset_context() + if (test and self.appli.dict_reels.has_key(oldnom) ): + self.appli.dict_reels[nom]=self.appli.dict_reels[oldnom] + return test,mess + + def is_reentrant(self): + return self.object.is_reentrant() + + def get_noms_sd_oper_reentrant(self): + return self.object.get_noms_sd_oper_reentrant() + + def get_objet_commentarise(self): + """ + Cette méthode retourne un objet commentarisé + représentatif de self.object + """ + # Format de fichier utilisé + format=self.appli.format_fichier.get() + return self.object.get_objet_commentarise(format) + + def get_objet_commentarise_BAK(self): + """ + Cette méthode retourne un objet commentarisé + représentatif de self.object + """ + import generator,string,Accas + # Format de fichier utilisé + format=self.appli.format_fichier.get() + g=generator.plugins[format]() + texte_commande = g.gener(self.object,format='beautifie') + # Il faut enlever la première ligne vide de texte_commande que + # rajoute le generator + rebut,texte_commande = string.split(texte_commande,'\n',1) + # on construit l'objet COMMANDE_COMM repésentatif de self mais non + # enregistré dans le jdc + commande_comment = Accas.COMMANDE_COMM(texte=texte_commande,reg='non', + parent=self.object.parent) + commande_comment.niveau = self.object.niveau + commande_comment.jdc = commande_comment.parent = self.object.jdc + + pos=self.object.parent.etapes.index(self.object) + parent=self.object.parent + self.object.parent.suppentite(self.object) + parent.addentite(commande_comment,pos) + + return commande_comment + + def visu_3D(self,appli,node) : + import TroisDPal + troisD=TroisDPal.TroisDPilote(node.item,appli,node.parent) + troisD.envoievisu() + +import Accas +treeitem = EtapeTreeItem +objet = Accas.ETAPE + diff --git a/InterfaceQT/compoparam.py b/InterfaceQT/compoparam.py new file mode 100644 index 00000000..cfdf276a --- /dev/null +++ b/InterfaceQT/compoparam.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- +""" + Ce module contient les classes permettant de définir les objets graphiques + représentant un objet de type PARAMETRE, cad le panneau et l'item de l'arbre + d'EFICAS +""" + +# import modules Python +import string +from qt import * + +# import modules EFICAS +from Editeur import Objecttreeitem +from InterfaceQT import browser +from InterfaceQT import typeNode + + +class Node(browser.JDCNode,typeNode.PopUpMenuNode): + def getPanel(self): + """ + """ + from monParamPanel import MonParamPanel + return MonParamPanel(self, parent=self.editor ) + + def createPopUpMenu(self): + typeNode.PopUpMenuNode.createPopUpMenu(self) + + + + +class PARAMTreeItem(Objecttreeitem.ObjectTreeItem): + """ + Classe servant à définir l'item porté par le noeud de l'arbre d'EFICAS + qui représente le PARAMETRE + """ + itemNode=Node + + def init(self): + self.setfunction = self.set_valeur + +# --------------------------------------------------------------------------- +# API du PARAMETRE pour l'arbre +# --------------------------------------------------------------------------- + + def GetIconName(self): + """ + Retourne le nom de l'icone associée au noeud qui porte self, + dépendant de la validité de l'objet + NB : un PARAMETRE est toujours valide ... + """ + if self.isactif(): + if self.isvalid(): + return "ast-green-square" + else: + return "ast-red-square" + else: + return "ast-white-square" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte à afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + return 'Parametre',None,None + + def GetText(self): + """ + Retourne le texte à afficher aprês le nom de la commande (ici aprês 'paramêtre') + Ce texte est tronqué à 25 caractêres + """ + texte = repr(self.object) + texte = string.split(texte,'\n')[0] + if len(texte) < 25 : + return texte + else : + return texte[0:24]+'...' + + def GetSubList(self): + """ + Retourne la liste des fils de self + """ + return [] + +# --------------------------------------------------------------------------- +# Méthodes permettant la modification et la lecture des attributs +# du paramêtre = API graphique du PARAMETRE pour Panel et EFICAS +# --------------------------------------------------------------------------- + + def get_valeur(self): + """ + Retourne la valeur de l'objet PARAMETRE cad son texte + """ + if self.object.valeur is None: return '' + else: return self.object.valeur + + def get_nom(self): + """ + Retourne le nom du paramêtre + """ + return self.object.nom + + def set_valeur(self,new_valeur): + """ + Affecte valeur à l'objet PARAMETRE + """ + self.object.set_valeur(new_valeur) + + def set_nom(self,new_nom): + """ + Renomme le paramêtre + """ + self.object.set_nom(new_nom) + #self.object.set_attribut('nom',new_nom) + + def get_fr(self): + """ + Retourne le fr associé au paramêtre, cad la bulle d'aide pour EFICAS + """ + return "Définition d'un paramêtre" + +import Extensions.parametre +treeitem =PARAMTreeItem +objet = Extensions.parametre.PARAMETRE diff --git a/InterfaceQT/compoparameval.py b/InterfaceQT/compoparameval.py new file mode 100644 index 00000000..ff0d1b94 --- /dev/null +++ b/InterfaceQT/compoparameval.py @@ -0,0 +1,153 @@ +# -*- coding: utf-8 -*- + +""" +Ce module contient les classes permettant de définir les objets graphiques +représentant un objet de type PARAMETRE_EVAL, cad le panneau et l'item de l'arbre +d'EFICAS +""" + +# import modules Python +import string + +# import modules EFICAS + +import Objecttreeitem + + +import browser +from qt import * + +class Node(browser.JDCNode): pass +## def getPanel(self): +## """ +## """ +## return PARAM_EVALPanel( self, self.editor ) + + +class PARAM_EVALTreeItem(Objecttreeitem.ObjectTreeItem): + """ + Classe servant a définir l'item porté par le noeud de l'arbre d'EFICAS + qui représente le PARAMETRE + """ + itemNode=Node +## panel = PARAM_EVALPanel + + def init(self): + self.setfunction = self.set_valeur + +# --------------------------------------------------------------------------- +# API du PARAMETRE pour l'arbre +# --------------------------------------------------------------------------- + + def GetIconName(self): + """ + Retourne le nom de l'icone associée au noeud qui porte self, + dépendant de la validité de l'objet + NB : un PARAMETRE est toujours valide ... + """ + if self.isactif(): + if self.isvalid(): + return "ast-green-square" + else: + return "ast-red-square" + else: + return "ast-white-square" + + def GetLabelText(self): + """ Retourne 3 valeurs : + - le texte a afficher dans le noeud représentant l'item + - la fonte dans laquelle afficher ce texte + - la couleur du texte + """ + return 'EVAL',Fonte_PARAMETRE,None + + def GetText(self): + """ + Retourne le texte a afficher apres le nom de la commande (ici apres 'parametre') + Ce texte est tronqué a 25 caracteres + """ + texte = repr(self.object) + texte = string.split(texte,'\n')[0] + if len(texte) < 25 : + return texte + else : + return texte[0:24]+'...' + + def GetSubList(self): + """ + Retourne la liste des fils de self + """ + return [] + +# --------------------------------------------------------------------------- +# Méthodes permettant la modification et la lecture des attributs +# du parametre = API graphique du PARAMETRE pour Panel et EFICAS +# --------------------------------------------------------------------------- + + def isvalid(self): + """ + Indique si l'objet pointé par self est valide + """ + return self.object.isvalid() + + def get_valeur(self): + """ + Retourne une chaine représentant la valeur de l'objet PARAMETRE + cad de l'objet class_eval.EVAL + """ + return self.object.get_valeur() or '' + + def get_nom(self): + """ + Retourne le nom du parametre + """ + return self.object.get_nom() + + def set_valeur(self,new_valeur): + """ + Affecte new_valeur a l'objet PARAMETRE_EVAL + """ + # on construit le texte de la nouvelle valeur + new_valeur = 'EVAL("""'+new_valeur+'""")' + # on affecte la nouvelle valeur a self.object + self.object.set_valeur(new_valeur) + + def set_nom(self,new_nom): + """ + Renomme le parametre + """ + self.object.set_nom(new_nom) + + def get_fr(self): + """ + Retourne le fr associé au parametre, cad la bulle d'aide pour EFICAS + """ + return "Définition d'un parametre de type EVAL" + + def verif_nom(self,nom): + """ + Lance la vérification de validité du nom passé en argument + """ + return self.object.verif_nom(nom = nom) + + def verif_eval(self,valeur): + """ + Lance la vérification de validité de l'expression EVAL passée en argument + """ + return self.object.verif_eval(exp_eval = valeur) + + def save_parametre_eval(self,new_nom,new_val): + """ + Vérifie si (new_nom,new_val) définit bien un EVAL licite : + - si oui, stocke ces parametres comme nouveaux parametres de l'EVAL courant et retourne 1 + - si non, laisse les parametres anciens de EVAL inchangés et retourne 0 + """ + test,erreur = self.object.verif_parametre_eval(param=(new_nom,new_val)) + if test : + # la formule est bien correcte : on sauve les nouveaux parametres + self.object.update(param=(new_nom,new_val)) + return test,erreur + +import Extensions.parametre_eval +treeitem =PARAM_EVALTreeItem +objet = Extensions.parametre_eval.PARAMETRE_EVAL diff --git a/InterfaceQT/compoproc.py b/InterfaceQT/compoproc.py new file mode 100644 index 00000000..c128496a --- /dev/null +++ b/InterfaceQT/compoproc.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from Editeur import Objecttreeitem +from InterfaceQT import compooper +from InterfaceQT import browser +from InterfaceQT import typeNode + +from qt import * + +class Node(browser.JDCNode,typeNode.PopUpMenuNode): + def getPanel(self): + from monMacroPanel import MonMacroPanel + return MonMacroPanel(self,parent=self.editor) + + def createPopUpMenu(self): + typeNode.PopUpMenuNode.createPopUpMenu(self) + + +class ProcEtapeTreeItem(compooper.EtapeTreeItem): + itemNode=Node + +import Accas +treeitem = ProcEtapeTreeItem +objet = Accas.PROC_ETAPE + diff --git a/InterfaceQT/composimp.py b/InterfaceQT/composimp.py new file mode 100644 index 00000000..96de9a9c --- /dev/null +++ b/InterfaceQT/composimp.py @@ -0,0 +1,636 @@ +# -*- coding: utf-8 -*- +# Modules Python +import string,types,os + +from copy import copy,deepcopy +import traceback +from qt import * + +# Modules Eficas +from Editeur import Objecttreeitem +from Aster import prefs +from InterfaceQT import browser +from Noyau.N_CR import justify_text + + +class Node(browser.JDCNode): + def getPanel(self): + """ + """ + klass = None + + # Attention l ordre des if est important + if self.item.wait_shell(): + # l'objet attend un shell + # a priori jamais + print "Pb : Panneau Shell attendu" + print "Pb : Prevenir la maintenance" + klass = None #CS_pbruno todo + return None + + # l'objet prend sa (ses) valeur(s) dans un ensemble discret de valeurs + if self.item.has_into(): + if self.item.is_list() : + from monPlusieursIntoPanel import MonPlusieursIntoPanel + klass = MonPlusieursIntoPanel + else: + from monUniqueIntoPanel import MonUniqueIntoPanel + klass = MonUniqueIntoPanel + + # l'objet prend une ou des valeurs a priori quelconques + else: + # on attend une liste de valeurs + if self.item.is_list() : + # on attend une liste de SD + if self.item.wait_assd(): + from monPlusieursASSDPanel import MonPlusieursASSDPanel + klass = MonPlusieursASSDPanel + else: + # on attend une liste de valeurs de types debase (entiers, réels,...) + from monPlusieursBasePanel import MonPlusieursBasePanel + klass = MonPlusieursBasePanel + # on n'attend qu'une seule valeur + else: + # on attend une SD ou un objet de la classe CO (qui n'existe pas encore) + if self.item.wait_co(): + if len(self.item.get_sd_avant_du_bon_type()) != 0 : + from monUniqueSDCOIntoPanel import MonUniqueSDCOIntoPanel + klass = MonUniqueSDCOIntoPanel + else : + from monUniqueSDCOPanel import MonUniqueSDCOPanel + klass = MonUniqueSDCOPanel + + # on attend une SD + elif self.item.wait_assd(): + if 'R' in self.item.GetType(): + from monUniqueASSDPanel import MonUniqueASSDReelPanel + klass = MonUniqueASSDReelPanel + else : + from monUniqueASSDPanel import MonUniqueASSDPanel + klass = MonUniqueASSDPanel + + # on attend une valeur d'un type de base (entier,reel,...) + else: + # on attend un complexe + if self.item.wait_complex(): + from monUniqueCompPanel import MonUniqueCompPanel + klass = MonUniqueCompPanel + else: + # on attend un entier, un réel ou une string + from monUniqueBasePanel import MonUniqueBasePanel + klass = MonUniqueBasePanel + + # cas particulier des fonctions + genea = self.item.get_genealogie() + if "VALE" in genea or "VALE_C" in genea: + if "DEFI_FONCTION" in genea : + from monFonctionPanel import MonFonctionPanel + klass = MonFonctionPanel + + #--------------------------------------------------------- + # PN ajout pour lancement de Salome + #--------------------------------------------------------- + if hasattr( self.editor, 'salome' ): +## import panelsSalome +## +## self.item.select_noeud_maille=0 +## self.item.clef_fonction="SALOME" +## for i in range(0,len( genea )) : +## self.item.clef_fonction=self.item.clef_fonction+"_"+ genea[i] +## #if genea[i] == "GROUP_NO" or genea[i] == "GROUP_MA": +## if "GROUP_NO" in genea[len(genea)-1] or "GROUP_MA" in genea[len(genea)-1]: +## self.item.select_noeud_maille=1 +## +## recherche=panelsSalome.dict_classes_salome[klass] +## if hasattr(recherche,self.item.clef_fonction): +## klass=recherche +## if self.item.select_noeud_maille==1 : +## klass=recherche + klass = None #CS_pbruno todo + + if not klass: + return None + + return klass( self, self.editor ) + + + +class SIMPTreeItem(Objecttreeitem.AtomicObjectTreeItem): + itemNode=Node + + def init(self) : + self.expandable = 0 + + + #----------------------------------------------- + # + # Methodes liees aux informations sur le Panel + # ou au mot-clef simple + # + #----------------------------------------------- + # is_list + # get_into a priori inutile --> commentee + # has_into + # wait_into a priori inutile --> commentee + # GetMinMax + # GetMultiplicite + # GetIntervalle + # GetListeValeurs + # get_liste_possible + + def is_list(self): + """ + Cette méthode indique si le mot cle simple attend une liste (valeur de retour 1) + ou s'il n'en attend pas (valeur de retour 0) + + Deux cas principaux peuvent se presenter : avec validateurs ou bien sans. + Dans le cas sans validateur, l'information est donnée par l'attribut max + de la definition du mot cle. + Dans le cas avec validateur, il faut combiner l'information précédente avec + celle issue de l'appel de la méthode is_list sur le validateur.On utilisera + l'operateur ET pour effectuer cette combinaison (AndVal). + """ + is_a_list=0 + min,max = self.GetMinMax() + assert (min <= max) + if max > 1 : + is_a_list=1 + # Dans le cas avec validateurs, pour que le mot cle soit considéré + # comme acceptant une liste, il faut que max soit supérieur a 1 + # ET que la méthode is_list du validateur retourne 1. Dans les autres cas + # on retournera 0 (n'attend pas de liste) + if self.definition.validators : + is_a_list= self.definition.validators.is_list() * is_a_list + return is_a_list + + #def get_into(self,liste_courante=None): + # """ + # Cette méthode retourne la liste de choix proposée par le mot cle. Si le mot cle ne propose + # pas de liste de choix, la méthode retourne None. + # L'argument d'entrée liste_courante, s'il est différent de None, donne la liste des choix déja + # effectués par l'utilisateur. Dans ce cas, la méthode get_into doit calculer la liste des choix + # en en tenant compte. + # Cette méthode part du principe que la relation entre into du mot clé et les validateurs est + # une relation de type ET (AndVal). + # """ + # if not self.object.definition.validators : + # return self.object.definition.into + # else: + # return self.object.definition.validators.get_into(liste_courante,self.definition.into) + + def has_into(self): + """ + Cette méthode indique si le mot cle simple propose un choix (valeur de retour 1) + ou s'il n'en propose pas (valeur de retour 0) + + Deux cas principaux peuvent se presenter : avec validateurs ou bien sans. + Dans le cas sans validateur, l'information est donnée par l'attribut into + de la definition du mot cle. + Dans le cas avec validateurs, pour que le mot cle soit considéré + comme proposant un choix, il faut que into soit présent OU + que la méthode has_into du validateur retourne 1. Dans les autres cas + on retournera 0 (ne propose pas de choix) + """ + has_an_into=0 + if self.definition.into: + has_an_into=1 + elif self.definition.validators : + has_an_into= self.definition.validators.has_into() + return has_an_into + + + def GetMinMax(self): + """ Retourne les valeurs min et max de la définition de object """ + return self.object.get_min_max() + + def GetMultiplicite(self): + """ A préciser. + Retourne la multiplicité des valeurs affectées a l'objet + représenté par l'item. Pour le moment retourne invariablement 1. + """ + return 1 + + def GetIntervalle(self): + """ + Retourne le domaine de valeur attendu par l'objet représenté + par l'item. + """ + return self.object.getintervalle() + + def GetListeValeurs(self) : + """ Retourne la liste des valeurs de object """ + valeurs=self.object.get_liste_valeurs() + try : + if "R" in self.object.definition.type: + clef=self.object.GetNomConcept() + if self.appli.dict_reels.has_key(clef): + if type(valeurs) == types.TupleType: + valeurs_reelles=[] + for val in valeurs : + if self.appli.dict_reels[clef].has_key(val) : + valeurs_reelles.append(self.appli.dict_reels[clef][val]) + else : + valeurs_reelles.append(val) + else : + if self.appli.dict_reels[clef].has_key(valeurs): + valeurs_reelles=self.appli.dict_reels[clef][valeurs] + valeurs=valeurs_reelles + except : + pass + return valeurs + + def get_liste_possible(self,listeActuelle=[]): + if hasattr(self.definition.validators,'into'): + valeurspossibles = self.definition.validators.into + else: + valeurspossibles = self.get_definition().into + + #On ne garde que les items valides + listevalideitem=[] + for item in valeurspossibles: + encorevalide=self.valide_item(item) + if encorevalide : + listevalideitem.append(item) + + #on ne garde que les choix possibles qui passent le test de valide_liste_partielle + listevalideliste=[] + for item in listevalideitem: + encorevalide=self.valide_liste_partielle(item,listeActuelle) + if encorevalide : + listevalideliste.append(item) + return listevalideliste + + def get_liste_param_possible(self): + liste_param=[] + for param in self.object.jdc.params: + encorevalide=self.valide_item(param.valeur) + if encorevalide: + type_param=param.valeur.__class__.__name__ + for typ in self.definition.type: + if typ=='R': + liste_param.append(param) + if typ=='I' and type_param=='int': + liste_param.append(param) + if typ=='TXM' and type_param=='str': + liste_param.append(repr(param)) + if ('grma' in repr(typ)) and type_param=='str': + liste_param.append(param.nom) + return liste_param + + #-------------------------------------------------- + # + # Methodes liees a la validite des valeurs saisies + # + #--------------------------------------------------- + # valide_item + # valide_liste_partielle + # valide_liste_complete + # info_erreur_item + # info_erreur_liste + # IsInIntervalle + # isvalid + + def valide_item(self,item): + """ + La validation est réalisée directement par l'objet + """ + return self.object.valide_item(item) + + def valide_liste_partielle(self,item,listecourante): + #On protege la liste en entree en la copiant + valeur=listecourante[:] + valeur.append(item) + return self.object.valid_valeur_partielle(valeur) + + def valide_liste_complete (self,valeur): + return self.object.valid_valeur(valeur) + + def valide_val (self,valeur): + return self.object.valid_val(valeur) + + def info_erreur_item(self) : + commentaire="" + if self.definition.validators : + commentaire=self.definition.validators.info_erreur_item() + return commentaire + + def aide(self) : + commentaire="" + if self.definition.validators : + commentaire=self.definition.validators.aide() + return commentaire + + def info_erreur_liste(self) : + commentaire="" + if self.definition.validators : + commentaire=self.definition.validators.info_erreur_liste() + return commentaire + + def IsInIntervalle(self,valeur): + """ + Retourne 1 si la valeur est dans l'intervalle permis par + l'objet représenté par l'item. + """ + return self.valide_item(valeur) + + def isvalid(self): + valide=self.object.isvalid() + return valide + + #-------------------------------------------------- + # + # Autres ... + # + #--------------------------------------------------- + # SetText a priori inutilisee --> commentee + # GetIconName + # GetText + # getval a priori inutilisee --> commentee + # set_valeur_co + # get_sd_avant_du_bon_type + # verif a priori inutilisee --> commentee + # delete_valeur_co + + #def SetText(self, text): + # try: + # value = eval(text) + # self.object.setval(value) + # except: + # pass + + def GetIconName(self): + if self.isvalid(): + return "ast-green-ball" + elif self.object.isoblig(): + return "ast-red-ball" + else: + return "ast-yel-ball" + + def GetText(self): + """ + Classe SIMPTreeItem + Retourne le texte a afficher dans l'arbre représentant la valeur de l'objet + pointé par self + """ + text= self.object.GetText() + if text == None : text="" + return text + + #def getval(self): + # return self.object.getval() + + def set_valeur_co(self,nom_co): + """ + Affecte au MCS pointé par self l'objet de type CO et de nom nom_co + """ + ret = self.object.set_valeur_co(nom_co) + #print "set_valeur_co",ret + return ret + + def get_sd_avant_du_bon_type(self): + """ + Retourne la liste des noms des SD présentes avant l'étape qui contient + le MCS pointé par self et du type requis par ce MCS + """ + a=self.object.etape.parent.get_sd_avant_du_bon_type(self.object.etape,self.object.definition.type) + return a + + def get_sd_avant_du_bon_type_pour_type_de_base(self): + a=self.object.jdc.get_sd_avant_du_bon_type_pour_type_de_base(self.object.etape,"LASSD") + return a + + + + #def verif(self): + # pass + + def delete_valeur_co(self,valeur=None): + """ + Supprime la valeur du mot cle (de type CO) + il faut propager la destruction aux autres etapes + """ + if not valeur : valeur=self.object.valeur + # XXX faut il vraiment appeler del_sdprod ??? + #self.object.etape.parent.del_sdprod(valeur) + self.object.etape.parent.delete_concept(valeur) + + #----------------------------------------------- + # + # Methodes liees au type de l objet attendu + # + #----------------------------------------------- + # wait_co + # wait_geom + # wait_complex + # wait_reel + # wait_shell + # wait_assd + # GetType + + def wait_co(self): + """ + Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un objet de type ASSD qui n'existe pas encore (type CO()), + 0 sinon + """ + return self.object.wait_co() + + def wait_geom(self): + """ + Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un objet GEOM, 0 sinon + """ + return self.object.wait_geom() + + def wait_complex(self): + """ Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un complexe, 0 sinon """ + if 'C' in self.object.definition.type: + return 1 + else: + return 0 + + def wait_reel(self): + """ Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un réel, 0 sinon """ + if 'R' in self.object.definition.type: + return 1 + else: + return 0 + + def wait_shell(self): + """ Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un shell, 0 sinon """ + if 'shell' in self.object.definition.type: + return 1 + else: + return 0 + + def wait_assd(self): + """Méthode booléenne qui retourne 1 si l'objet pointé par self + attend un objet de type ASSD ou dérivé, 0 sinon """ + return self.object.wait_assd() + + def wait_assd_or_type_base(self) : + boo=0 + if len(self.object.definition.type) > 1 : + if self.wait_reel() : + boo = 1 + if 'I' in self.object.definition.type : + boo = 1 + return boo + + + def GetType(self): + """ + Retourne le type de valeur attendu par l'objet représenté par l'item. + """ + return self.object.get_type() + + #----------------------------------------------------- + # + # Methodes liees a l evaluation de la valeur saisie + # + #----------------------------------------------------- + # eval_valeur + # eval_valeur_item + # is_CO + # traite_reel + + def eval_valeur(self,valeur): + """ Lance l'interprétation de 'valeur' (chaine de caractéres) comme valeur de self : + - retourne l'objet associé si on a pu interpréter (entier, réel, ASSD,...) + - retourne 'valeur' (chaine de caractéres) sinon + """ + newvaleur=self.eval_val(valeur) + return newvaleur,1 + + def eval_valeur_BAK(self,valeur): + """ Lance l'interprétation de 'valeur' (chaine de caractéres) comme valeur + de l'objet pointé par self : + - retourne l'objet associé si on a pu interpréter (entier, réel, ASSD,...) + - retourne 'valeur' (chaine de caractéres) sinon + - retourne None en cas d invalidite + - retourne invalide si 1 des objets du tuple l est + """ + validite=1 + if type(valeur) in (types.ListType,types.TupleType) : + valeurretour=[] + for item in valeur : + newvaleur,validiteitem=self.eval_valeur_item(item) + valeurretour.append(newvaleur) + if validiteitem == 0: + validite=0 + else : + valeurretour,validite= self.eval_valeur_item(valeur) + if validite == 0 : + valeurretour = None + return valeurretour,validite + + def eval_valeur_item(self,valeur): + """ Lance l'interprétation de 'valeur' qui doit ne pas etre un tuple + - va retourner la valeur de retour et la validite + selon le type de l objet attendu + - traite les reels et les parametres + """ + #print "eval_valeur_item",valeur + if valeur==None or valeur == "" : + return None,0 + validite=1 + if self.wait_reel(): + valeurinter = self.traite_reel(valeur) + if valeurinter != None : + valeurretour,validite= self.object.eval_valeur(valeurinter) + else: + valeurretour,validite= self.object.eval_valeur(valeur) + elif self.wait_geom(): + valeurretour,validite = valeur,1 + else : + valeurretour,validite= self.object.eval_valeur(valeur) + #print "eval_valeur_item",valeurretour,validite + + if validite == 0: + if type(valeur) == types.StringType and self.object.wait_TXM(): + essai_valeur="'" + valeur + "'" + valeurretour,validite= self.object.eval_valeur(essai_valeur) + + if hasattr(valeurretour,'__class__'): + #if valeurretour.__class__.__name__ in ('PARAMETRE','PARAMETRE_EVAL'): + if valeurretour.__class__.__name__ in ('PARAMETRE',): + validite=1 + + #if self.wait_co(): + # CCAR : il ne faut pas essayer de creer un concept + # il faut simplement en chercher un existant ce qui a du etre fait par self.object.eval_valeur(valeur) + #try: + #valeurretour=Accas.CO(valeur) + #except: + #valeurretour=None + #validite=0 + # on est dans le cas ou on a évalué et ou on n'aurait pas du + if self.object.wait_TXM() : + if type(valeurretour) != types.StringType: + valeurretour=str(valeur) + validite=1 + return valeurretour,validite + + def is_CO(self,valeur=None): + """ + Indique si valeur est un concept produit de la macro + Cette méthode n'a de sens que pour un MCSIMP d'une MACRO + Si valeur vaut None on teste la valeur du mot cle + """ + # Pour savoir si un concept est un nouveau concept de macro + # on regarde s'il est présent dans l'attribut sdprods de l'étape + # ou si son nom de classe est CO. + # Il faut faire les 2 tests car une macro non valide peut etre + # dans un etat pas tres catholique avec des CO pas encore types + # et donc pas dans sdprods (resultat d'une exception dans type_sdprod) + if not valeur:valeur=self.object.valeur + if valeur in self.object.etape.sdprods:return 1 + if type(valeur) is not types.InstanceType:return 0 + if valeur.__class__.__name__ == 'CO':return 1 + return 0 + + def is_param(self,valeur) : + for param in self.jdc.params: + if (repr(param) == valeur): + return 1 + return 0 + + def traite_reel(self,valeur): + """ + Cette fonction a pour but de rajouter le '.' en fin de chaine pour un réel + ou de détecter si on fait référence a un concept produit par DEFI_VALEUR + ou un EVAL ... + """ + valeur = string.strip(valeur) + liste_reels = self.get_sd_avant_du_bon_type() + if valeur in liste_reels: + return valeur + if len(valeur) >= 3 : + if valeur[0:4] == 'EVAL' : + # on a trouvé un EVAL --> on retourne directement la valeur + return valeur + if string.find(valeur,'.') == -1 : + # aucun '.' n'a été trouvé dans valeur --> on en rajoute un a la fin + if (self.is_param(valeur)): + return valeur + else: + if string.find(valeur,'e') != -1: + # Notation scientifique ? + try : + r=eval(valeur) + return valeur + except : + return None + else : + return valeur+'.' + else: + return valeur + + +import Accas +treeitem = SIMPTreeItem +objet = Accas.MCSIMP + diff --git a/InterfaceQT/editor.py b/InterfaceQT/editor.py new file mode 100644 index 00000000..5321d7fc --- /dev/null +++ b/InterfaceQT/editor.py @@ -0,0 +1,649 @@ +# -*- coding: iso-8859-1 -*- + +# Modules Python +import types,sys,os +import traceback +from qt import * + +# Modules Eficas + +import convert,generator +from Editeur import session +from Editeur import comploader +from Editeur import Objecttreeitem +from Aster import prefs +from InterfaceQT import panelsQT +from InterfaceQT import browser +from InterfaceQT import readercata + +import qtCommun + +VERSION_EFICAS = "EFICAS v1.12" + + +# -------------------------- # +# # +class JDCEditor(QSplitter): +# # +# -------------------------- # + """ + Editeur de jdc + """ + + def __init__(self,fn = None, jdc = None ,parent=None, editor = None): + #-------------------------------------------------------------------# + + QSplitter.__init__(self, parent,'') + + VERSION_CODE = session.d_env.cata + self.top = None + self.code = prefs.code + self.version_code = VERSION_CODE + self.titre=VERSION_EFICAS + ' pour '+ self.code + self.dict_reels={} + self.liste_simp_reel=[] + self.format_fichier='python' #CS_pbruno gestion python uniquement + self.ihm="QT" + + from Editeur import configuration + self.CONFIGURATION = configuration.make_config(self,prefs.REPINI) + self.CONFIGStyle = configuration.make_config_style(self,prefs.REPINI) + self.test=0 + self.sb = None + if hasattr(qApp.mainWidget(),"statusBar"): + self.sb = qApp.mainWidget().statusBar() + + self.parent = parent + self.vm = parent #viewManager + self.fileName = fn + self.fileInfo = None + self.lastModified = 0 + self.jdc = jdc + + self.fichier=None + self.panel_courant=None + self.node_selected = None + self.modified = False + self.isReadOnly = False + + if not hasattr( readercata, 'reader' ): + readercata.reader = readercata.READERCATA( self, self ) + self.readercata = readercata.reader + + + #------- construction du jdc -------------- + + jdc_item = None + + if self.fileName is not None: # fichier jdc fourni + self.fileInfo = QFileInfo(self.fileName) + self.fileInfo.setCaching(0) + if editor is None: + self.jdc = self.readFile(self.fileName) + else: + self.top = editor.top + self.code = editor.code + self.version_code = editor.version_code + self.titre = editor.titre + self.dict_reels = editor.dict_reels + self.liste_simp_reel= editor.liste_simp_reel + self.format_fichier = editor.format_fichier + self.CONFIGURATION = editor.CONFIGURATION + self.CONFIGStyle = editor.CONFIGStyle + self.jdc = editor.jdc + + self.lastModified = self.fileInfo.lastModified() + elif editor is not None: + self.jdc = editor.jdc + else: + if not self.jdc: # nouveau jdc + self.jdc = self._newJDC() + + if self.jdc: + self.jdc.appli = self + txt_exception = None + if not jdc: + self.jdc.analyse() + txt_exception = self.jdc.cr.get_mess_exception() + if txt_exception: + self.jdc = None + qApp.restoreOverrideCursor() + self.affiche_infos("Erreur fatale au chargement de %s" %fn) + QMessageBox.critical( self, "Erreur fatale au chargement d'un fichier", txt_exception) + else: + comploader.charger_composants("QT") + jdc_item=Objecttreeitem.make_objecttreeitem( self, "nom", self.jdc ) + + if not self.jdc.isvalid(): + self.viewJdcRapport() + + #------- config widget -------------- + + if jdc_item: + self.tree = browser.JDCTree( jdc_item, self ) + self.connect(self.tree,SIGNAL('selectionChanged(QListViewItem *)'),self.updatePanel) + + sh = self.sizeHint() + if sh.height() < 300: + sh.setHeight(300) + self.resize(sh) + + # Make sure tabbing through a QWorkspace works. + self.setFocusPolicy(QWidget.StrongFocus) + self._updateReadOnly(1) + + # Set the editors size if it is too big for the parent. + if parent is not None: + req = self.size() + bnd = req.boundedTo(parent.size()) + + if bnd.width() < req.width() or bnd.height() < req.height(): + self.resize(bnd) + + self.panel = QWidget(self) + #self.connect(self, SIGNAL('modificationChanged(bool)'), self.handleModificationChanged) + + + #-------------------------------------------------------------------# + def _updateReadOnly(self, bForce=1): + #-------------------------------------------------------------------# + """ + Private method to update the readOnly information for this editor. + + If bForce is True, then updates everything regardless if + the attributes have actually changed, such as during + initialization time. A signal is emitted after the + caption change. + + @param bForce 1 to force change, 0 to only update and emit + signal if there was an attribute change. + """ + + if self.fileName is None: + return + readOnly = not QFileInfo(self.fileName).isWritable() and 1 or 0 + if not bForce and (readOnly == self.isReadOnly): + return + cap = self.fileName + if readOnly: + cap = "%s (ro)" % unicode(cap) + self.isReadOnly = readOnly + self.setCaption(cap) + self.emit(PYSIGNAL('captionChanged'), (cap, self)) + + #-------------------# + def _newJDC( self ): + #-------------------# + """ + Initialise un nouveau JDC vierge + """ + CONTEXT.unset_current_step() + jdc=self.readercata.cata[0].JdC( procedure="", + appli=self, + cata=self.readercata.cata, + cata_ord_dico=self.readercata.cata_ordonne_dico, + rep_mat=self.CONFIGURATION.rep_mat + ) + jdc.analyse() + return jdc + + + #-----------------------# + def get_source(self,file): + #-----------------------# + import convert + format=self.format_fichier + + # Il faut convertir le contenu du fichier en fonction du format + if convert.plugins.has_key(format): + # Le convertisseur existe on l'utilise + p=convert.plugins[format]() + p.readfile(file) + text=p.convert('execnoparseur') + if not p.cr.estvide(): + self.affiche_infos("Erreur a la conversion") + return text + else: + # Il n'existe pas c'est une erreur + self.affiche_infos("Type de fichier non reconnu") + QMessageBox.critical( self, "Type de fichier non reconnu","EFICAS ne sait pas ouvrir ce type de fichier") + return None + + #---------------------------------------------# + def get_file(self,unite=None,fic_origine = ''): + #---------------------------------------------# + ulfile = None + jdcText = "" + + titre = "" + + if unite : + titre = "Choix unite %d " %unite + texte = "Le fichier %s contient une commande INCLUDE \n" % fic_origine + texte = texte+'Donnez le nom du fichier correspondant\n à  l unité logique %d' % unite + labeltexte = 'Fichier pour unite %d :' % unite + else: + titre = "Choix d'un fichier de poursuite" + texte = "Le fichier %s contient une commande %s\n" %(fic_origine,'POURSUITE') + texte = texte+'Donnez le nom du fichier dont vous \n voulez faire une poursuite' + + QMessageBox.information( self, titre,texte) + fn = QFileDialog.getOpenFileName( None, "", self, None, titre ) + + if fn.isNull(): + return + + ulfile = os.path.abspath(unicode(fn)) + # On utilise le convertisseur défini par format_fichier + source=self.get_source(ulfile) + if source: + # On a réussi à convertir le fichier self.ulfile + jdcText = source + else: + # Une erreur a été rencontrée + jdcText = '' + return ulfile, jdcText + + + #-----------------------# + def readFile(self, fn): + #-----------------------# + """ + Public slot to read the text from a file. + + @param fn filename to read from (string or QString) + """ + fn = unicode(fn) + + qApp.setOverrideCursor(Qt.waitCursor) + + # ------------------------------------------------------------------------------------ + # charge le JDC + # ------------------------------------------------------------------------------------ + + jdcName=os.path.basename(fn) + # Il faut convertir le contenu du fichier en fonction du format + if convert.plugins.has_key( self.format_fichier ): + # Le convertisseur existe on l'utilise + appli = self # CS_pbruno compatiblity parseur_python: self.appli.liste_simp_reel, self.appli.dict_reels + p=convert.plugins[self.format_fichier]() + p.readfile(fn) + text=p.convert('exec',appli) + if not p.cr.estvide(): + self.affiche_infos("Erreur à la conversion") + + CONTEXT.unset_current_step() + ## os.chdir(self.initialdir) + jdc=self.readercata.cata[0].JdC(procedure=text, + appli=self, + cata=self.readercata.cata, + cata_ord_dico=self.readercata.cata_ordonne_dico, + nom=jdcName, + rep_mat=self.CONFIGURATION.rep_mat + ) + # ---------------------------------------------------- + # charge le JDC fin + # ---------------------------------------------------- + self.modified = False + + qApp.restoreOverrideCursor() + self.lastModified = self.fileInfo.lastModified() + return jdc + + #----------------------------------------------# + def _viewText(self, txt, caption = "FILE_VIEWER"): + #----------------------------------------------# + w = qtCommun.ViewText( self.parent ) + w.setCaption( caption ) + w.setText(txt) + w.show() + + #-----------------------# + def viewJdcSource(self): + #-----------------------# + format = self.format_fichier.get() + strSource = str( self.get_text_JDC(format) ) + self._viewText(strSource, "JDC_SOURCE") + + #-----------------------# + def viewJdcRapport(self): + #-----------------------# + strRapport = str( self.jdc.report() ) + self._viewText(strRapport, "JDC_RAPPORT") + + #-----------------------# + def handleRenamed(self, fn): + #-----------------------# + """ + Public slot to handle the editorRenamed signal. + + @param fn filename to be set for the editor (QString or string). + """ + self.fileName = unicode(fn) + self.setCaption(self.fileName) + + if self.fileInfo is None: + self.fileInfo = QFileInfo(self.fileName) + self.fileInfo.setCaching(0) + + self.lastModified = self.fileInfo.lastModified() + self.vm.setEditorName(self, self.fileName) + self._updateReadOnly(1) + + #-----------------------# + def handleNewView(self): + #-----------------------# + """ + Private slot to create a new view to an open document. + """ + self.vm.newEditorView(self.fileName, self)#, self.isPythonFile) + + #------------------------------------# + def handleModificationChanged(self, m): + #------------------------------------# + """ + Private slot to handle the modificationChanged signal. + + It emits the signal modificationStatusChanged with parameters + m and self. + + @param m modification status + """ + if not m and self.fileInfo is not None: + self.lastModified = self.fileInfo.lastModified() + self.emit(PYSIGNAL('modificationStatusChanged'), (m, self)) + + #------------------------# + def hasSyntaxErrors(self): + #------------------------# + return False #CS_pbruno todo + + #----------------# + def closeIt(self): + #----------------# + """ + Public method called by the viewmanager to finally get rid of us. + """ + + if self.jdc: + self.jdc.supprime() + self.close() + + + #------------------------------# + def affiche_infos(self,message): + #------------------------------# + if self.sb: + self.sb.message(message)#,2000) + + #------------------------------# + def updatePanel(self, jdcNode): + #------------------------------# + """ + Appele a chaque changement de noeud + """ + self.node_selected = jdcNode + if self.panel: + self.panel.close() + del self.panel + self.panel = None + + if jdcNode.item.isactif(): + self.panel = jdcNode.getPanel() + else: + self.panel = panelsQT.PanelInactif(self.node_selected,self) + + if not self.panel: + self.panel = panelsQT.NoPanel(self) + + self.panel.show() + + + + #-------------------# + def init_modif(self): + #-------------------# + """ + Met l'attribut modified a 'o' : utilise par Eficas pour savoir + si un JDC doit etre sauvegarde avant destruction ou non + """ + self.modified = True + self.emit(PYSIGNAL('modificationStatusChanged'), (True, self)) + + #-------------------# + def stop_modif(self): + #-------------------# + """ + Met l'attribut modified à 'n' : utilisé par Eficas pour savoir + si un JDC doit etre sauvegardé avant destruction ou non + """ + self.modified = False + self.emit(PYSIGNAL('modificationStatusChanged'), (False, self)) + + + #-------------------# + def cut(self): + #-------------------# + """ + Stocke dans Eficas.noeud_a_editer le noeud à  couper + """ + if not self.node_selected.item.iscopiable(): + QMessageBox.information( self, "Copie impossible", + "Cette version d'EFICAS ne permet que la copie d'objets de type 'Commande' ou mot-clé facteur") + return + self.parent.edit="couper" + self.parent.noeud_a_editer = self.node_selected + + #-------------------# + def copy(self): + #-------------------# + """ + Stocke dans Eficas.noeud_a_editer le noeud a copier + """ + if not self.node_selected.item.iscopiable(): + QMessageBox.information( self, "Copie impossible", + "La copie d'un tel objet n'est pas permise") + return + self.parent.edit="copier" + self.parent.noeud_a_editer = self.node_selected + + #-------------------# + def paste(self): + #-------------------# + """ + Lance la copie de l'objet place dans self.parent.noeud_a_editer + Ne permet que la copie d'objets de type Commande ou MCF + """ + try: + child=self.parent.noeud_a_editer.doPaste(self.node_selected) + except: + traceback.print_exc() + QMessageBox.information( self, "Copie impossible", + "L'action de coller apres un tel objet n'est pas permise") + return + + if child == 0: + if self.message != '': + QMessageBox.critical( self, "Copie refusee", self.message) + self.message = '' + self.affiche_infos("Copie refusée") + return + + # il faut declarer le JDCDisplay_courant modifie + self.init_modif() + # suppression eventuelle du noeud selectionne + # si possible on renomme l objet comme le noeud couper + + if self.parent.edit == "couper": + #nom = self.parent.noeud_a_editer.item.object.sd.nom + item=self.parent.noeud_a_editer.item + self.parent.noeud_a_editer.delete() + child.item.update(item) + #test,mess = child.item.nomme_sd(nom) + child.select() + + # on rend la copie a nouveau possible en liberant le flag edit + self.parent.edit="copier" + + #---------------------# + def getFileName(self): + #---------------------# + return self.fileName + + #---------------------# + def writeFile(self, fn): + #---------------------# + """ + Public slot to write the text to a file. + + @param fn filename to write to (string or QString) + @return flag indicating success + """ + fn = unicode(fn) + txt = self.get_text_JDC('python') + + eol = '\n' + if len(txt) >= len(eol): + if txt[-len(eol):] != eol: + txt += eol + else: + txt += eol + try: + f = open(fn, 'wb') + f.write(txt) + f.close() + return 1 + except IOError, why: + QMessageBox.critical(self, self.trUtf8('Save File'), + self.trUtf8('The file %1 could not be saved.
Reason: %2') + .arg(unicode(fn)).arg(str(why))) + return 0 + + #-----------------------------# + def get_text_JDC(self,format): + #-----------------------------# + if generator.plugins.has_key(format): + # Le generateur existe on l'utilise + g=generator.plugins[format]() + jdc_formate=g.gener(self.jdc,format='beautifie') + if not g.cr.estvide(): + self.affiche_infos("Erreur à la generation") + QMessageBox.critical( self, "Erreur a la generation","EFICAS ne sait pas convertir ce JDC") + return + else: + return jdc_formate + else: + # Il n'existe pas c'est une erreur + self.affiche_infos("Format %s non reconnu" % format) + QMessageBox.critical( self, "Format %s non reconnu" % format,"EFICAS ne sait pas convertir le JDC en format %s "% format) + return + + + #-------------------------------------------# + def saveFile(self, saveas = 0, path = None): + #-------------------------------------------# + """ + Public slot to save the text to a file. + + @param saveas flag indicating a 'save as' action + @param path directory to save the file in (string or QString) + @return tuple of two values (boolean, string) giving a success indicator and + the name of the saved file + """ + self.modified = True #CS_pbruno test + + if not saveas and not self.modified:#self.isModified(): + return (0, None) # do nothing if text wasn't changed + + newName = None + if saveas or self.fileName is None: + if path is None and self.fileName is not None: + path = os.path.dirname(unicode(self.fileName)) + selectedFilter = QString('') + fn = QFileDialog.getSaveFileName(path, + self.trUtf8("JDC (*.comm);;" + "All Files (*)"), self, None, + self.trUtf8("Save File"), selectedFilter, 0) + + if not fn.isNull(): + ext = QFileInfo(fn).extension() + if ext.isEmpty(): + ex = selectedFilter.section('(*',1,1).section(')',0,0) + if not ex.isEmpty(): + fn.append(ex) + if QFileInfo(fn).exists(): + abort = QMessageBox.warning(self, + self.trUtf8("Save File"), + self.trUtf8("The file %1 already exists.") + .arg(fn), + self.trUtf8("&Overwrite"), + self.trUtf8("&Abort"), None, 1) + if abort: + return (0, None) + fn = unicode(QDir.convertSeparators(fn)) + newName = fn + else: + return (0, None) + else: + fn = self.fileName + + if self.writeFile(fn): + self.fileName = fn + self.modified = False + self.setCaption(self.fileName) + if self.fileInfo is None or saveas: + self.fileInfo = QFileInfo(self.fileName) + self.fileInfo.setCaching(0) + self.emit(PYSIGNAL('editorRenamed'), (self.fileName,)) + self.lastModified = self.fileInfo.lastModified() + if newName is not None: + self.vm.addToRecentList(newName) + self.emit(PYSIGNAL('editorSaved'), (self.fileName,)) + self.stop_modif() + return (1, self.fileName) + else: + return (0, None) + + #---------------------------------# + def saveFileAs(self, path = None): + #---------------------------------# + """ + Public slot to save a file with a new name. + + @param path directory to save the file in (string or QString) + @return tuple of two values (boolean, string) giving a success indicator and + the name of the saved file + """ + return self.saveFile(1, path) + + + + + +if __name__=='__main__': + if hasattr(prefs,'encoding'): + # Hack pour changer le codage par defaut des strings + import sys + reload(sys) + sys.setdefaultencoding(prefs.encoding) + del sys.setdefaultencoding + # Fin hack + + #CS_pbruno note: fait implicitement des trucs ces imports (grr) + import styles + import import_code + import session + + # Analyse des arguments de la ligne de commande + options=session.parse(sys.argv) + code=options.code + + app = QApplication(sys.argv) + mw = JDCEditor('azAster.comm') + app.setMainWidget(mw) + app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + mw.show() + + res = app.exec_loop() + sys.exit(res) + diff --git a/InterfaceQT/eficas.py b/InterfaceQT/eficas.py new file mode 100644 index 00000000..731589d0 --- /dev/null +++ b/InterfaceQT/eficas.py @@ -0,0 +1,65 @@ +class UserInterface(Eficas): + """ + Class implementing the main user interface. + + @signal appendStderr(string) emitted to write data to stderr logger + @signal appendStdout(string) emitted to write data to stdout logger + @signal preferencesChanged() emitted after the preferences were changed + """ + def __init__(self): + """ + Constructor + + @param loc locale to be used by the UI (string) + @param splash reference to the splashscreen (UI.SplashScreen.SplashScreen) + """ + Eficas.__init__(self) + + # Generate the debug server object + dbs = DebugServer() + + # Create main layout type 4 (floating windows) + + # Create the view manager depending on the configuration setting + self.viewmanager = MyTabview(self, self, dbs) #MyTabview, MyWorkspace, Listspace + self.setCentralWidget(self.viewmanager) + + + self.connect(self,PYSIGNAL('preferencesChanged'), + self.viewmanager.handlePreferencesChanged) + + + self.connect(self.viewmanager,PYSIGNAL('lastEditorClosed'), + self.handleLastEditorClosed) + self.connect(self.viewmanager,PYSIGNAL('editorOpened'), + self.handleEditorOpened) + + + + # Initialise the instance variables. + self.currentProg = None + self.isProg = 0 + self.utEditorOpen = 0 + self.utProjectOpen = 0 + + self.inDragDrop = 0 + self.setAcceptDrops(1) + + + + def handleLastEditorClosed(self): + """ + Public slot to handle the lastEditorClosed signal. + """ + pass + + def handleEditorOpened(self, fn): + """ + Public slot to handle the editorOpened signal. + + @param fn filename of the opened editor (string) + """ + pass + + def fileOpen(self, prog=None): + self.viewmanager.handleOpen(prog) diff --git a/InterfaceQT/monChoixCata.py b/InterfaceQT/monChoixCata.py new file mode 100644 index 00000000..f21aaa14 --- /dev/null +++ b/InterfaceQT/monChoixCata.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desChoixCata import DChoixCata +from qt import * + + +# Import des panels + +class MonChoixCata(DChoixCata): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,listeCata,readercata, parent = None,name = None,fl = 0): + DChoixCata.__init__(self,parent,name,fl) + self.listeCata=listeCata + self.readercata=readercata + for cata in self.listeCata : + self.CBChoixCata.insertItem(cata,0) + lab = QString(repr(len(listeCata))) + lab += QString(" versions du catalogue sont disponibles") + self.TLNb.setText(lab) + self.readercata.version_cata=self.CBChoixCata.currentText() + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def CataChoisi(self): + self.readercata.version_cata=self.CBChoixCata.currentText() + + def BOkPressed(self): + QDialog.accept(self) + + def BCancelPressed(self): + QDialog.reject(self) diff --git a/InterfaceQT/monCommandePanel.py b/InterfaceQT/monCommandePanel.py new file mode 100644 index 00000000..a15cc8a1 --- /dev/null +++ b/InterfaceQT/monCommandePanel.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desCommande import DComm +from qtCommun import QTPanel +from qtCommun import QTPanelTBW1 +from qtCommun import QTPanelTBW2 +from qtCommun import QTPanelTBW3 +from qt import * + + +# Import des panels + +class MonCommandePanel(DComm,QTPanelTBW1,QTPanelTBW2,QTPanelTBW3): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DComm.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW1.__init__(self,node,parent) + QTPanelTBW2.__init__(self,node,parent) + QTPanelTBW3.__init__(self,node,parent) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + + def BNextPressed(self): + QTPanelTBW2.BNextPressed(self) + + def BuildTabCommand(self): + QTPanelTBW2.BuildLBNouvCommande(self) + + def LEFiltreTextChanged(self): + QTPanelTBW2.LEFiltreTextChanged(self) + + def LEfiltreReturnPressed(self): + QTPanelTBW2.LEfiltreReturnPressed(self) + + def LBNouvCommandeClicked(self): + QTPanelTBW2.LBNouvCommandeClicked(self) + + def LENomConceptReturnPressed(self): + QTPanelTBW3.LENomConceptReturnPressed(self) diff --git a/InterfaceQT/monCommentairePanel.py b/InterfaceQT/monCommentairePanel.py new file mode 100644 index 00000000..ae6ce6e3 --- /dev/null +++ b/InterfaceQT/monCommentairePanel.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas + +from qt import * + +from desCommentaire import DComment +from qtCommun import QTPanel +from Aster import prefs + +# Import des panels + +class MonCommentairePanel(DComment,QTPanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DComment.__init__(self,parent,name,fl) + self.RemplitPanel() + + def RemplitPanel(self): + texte=self.node.item.get_valeur() + self.textCommentaire.setText(texte) + + def TexteCommentaireEntre(self): + texte=self.textCommentaire.text().latin1() + self.editor.init_modif() + self.node.item.set_valeur(texte) + self.node.onValid() + diff --git a/InterfaceQT/monFonctionPanel.py b/InterfaceQT/monFonctionPanel.py new file mode 100644 index 00000000..9bde8dc0 --- /dev/null +++ b/InterfaceQT/monFonctionPanel.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os +from qt import * + +# Modules Eficas + +from monPlusieursBasePanel import MonPlusieursBasePanel + +# Import des panels + +class MonFonctionPanel(MonPlusieursBasePanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + self.node=node + self.SetNbValeurs() + MonPlusieursBasePanel.__init__(self,node,parent,name,fl) + + def SetNbValeurs(self): + genea=self.node.item.get_genealogie() + if "VALE" in genea: + self.nbValeurs=2 + if "VALE_C" in genea: + self.nbValeurs=3 + + + def DecoupeListeValeurs(self,liste): + #decoupe la liste des valeurs en n ( les x puis les y) + l_valeurs=[] + if (len(liste)% self.nbValeurs != 0): + message="La cardinalité n'est pas correcte, la dernière valeur est ignorée" + self.Commentaire.setText(QString(commentaire)) + for i in range(len(liste)/ self.nbValeurs) : + if (self.nbValeurs==2): + t=(liste[i*self.nbValeurs], liste[i*self.nbValeurs+1]) + else: + t=(liste[i*self.nbValeurs], liste[i*self.nbValeurs+1], liste[i*self.nbValeurs+2]) + l_valeurs.append(t) + return l_valeurs + + def BuildLBValeurs(self): + self.LBValeurs.clear() + listeValeurs=self.node.item.GetListeValeurs() + for valeur in self.DecoupeListeValeurs(listeValeurs): + self.LBValeurs.insertItem(str(valeur)) + + def Ajout1Valeur(self,liste=[]): + # Pour être appele a partir du Panel Importer (donc plusieurs fois par AjouterNValeur) + if liste == [] : + liste,validite=SaisieValeur.TraiteLEValeur(self) + else : + validite=1 + if validite == 0 : return + if liste ==[] : return + + if len(liste) != self.nbValeurs : + commentaire = QString(str(liste)) + commentaire += QString(" n est pas un tuple de ") + commentaire += QString(str(self.nbValeurs)) + commentaire += QString(" valeurs") + self.Commentaire.setText(commentaire) + return + + index=self.LBValeurs.currentItem() +1 + indexListe=index*self.nbValeurs + if index == 0 : + index = -1 + indexListe=len(self.listeValeursCourantes) + listeVal=[] + for valeur in self.listeValeursCourantes : + listeVal.append(valeur) + validite,comm,comm2,listeRetour=self.politique.AjoutValeurs(liste,index,listeVal) + self.Commentaire.setText(comm2) + if not validite : + self.editor.affiche_infos(comm) + else: + self.LEValeur.setText(QString("")) + l1=self.listeValeursCourantes[:indexListe] + l3=self.listeValeursCourantes[indexListe:] + for valeur in self.DecoupeListeValeurs(listeRetour): + self.LBValeurs.insertItem(QString(str(valeur)),index) + index=index+1 + self.listeValeursCourantes=l1+listeRetour+l3 + + + def AjoutNValeur(self,liste) : + if len(liste)%self.nbValeurs != 0 : + texte="Nombre de valeur incorrecte" + self.Commentaire.setText(texte) + return + listeDecoupee=self.DecoupeListeValeurs(liste) + for vals in listeDecoupee : + self.Ajout1Valeur(vals) + + + def Sup1Valeur(self): + index=self.LBValeurs.currentItem() + self.LBValeurs.removeItem(self.LBValeurs.currentItem()) + listeVal=[] + i=0 + for valeur in self.listeValeursCourantes : + if self.nbValeurs == 2 : + if (i != index*2 and i != index*2+1 ) : listeVal.append(valeur) + elif self.nbValeurs == 3 : + if (i != index*3 and i != index*3+1 and i != index*3 +2) : listeVal.append(valeur) + else : + print "aiiiiiiiiiiiiiiiiiieeee" + i = i+1 + self.listeValeursCourantes=listeVal + listeValeurs=self.listeValeursCourantes + self.LBValeurs.clear() + for valeur in self.DecoupeListeValeurs(listeValeurs): + self.LBValeurs.insertItem(str(valeur)) + diff --git a/InterfaceQT/monFormulePanel.py b/InterfaceQT/monFormulePanel.py new file mode 100644 index 00000000..6fa2e588 --- /dev/null +++ b/InterfaceQT/monFormulePanel.py @@ -0,0 +1,140 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desFormule import DFormule +from qtCommun import QTPanel +from qtCommun import QTPanelTBW2 +from qt import * + + +# Import des panels + +class MonFormulePanel(DFormule,QTPanelTBW2): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DFormule.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW2.__init__(self,node,parent) + self.LENomFormule.setText(node.item.get_nom()) + self.LECorpsFormule.setText(node.item.get_corps()) + texte_args="" + for i in node.item.get_args() : + if texte_args != "" : + texte_args = texte_args +"," + texte_args=texte_args + i + self.LENomsArgs.setText(texte_args) + + + self.parent=parent + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + + def BNextPressed(self): + QTPanelTBW2.BNextPressed(self) + + def BuildTabCommand(self): + QTPanelTBW2.BuildLBNouvCommande(self) + + def LEFiltreTextChanged(self): + QTPanelTBW2.LEFiltreTextChanged(self) + + def LEfiltreReturnPressed(self): + QTPanelTBW2.LEfiltreReturnPressed(self) + + def LBNouvCommandeClicked(self): + QTPanelTBW2.LBNouvCommandeClicked(self) + + def NomFormuleSaisi(self): + nomFormule = self.LENomFormule.text().latin1() + if nomFormule == '' : return + test,erreur = self.node.item.verif_nom(nomFormule) + if test : + commentaire=nomFormule+" est un nom valide pour une FORMULE" + else : + commentaire=nomFormule+" n'est pas un nom valide pour une FORMULE" + self.editor.affiche_infos(commentaire) + + def argsSaisis(self): + arguments = self.LENomsArgs.text().latin1() + if arguments == '' : return + + test,erreur = self.node.item.verif_arguments(arguments) + if test: + commentaire="Argument(s) valide(s) pour une FORMULE" + else: + commentaire="Argument(s) invalide(s) pour une FORMULE" + self.editor.affiche_infos(commentaire) + + def FormuleSaisie(self): + nomFormule = self.LENomFormule.text().latin1() + arguments = self.LENomsArgs.text().latin1() + expression = self.LECorpsFormule.text().latin1() + if expression == '' : return + test,erreur = self.node.item.verif_formule_python((nomFormule,"REEL",arguments,expression)) + + if test: + commentaire="Corps de FORMULE valide" + else: + commentaire="Corps de FORMULE invalide" + self.editor.affiche_infos(commentaire) + + + def BOkPressedFormule(self): + if self.parent.modified == 'n' : self.parent.init_modif() + + nomFormule = self.LENomFormule.text().latin1() + test,erreur = self.node.item.verif_nom(nomFormule) + if not test : + self.editor.affiche_infos(erreur) + return + + arguments = self.LENomsArgs.text().latin1() + test,erreur = self.node.item.verif_arguments(arguments) + if not test : + self.editor.affiche_infos(erreur) + return + + expression = self.LECorpsFormule.text().latin1() + test,erreur = self.node.item.verif_formule_python((nomFormule,"REEL",arguments,expression)) + if not test : + self.editor.affiche_infos(erreur) + return + + test=self.node.item.object.update_formule_python(formule=(nomFormule,"REEL",arguments,expression)) + test,erreur = self.node.item.save_formule(nomFormule,"REEL",arguments,expression) + if test : + self.node.update_valid() + self.node.update_node_texte() + commentaire = "Formule modifiée" + else: + commentaire ="Formule incorrecte : " + erreur + self.editor.init_modif() + self.editor.affiche_infos(commentaire) diff --git a/InterfaceQT/monIncludePanel.py b/InterfaceQT/monIncludePanel.py new file mode 100644 index 00000000..6da7fa71 --- /dev/null +++ b/InterfaceQT/monIncludePanel.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +import os,traceback,sys +from qt import * +from desMacro import DMacro + +from monMacroPanel import MonMacroPanel +import convert + + +# Import des panels + +class MonIncludePanel(MonMacroPanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + MonMacroPanel.__init__(self,node,parent,name,fl) + #Version TK ?? + #if not hasattr(self.node.item.object,'fichier_ini'): + if not hasattr(self.node.item.object,'fichier_unite'): + self.ajoutPageBad() + else: + self.ajoutPageOk() + + def ajoutPageOk(self): + self.TabPage = QWidget(self.TWChoix,"TabPage") + self.LENomFichier = QLineEdit(self.TabPage,"LENomFichier") + self.LENomFichier.setGeometry(QRect(18,127,450,30)) + self.textLabel1_3 = QLabel(self.TabPage,"textLabel1_3") + self.textLabel1_3.setGeometry(QRect(70,50,350,41)) + self.BBrowse = QPushButton(self.TabPage,"BBrowse") + self.BBrowse.setGeometry(QRect(288,306,161,41)) + self.TWChoix.insertTab(self.TabPage,QString("")) + self.textLabel1_3.setText(self._DMacro__tr("La commande INCLUDE requiert un nom de Fichier :")) + self.BBrowse.setText(self._DMacro__tr("Edit")) + self.TWChoix.changeTab(self.TabPage,self._DMacro__tr("Fichier Include")) + self.TWChoix.setCurrentPage(2) + + self.LENomFichier.setText(self.node.item.object.fichier_ini) + + self.connect(self.BBrowse,SIGNAL("clicked()"),self.BBrowsePressed) + self.connect(self.LENomFichier,SIGNAL("returnPressed()"),self.LENomFichReturnPressed) + + + def ajoutPageBad(self) : + self.TabPage = QWidget(self.TWChoix,"TabPage") + self.textLabel1_5 = QLabel(self.TabPage,"textLabel1_5") + self.textLabel1_5.setGeometry(QRect(88,96,290,131)) + self.TWChoix.insertTab(self.TabPage,QString("")) + self.textLabel1_5.setText(self._DMacro__trUtf8("\x3c\x66\x6f\x6e\x74\x20\x73\x69\x7a\x65\x3d\x22\x2b\x31\x22\x3e\x3c\x70\x20\x61\x6c\x69\x67\x6e\x3d\x22\x63\x65\x6e\x74\x65\x72\x22\x3e\x4c\x61\x20\x63\x6f\x6d\x6d\x61\x6e\x64\x65\x20\x49\x4e\x43\x4c\x55\x44\x45\x20\x6e\x27\x61\x20\x70\x61\x73\x20\x64\x65\x20\x66\x69\x63\x68\x69\x65\x72\x20\x61\x73\x73\x6f\x63\x69\xc3\xa9\x2e\x0a\x49\x6c\x20\x66\x61\x75\x74\x20\x64\x27\x61\x62\x6f\x72\x64\x20\x63\x68\x6f\x69\x73\x69\x72\x20\x75\x6e\x20\x6e\x75\x6d\xc3\xa9\x72\x6f\x20\x64\x27\x75\x6e\x69\x74\xc3\xa9\x3c\x2f\x70\x3e\x3c\x2f\x66\x6f\x6e\x74\x3e")) + self.TWChoix.changeTab(self.TabPage,self._DMacro__tr("Fichier Include")) + self.TWChoix.setCurrentPage(2) + + + def BBrowsePressed(self): + pass + + def BOkIncPressed (self): + self.LENomFichReturnPressed() + + def LENomFichReturnPressed(self): + nomFichier=str(self.LENomFichier.text()) + if not os.path.isfile(nomFichier) : + commentaire = "Fichier introuvable" + self.Commentaire.setText(QString(commentaire)) + return + + text=self.convert_file(nomFichier) + + # Si probleme a la lecture-conversion on arrete le traitement + if not text: + return + + try : + self.node.item.object.change_fichier_init(nomFichier,text) + commentaire = "Fichier modifie : " + self.node.item.get_nom() + self.Commentaire.setText(QString(commentaire)) + except: + l=traceback.format_exception_only("Fichier invalide",sys.exc_info()[1]) + QMessageBox.critical( self, "Erreur fatale au chargement du fichier Include", l[0]) + commentaire = "Fichier invalide" + self.Commentaire.setText(QString(commentaire)) + return + + + def convert_file(self,file): + """ + Methode pour convertir le fichier file dans le format courant + """ + format=self.editor.format_fichier + text=None + if convert.plugins.has_key(format): + # Le convertisseur existe on l'utilise + p=convert.plugins[format]() + p.readfile(file) + text=p.convert('execnoparseur') + else : + commentaire = "Impossible de lire le fichier : Format inconnu" + self.Commentaire.setText(QString(commentaire)) + return text + diff --git a/InterfaceQT/monListeParamPanel.py b/InterfaceQT/monListeParamPanel.py new file mode 100644 index 00000000..68c4bada --- /dev/null +++ b/InterfaceQT/monListeParamPanel.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desListeParam import DLisParam +from qt import * + +# Import des panels + +class MonListeParamPanel(DLisParam): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,liste,parent,name = None,fl = 0): + self.panel=parent + DLisParam.__init__(self,parent,name,Qt.WType_Dialog) + self.liste=liste + self.initVal() + + def initVal(self): + self.LBParam.clear() + for param in self.liste : + self.LBParam.insertItem(QString(repr(param))) + + def LBParamItemPressed(self): + i=self.LBParam.index(self.LBParam.selectedItem()) + self.panel.Ajout1Valeur(self.liste[i]) diff --git a/InterfaceQT/monMCFactPanel.py b/InterfaceQT/monMCFactPanel.py new file mode 100644 index 00000000..ccd3f6e3 --- /dev/null +++ b/InterfaceQT/monMCFactPanel.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desMCFact import DMCFact +from qtCommun import QTPanel +from qtCommun import QTPanelTBW1 +from qt import * + + +# Import des panels + +class MonMCFactPanel(DMCFact,QTPanelTBW1): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DMCFact.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW1.__init__(self,node,parent) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + diff --git a/InterfaceQT/monMCListAjoutPanel.py b/InterfaceQT/monMCListAjoutPanel.py new file mode 100644 index 00000000..622deab5 --- /dev/null +++ b/InterfaceQT/monMCListAjoutPanel.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desMCListAjout import DMCListAjout +from qtCommun import QTPanel +from qt import * + + +# Import des panels + +class MonMCListAjoutPanel(DMCListAjout,QTPanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node,parent = None,name = None,fl = 0): + DMCListAjout.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + monMCFact=self.node.item.get_nom() + self.MCFacteur.setText(QString(monMCFact)) + self.MCFacteur.setAlignment(Qt.AlignHCenter) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BAjoutClicked(self): + self.node.parent.append_child(self.node.item.get_nom()) + diff --git a/InterfaceQT/monMacroPanel.py b/InterfaceQT/monMacroPanel.py new file mode 100644 index 00000000..b7905c2c --- /dev/null +++ b/InterfaceQT/monMacroPanel.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desMacro import DMacro +from qtCommun import QTPanel +from qtCommun import QTPanelTBW1 +from qtCommun import QTPanelTBW2 +from qt import * + + +# Import des panels + +class MonMacroPanel(DMacro,QTPanelTBW1,QTPanelTBW2): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DMacro.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW2.__init__(self,node,parent) + QTPanelTBW1.__init__(self,node,parent) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + + def BNextPressed(self): + QTPanelTBW2.BNextPressed(self) + + def BuildTabCommand(self): + QTPanelTBW2.BuildLBNouvCommande(self) + + def LEFiltreTextChanged(self): + QTPanelTBW2.LEFiltreTextChanged(self) + + def LEfiltreReturnPressed(self): + QTPanelTBW2.LEfiltreReturnPressed(self) + + def LBNouvCommandeClicked(self): + QTPanelTBW2.LBNouvCommandeClicked(self) + diff --git a/InterfaceQT/monParamPanel.py b/InterfaceQT/monParamPanel.py new file mode 100644 index 00000000..33145e9e --- /dev/null +++ b/InterfaceQT/monParamPanel.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os,re + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desParam import DParam +from qtCommun import QTPanel +from qtCommun import QTPanelTBW2 + +# Import des panels + +class MonParamPanel(DParam,QTPanelTBW2,QTPanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DParam.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW2.__init__(self,node,parent) + self.InitLEs() + + def InitLEs(self): + nom=self.node.item.get_nom() + self.lineEditNom.setText(nom) + valeur=self.node.item.get_valeur() + if valeur != None: + try : + str=QString("").setNum(valeur) + except : + str=QString(valeur) + self.lineEditVal.setText(str) + else : + self.lineEditVal.clear() + + def BOkParamPressed(self): + val=self.LEValeurPressed() + nom=self.LENomPressed() + if not nom : + commentaire="Entrer un nom de parametre" + self.Commentaire.setText(QString(commentaire)) + return + self.node.item.set_nom(nom) + self.node.item.set_valeur(val) + self.node.update_texte() + self.node.update_valid() + self.editor.init_modif() + self.InitLEs() + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def LEValeurPressed(self): + self.Commentaire.setText(QString("")) + commentaire="Valeur incorrecte" + qtVal=self.lineEditVal.text() + boul=2 + try : + val,boul=QString.toInt(qtVal) + except : + pass + if boul == 0 : + try : + val,boul=QString.toFloat(qtVal) + except : + pass + if boul == 0 : + try : + val=str(qtVal) + boul=1 + except : + pass + if boul: commentaire="Valeur correcte" + self.Commentaire.setText(QString(commentaire)) + return val + + def LENomPressed(self): + self.Commentaire.setText(QString("")) + qtNom=self.lineEditNom.text() + nom=str(qtNom) + numDebutPattern=re.compile('[a-zA-Z]') + if numDebutPattern.match(nom) : + return nom + else : + commentaire="Les noms de parametre doivent commencer par une lettre" + self.Commentaire.setText(QString(commentaire)) + return None + + def BuildTabCommand(self): + QTPanelTBW2.BuildLBNouvCommande(self) + + def LEFiltreTextChanged(self): + QTPanelTBW2.LEFiltreTextChanged(self) + + def LEfiltreReturnPressed(self): + QTPanelTBW2.LEfiltreReturnPressed(self) + + def LBNouvCommandeClicked(self): + QTPanelTBW2.LBNouvCommandeClicked(self) + + def AppelleBuildLBRegles(self): + listeRegles=self.node.item.get_regles() + listeNomsEtapes = self.node.item.get_l_noms_etapes() + self.BuildLBRegles(listeRegles,listeNomsEtapes) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + + diff --git a/InterfaceQT/monPlusieursASSDPanel.py b/InterfaceQT/monPlusieursASSDPanel.py new file mode 100644 index 00000000..0b7a6412 --- /dev/null +++ b/InterfaceQT/monPlusieursASSDPanel.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * +from monPlusieursIntoPanel import MonPlusieursIntoPanel +from desPlusieursInto import DPlusInto +from qtCommun import QTPanel +from politiquesValidation import PolitiquePlusieurs +# Import des panels + +class MonPlusieursASSDPanel(MonPlusieursIntoPanel): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DPlusInto.__init__(self,parent,name,fl) + + self.listeValeursCourantes=self.node.item.GetListeValeurs() + self.InitValeursCourantes() + self.DisplayListBoxCourantes() + self.DisplayListBoxPossibles() + + self.politique=PolitiquePlusieurs(node,parent) + #QObject.connect(self.listBoxVal, SIGNAL("doubleClicked(QListBoxItem*)" ), self.Ajout1Valeur ) + # QObject.connect(self.listBoxVal, SIGNAL("doubleClicked(QListBoxItem*)" ), self.ClicASSD ) + + def DisplayListBoxPossibles(self): + listeNomsSD = self.node.item.get_sd_avant_du_bon_type() + self.listBoxVal.clear() + for aSD in listeNomsSD: + if aSD not in self.listNomsValeurs : + self.listBoxVal.insertItem( aSD) + + def DisplayListBoxCourantes(self): + self.LBValeurs.clear() + for aSD in self.listNomsValeurs : + self.LBValeurs.insertItem( aSD) + + def InitValeursCourantes(self): + self.listNomsValeurs=[] + for i in self.listeValeursCourantes : + self.listNomsValeurs.append(i.get_name()) + + def BOkPourListePressed(self): + self.node.item.set_valeur(self.listeValeursCourantes) + self.editor.affiche_infos("Valeur Acceptée") + pass + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def Sup1Valeur(self): + index=self.LBValeurs.currentItem() + self.LBValeurs.removeItem(self.LBValeurs.currentItem()) + listeVal=[] + i=0 + for valeur in self.listeValeursCourantes : + if i != index : listeVal.append(valeur) + i = i+1 + self.listeValeursCourantes=listeVal + self.InitValeursCourantes() + self.DisplayListBoxCourantes() + self.DisplayListBoxPossibles() + + def Ajout1Valeur(self): + liste=[] + liste.append(self.listBoxVal.currentText().latin1()) + index=self.LBValeurs.currentItem() + 1 + if index==0 : index = -1 + listeVal=[] + for valeur in self.listeValeursCourantes : + listeVal.append(valeur) + validite,comm,comm2,listeRetour=self.politique.AjoutValeurs(liste,index,listeVal) + self.Commentaire.setText(comm2) + if not validite : + self.editor.affiche_infos(comm) + else: + l1=self.listeValeursCourantes[:index] + l3=self.listeValeursCourantes[index:] + for valeur in listeRetour: + self.LBValeurs.insertItem(QString(str(valeur)),index) + index=index+1 + self.listeValeursCourantes=l1+listeRetour+l3 + self.InitValeursCourantes() + self.DisplayListBoxCourantes() + self.DisplayListBoxPossibles() diff --git a/InterfaceQT/monPlusieursBasePanel.py b/InterfaceQT/monPlusieursBasePanel.py new file mode 100644 index 00000000..c6e59a8d --- /dev/null +++ b/InterfaceQT/monPlusieursBasePanel.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desPlusieursBase import DPlusBase +from qtCommun import QTPanel +from qtSaisie import SaisieValeur +from politiquesValidation import PolitiquePlusieurs + +# Import des panels + +class MonPlusieursBasePanel(DPlusBase,QTPanel,SaisieValeur): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DPlusBase.__init__(self,parent,name,fl) + self.politique=PolitiquePlusieurs(node,parent) + self.BuildLBValeurs() + self.listeValeursCourantes=self.node.item.GetListeValeurs() + + def BuildLBValeurs(self): + # redefinit en raison de l heritage par monFonctionPanel + SaisieValeur.BuildLBValeurs(self) + + def BOkPourListePressed(self): + self.node.item.set_valeur(self.listeValeursCourantes) + self.editor.affiche_infos("Valeur Acceptée") + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BParametresPressed(self): + QTPanel.BParametresPressed(self) + + def LEValeurPressed(self): + self.Ajout1Valeur() + + def Sup1Valeur(self): + index=self.LBValeurs.currentItem() + self.LEValeur.setText(self.LBValeurs.currentText()) + self.LBValeurs.removeItem(self.LBValeurs.currentItem()) + listeVal=[] + i=0 + for valeur in self.listeValeursCourantes : + if i != index : listeVal.append(valeur) + i = i+1 + self.listeValeursCourantes=listeVal + + + def Ajout1Valeur(self,valeur=None): + liste,validite=SaisieValeur.TraiteLEValeur(self,valeur) + if validite == 0 : return + if liste ==[] : return + + index=self.LBValeurs.currentItem() + 1 + listeVal=[] + for valeur in self.listeValeursCourantes : + listeVal.append(valeur) + validite,comm,comm2,listeRetour=self.politique.AjoutValeurs(liste,index,listeVal) + self.Commentaire.setText(comm2) + if not validite : + self.editor.affiche_infos(comm) + else: + self.LEValeur.setText(QString("")) + l1=self.listeValeursCourantes[:index] + l3=self.listeValeursCourantes[index:] + for valeur in listeRetour: + self.LBValeurs.insertItem(QString(str(valeur)),index) + index=index+1 + self.listeValeursCourantes=l1+listeRetour+l3 + + def BImportPressed(self): + init=QString( self.editor.CONFIGURATION.rep_user) + fn = QFileDialog.getOpenFileName(init, self.trUtf8('All Files (*)',)) + if fn == None : return + if fn == "" : return + from monSelectVal import MonSelectVal + MonSelectVal(file=fn,parent=self).show() diff --git a/InterfaceQT/monPlusieursIntoPanel.py b/InterfaceQT/monPlusieursIntoPanel.py new file mode 100644 index 00000000..7aa23d7c --- /dev/null +++ b/InterfaceQT/monPlusieursIntoPanel.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desPlusieursInto import DPlusInto +from qtCommun import QTPanel +from qtSaisie import SaisieValeur +from politiquesValidation import PolitiquePlusieurs + +# Import des panels + +class MonPlusieursIntoPanel(DPlusInto,QTPanel,SaisieValeur): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DPlusInto.__init__(self,parent,name,fl) + self.politique=PolitiquePlusieurs(node,parent) + SaisieValeur.BuildLBValeurs(self) + self.listeValeursCourantes=self.node.item.GetListeValeurs() + SaisieValeur.RemplitPanel(self,self.listeValeursCourantes) + QObject.connect(self.listBoxVal, SIGNAL("doubleClicked(QListBoxItem*)" ), self.Ajout1Valeur ) + + def BOkPourListePressed(self): + self.node.item.set_valeur(self.listeValeursCourantes) + self.editor.affiche_infos("Valeur Acceptée") + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def Sup1Valeur(self): + index=self.LBValeurs.currentItem() + self.LBValeurs.removeItem(self.LBValeurs.currentItem()) + listeVal=[] + i=0 + for valeur in self.listeValeursCourantes : + if i != index : listeVal.append(valeur) + i = i+1 + self.listeValeursCourantes=listeVal + SaisieValeur.RemplitPanel(self,self.listeValeursCourantes) + + def Ajout1Valeur(self): + liste=[] + liste.append(self.listBoxVal.currentText().latin1()) + index=self.LBValeurs.currentItem() + 1 + if index==0 : index = -1 + listeVal=[] + for valeur in self.listeValeursCourantes : + listeVal.append(valeur) + validite,comm,comm2,listeRetour=self.politique.AjoutValeurs(liste,index,listeVal) + self.Commentaire.setText(comm2) + if not validite : + self.editor.affiche_infos(comm) + else: + l1=self.listeValeursCourantes[:index] + l3=self.listeValeursCourantes[index:] + for valeur in listeRetour: + self.LBValeurs.insertItem(QString(str(valeur)),index) + index=index+1 + self.listeValeursCourantes=l1+listeRetour+l3 + SaisieValeur.RemplitPanel(self,self.listeValeursCourantes) + diff --git a/InterfaceQT/monRacinePanel.py b/InterfaceQT/monRacinePanel.py new file mode 100644 index 00000000..e7b0aeb8 --- /dev/null +++ b/InterfaceQT/monRacinePanel.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desRacine import DRac +from qtCommun import QTPanel +from qtCommun import QTPanelTBW2 +from qtCommun import itemColore +from qt import * + + +# Import des panels + +class MonRacinePanel(DRac,QTPanelTBW2): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + DRac.__init__(self,parent,name,fl) + QTPanel.__init__(self,node,parent) + QTPanelTBW2.__init__(self,node,parent,racine=1) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOkPressed(self): + QTPanel.BOkPressed(self) + + def BNextPressed(self): + QTPanelTBW2.BNextPressed(self) + + def BuildTabCommand(self): + QTPanelTBW2.BuildLBNouvCommande(self) + + def LEFiltreTextChanged(self): + QTPanelTBW2.LEFiltreTextChanged(self) + + def LEfiltreReturnPressed(self): + QTPanelTBW2.LEfiltreReturnPressed(self) + + def LBNouvCommandeClicked(self): + QTPanelTBW2.LBNouvCommandeClicked(self) + + def AppelleBuildLBRegles(self): + listeRegles=self.node.item.get_regles() + listeNomsEtapes = self.node.item.get_l_noms_etapes() + self.BuildLBRegles(listeRegles,listeNomsEtapes) + + def DefCmd(self): + name=str(self.LBNouvCommande.selectedItem().text()) + if name==QString(" "): return + if name.find("GROUPE :")==0 : return + self.editor.init_modif() + new_node = self.node.append_child(name,'first') diff --git a/InterfaceQT/monSelectVal.py b/InterfaceQT/monSelectVal.py new file mode 100644 index 00000000..c3c64148 --- /dev/null +++ b/InterfaceQT/monSelectVal.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +# Modules Eficas + +from desSelectVal import DSelVal +from qt import * + +# Import des panels + +class MonSelectVal(DSelVal): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,file,parent,name = None,fl = 0): + self.FonctPanel=parent + DSelVal.__init__(self,parent,name,Qt.WType_Dialog) + self.dictSepar={} + self.separateur=" " + self.texte=" " + self.textTraite="" + self.file=str(file) + self.readVal() + self.initVal() + + def readVal(self): + f = open(self.file, "rb") + self.texte = f.read() + f.close() + + def initVal(self): + self.TBtext.clear() + self.TBtext.setText(self.texte) + self.dictSepar["virgule"]="," + self.dictSepar["point-virgule"]=";" + self.dictSepar["espace"]=" " + + def SeparateurSelect(self,numero): + monBouton=self.BGSeparateur.find(numero) + self.separateur=self.dictSepar[str(monBouton.text())] + + def BImportSelPressed(self): + text=str(self.TBtext.selectedText()) + self.textTraite=text + self.Traitement() + + def BImportToutPressed(self): + self.textTraite=self.texte + self.Traitement() + + def Traitement(self): + import string + if self.textTraite[-1]=="\n" : self.textTraite=self.textTraite[0:-1] + self.textTraite=string.replace(self.textTraite,"\n",self.separateur) + liste1=self.textTraite.split(self.separateur) + liste=[] + for val in liste1 : + val=str(val) + try : + val=eval(val,{}) + except : + pass + liste.append(val) + self.FonctPanel.AjoutNValeur(liste) diff --git a/InterfaceQT/monUniqueASSDPanel.py b/InterfaceQT/monUniqueASSDPanel.py new file mode 100644 index 00000000..d41c7082 --- /dev/null +++ b/InterfaceQT/monUniqueASSDPanel.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueASSD import DUnASSD +from qtCommun import QTPanel +from qtSaisie import SaisieValeur +from politiquesValidation import PolitiqueUnique + +# Import des panels + +class MonUniqueASSDPanel(DUnASSD,QTPanel,SaisieValeur): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnASSD.__init__(self,parent,name,fl) + self.politique=PolitiqueUnique(node,parent) + self.InitListBoxASSD() + + def BOkPressed(self): + self.ClicASSD() + + def BSupPressed(self): + QTPanel.BSupPressed(self) + diff --git a/InterfaceQT/monUniqueBasePanel.py b/InterfaceQT/monUniqueBasePanel.py new file mode 100644 index 00000000..bbac7773 --- /dev/null +++ b/InterfaceQT/monUniqueBasePanel.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueBase import DUnBase +from qtCommun import QTPanel +from qtSaisie import SaisieValeur +from politiquesValidation import PolitiqueUnique + +# Import des panels + +class MonUniqueBasePanel(DUnBase,QTPanel,SaisieValeur): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnBase.__init__(self,parent,name,fl) + self.politique=PolitiqueUnique(node,parent) + self.InitLineEditVal() + + def InitLineEditVal(self): + valeur=self.node.item.get_valeur() + valeurTexte=self.politique.GetValeurTexte(valeur) + if valeurTexte != None: + try : + str=QString("").setNum(valeurTexte) + except : + str=QString(valeurTexte) + self.lineEditVal.setText(str) + + def BOk2Pressed(self): + SaisieValeur.BOk2Pressed(self) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def LEValeurPressed(self): + SaisieValeur.LEValeurPressed(self) + + def BParametresPressed(self): + QTPanel.BParametresPressed(self) + + def Ajout1Valeur(self,valeur): + SaisieValeur.LEValeurPressed(self,valeur) diff --git a/InterfaceQT/monUniqueCompPanel.py b/InterfaceQT/monUniqueCompPanel.py new file mode 100644 index 00000000..e47f2940 --- /dev/null +++ b/InterfaceQT/monUniqueCompPanel.py @@ -0,0 +1,152 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os,re + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueComp import DUnComp +from qtCommun import QTPanel +from politiquesValidation import PolitiqueUnique + +# Import des panels + +#class MonUniqueCompPanel(DUnComp,QTPanel,SaisieValeur): +class MonUniqueCompPanel(DUnComp,QTPanel,PolitiqueUnique): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnComp.__init__(self,parent,name,fl) + self.politique=PolitiqueUnique(node,parent) + self.InitLinesVal() + + def InitLinesVal(self): + valeur=self.node.item.get_valeur() + if valeur == None or valeur == '' : return + if type(valeur) not in (types.ListType,types.TupleType) : + self.LEcomp.setText(str(valeur)) + else : + typ_cplx,x1,x2=valeur + self.LEReel.setText(str(x1)) + self.LEImag.setText(str(x2)) + if typ_cplx == "RI" : + self.buttonGroup1.setButton(1) + else : + self.buttonGroup1.setButton(0) + + + def LEcompRPressed(self) : + self.LEReel.clear() + self.LEImag.clear() + commentaire="expression valide" + valeur = str(self.LEcomp.text()) + d={} + try : + v=eval(valeur,d) + except : + commentaire="expression invalide" + self.editor.affiche_infos(commentaire) + return + try : + i=v.imag + except : + commentaire="expression n est pas de la forme a+bj" + self.editor.affiche_infos(commentaire) + + def LEReelRPressed(self): + self.LEcomp.clear() + commentaire="expression valide" + valeur = str(self.LEReel.text()) + try : + a=string.atof(valeur) + except : + commentaire="expression invalide" + self.editor.affiche_infos(commentaire) + + def LEImagRPressed(self): + self.LEcomp.clear() + commentaire="expression valide" + valeur = str(self.LEImag.text()) + try : + a=string.atof(valeur) + except : + commentaire="expression invalide" + self.editor.affiche_infos(commentaire) + + def BOkPressed(self): + if self.LEcomp.text()== "" : + valeur = self.getValeurAster() + else : + if self.LEReel.text() != "" or self.LEImag.text() != "" : + commentaire="entrer une seule valeur SVP" + self.editor.affiche_infos(commentaire) + return + valeur= self.getValeurComp() + self.politique.RecordValeur(valeur) + + def getValeurAster(self): + """ + Retourne le complexe saisi par l'utilisateur + """ + l=[] + if (self.buttonGroup1.selectedId() == 0 ) : + l.append("MP") + elif (self.buttonGroup1.selectedId() == 1) : + l.append("RI") + else : + commentaire="saisir le type de complexe" + self.editor.affiche_infos(commentaire) + return None + try : + l.append(string.atof(str(self.LEReel.text()))) + l.append(string.atof(str(self.LEImag.text()))) + except : + return None + return `tuple(l)` + + def getValeurComp(self): + commentaire="expression valide" + valeur = str(self.LEcomp.text()) + d={} + try : + v=eval(valeur,d) + except : + commentaire="expression invalide" + self.editor.affiche_infos(commentaire) + return None + try : + i=v.imag + except : + commentaire="expression n est pas de la forme a+bj" + self.editor.affiche_infos(commentaire) + return None + return v + + def BSupPressed(self): + QTPanel.BSupPressed(self) + diff --git a/InterfaceQT/monUniqueIntoPanel.py b/InterfaceQT/monUniqueIntoPanel.py new file mode 100644 index 00000000..144dc700 --- /dev/null +++ b/InterfaceQT/monUniqueIntoPanel.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueIntoPanel import DUnIn +from qtCommun import QTPanel +from qtSaisie import SaisieValeur +from politiquesValidation import PolitiqueUnique + +# Import des panels + +class MonUniqueIntoPanel(DUnIn,QTPanel,SaisieValeur): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnIn.__init__(self,parent,name,fl) + SaisieValeur.RemplitPanel(self) + self.politique=PolitiqueUnique(node,parent) + QObject.connect(self.listBoxVal, SIGNAL("doubleClicked(QListBoxItem*)" ), self.ClicValeur ) + + def ClicValeur(self): + SaisieValeur.ClicValeur(self) + + def BOkPressed(self): + SaisieValeur.BOkPressed(self) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + diff --git a/InterfaceQT/monUniqueSDCOIntoPanel.py b/InterfaceQT/monUniqueSDCOIntoPanel.py new file mode 100644 index 00000000..7890d151 --- /dev/null +++ b/InterfaceQT/monUniqueSDCOIntoPanel.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueSDCOInto import DUnSDCOInto +from qtCommun import QTPanel +from qtSaisie import SaisieSDCO +from politiquesValidation import PolitiqueUnique + +# Import des panels + +class MonUniqueSDCOIntoPanel(DUnSDCOInto,QTPanel,SaisieSDCO): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnSDCOInto.__init__(self,parent,name,fl) + self.initLBSDCO() + + def initLBSDCO(self): + listeNomsSDCO = self.node.item.get_sd_avant_du_bon_type() + for aSDCO in listeNomsSDCO: + self.LBSDCO.insertItem( aSDCO) + valeur = self.node.item.get_valeur() + if valeur != "" and valeur != None : + self.LESDCO.setText(QString(valeur.nom)) + + def BOuiPressed(self): + self.rbOui.setChecked(1) + self.rbNon.setChecked(0) + self.LESDCO.setEnabled(1) + self.disconnect(self.LBSDCO,SIGNAL("clicked(QListBoxItem*)"),self.LBSDCOReturnPressed) + self.LBSDCO.clear() + + def BNonPressed(self): + self.rbOui.setChecked(0) + self.rbNon.setChecked(1) + self.LESDCO.setEnabled(0) + self.initLBSDCO() + self.connect(self.LBSDCO,SIGNAL("clicked(QListBoxItem*)"),self.LBSDCOReturnPressed) + + def LBSDCOReturnPressed(self): + """ + Teste si la valeur fournie par l'utilisateur est une valeur permise : + - si oui, l'enregistre + - si non, restaure l'ancienne valeur + """ + nomConcept=str(self.LBSDCO.currentText()) + self.editor.init_modif() + anc_val = self.node.item.get_valeur() + test_CO=self.node.item.is_CO(anc_val) + + valeur,validite=self.node.item.eval_valeur(nomConcept) + test = self.node.item.set_valeur(valeur) + if not test : + commentaire = "impossible d'évaluer : %s " %`valeur` + elif validite: + commentaire = "Valeur du mot-clé enregistrée" + if test_CO: + # il faut egalement propager la destruction de l'ancien concept + self.node.item.delete_valeur_co(valeur=anc_val) + self.node.item.object.etape.get_type_produit(force=1) + self.node.item.object.etape.parent.reset_context() + else : + commentaire = self.node.item.get_cr() + self.reset_old_valeur(anc_val,mess=mess) + self.Commentaire.setText(commentaire) + + def LESDCOReturnPressed(self) : + SaisieSDCO.LESDCOReturnPressed(self) + + def BOkPressed(self): + if self.rbOui.isChecked(): + self.LESDCOReturnPressed() + else: + self.LBSDCOReturnPressed() + + def BSupPressed(self): + QTPanel.BSupPressed(self) + diff --git a/InterfaceQT/monUniqueSDCOPanel.py b/InterfaceQT/monUniqueSDCOPanel.py new file mode 100644 index 00000000..dd23f829 --- /dev/null +++ b/InterfaceQT/monUniqueSDCOPanel.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os + +# Modules Eficas +from Aster import prefs + +from qt import * + +from desUniqueSDCO import DUnSDCO +from qtCommun import QTPanel +from qtSaisie import SaisieSDCO + +# Import des panels + +class MonUniqueSDCOPanel(DUnSDCO,QTPanel,SaisieSDCO): + """ + Classe définissant le panel associé aux mots-clés qui demandent + à l'utilisateur de choisir une seule valeur parmi une liste de valeurs + discrètes + """ + def __init__(self,node, parent = None,name = None,fl = 0): + QTPanel.__init__(self,node,parent) + DUnSDCO.__init__(self,parent,name,fl) + valeur = self.node.item.get_valeur() + if valeur != "" and valeur != None : + self.LESDCO.setText(QString(valeur.nom)) + + def BOkPressed(self): + SaisieSDCO.LESDCOReturnPressed(self) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + + def BOuiPressed(self): + self.Commentaire.setText("Aucun Objet de ce type n'est defini") + self.rbOui.setChecked(1) + + def LESDCOReturnPressed(self): + """ + Lit le nom donné par l'utilisateur au concept de type CO qui doit être + la valeur du MCS courant et stocke cette valeur + """ + SaisieSDCO.LESDCOReturnPressed(self) + diff --git a/InterfaceQT/myMain_ui.py b/InterfaceQT/myMain_ui.py new file mode 100644 index 00000000..697e5b47 --- /dev/null +++ b/InterfaceQT/myMain_ui.py @@ -0,0 +1,516 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'myMain.ui' +# +# Created: lun mar 5 15:21:40 2007 +# by: The PyQt User Interface Compiler (pyuic) 3.13 +# +# WARNING! All changes made in this file will be lost! + + +from qt import * + +image0_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\x74\x49\x44\x41\x54\x38\x8d\xed\xd5\xc1\x09\xc0" \ + "\x20\x0c\x05\xd0\x6f\xe9\x36\x81\x2c\x10\xb2\xff" \ + "\xdd\x85\xd2\x53\x85\xb6\xa9\x91\x48\x0f\x05\x3f" \ + "\x08\x1a\xf0\x29\x12\x10\xf8\x28\xc5\xa9\xd9\xc4" \ + "\xde\x96\xcd\x2b\x9a\xd9\xeb\x00\x00\x66\x0e\x2f" \ + "\xe0\xc2\x51\x98\x39\xc4\xf7\x0c\x4c\x44\x6d\x5e" \ + "\x6b\x35\x38\xcf\x92\x82\x45\xe4\xb2\xf6\xf0\x14" \ + "\xac\xaa\x8f\xda\x1d\x4f\xc1\xa5\x74\x1b\x22\x07" \ + "\x9f\x9d\x11\x1d\x96\xea\x8a\x91\x2c\x78\xc1\x0b" \ + "\xee\x64\xe6\x07\x19\xf5\x7e\x92\x03\xad\x45\x2a" \ + "\x04\xcc\x4e\x50\x20\x00\x00\x00\x00\x49\x45\x4e" \ + "\x44\xae\x42\x60\x82" +image1_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\x99\x49\x44\x41\x54\x38\x8d\xed\x94\x41\x0e\x85" \ + "\x20\x0c\x44\x5f\x89\xc7\x36\x7f\x61\xbc\x77\x5d" \ + "\x28\x48\xa4\x28\x60\xff\xce\xd9\x54\x8b\xbe\x8e" \ + "\x13\x04\x3e\x1d\x92\x81\x77\xf4\x81\xa1\x23\xdc" \ + "\x2b\x34\xf6\xf4\x7a\x3d\xe2\xb8\x65\xa8\x84\x3f" \ + "\x40\x01\x98\x2a\x0b\x3d\x5f\x62\xc5\x83\x00\xaa" \ + "\x1a\xd7\x05\x50\x44\x9a\xb9\xd5\x07\xa7\x73\xa8" \ + "\xa4\xba\x4f\x92\xa2\xdf\x33\x3c\x64\xc6\x3b\xeb" \ + "\xbd\x82\xe5\xb8\xad\xde\xcb\xcc\x78\x20\xeb\x42" \ + "\x66\xc6\x39\x74\x5d\xfa\x80\xf3\x6f\xaf\x66\xc6" \ + "\x6f\xa1\x9c\x3f\x88\x2f\xb4\x70\xec\x05\xcd\xc0" \ + "\xbe\xd0\x78\x93\xf6\x8e\x17\x14\x92\x63\x5f\x68" \ + "\x6c\x3e\xef\xf6\xba\x3c\x8f\xdd\x36\x6d\xc4\xc0" \ + "\x45\x2c\x87\x81\xf8\x08\x00\x00\x00\x00\x49\x45" \ + "\x4e\x44\xae\x42\x60\x82" +image2_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\xa0\x49\x44\x41\x54\x38\x8d\xd5\x95\x4d\x0a\x80" \ + "\x20\x10\x85\x9f\xd1\x46\x68\xe1\x8d\xe6\x62\xd2" \ + "\x22\xbc\x98\x37\x6a\x21\xb4\xac\x45\x19\x92\xc6" \ + "\x64\x69\xe0\xb7\xf1\x87\xf1\xf1\x1c\x47\x05\x2a" \ + "\x21\x8e\x76\x2d\xad\xdb\xfb\x9e\x99\xf6\x56\x8f" \ + "\x80\xb5\x36\x4b\x85\x88\xce\x35\x44\x04\x00\xe8" \ + "\x0a\x39\x8c\xe8\xf9\x90\x34\xd2\x29\x2c\xc3\x7c" \ + "\x8e\xbd\x53\x0f\xeb\x58\x3a\x05\xe9\x54\x34\x1f" \ + "\x8a\x02\x7b\x2a\x7d\x3a\x1f\x09\xbf\x85\x4d\xc5" \ + "\xd5\xd9\x53\xaa\x39\x6e\x4f\x38\xca\xb1\x99\xe2" \ + "\xd2\xe1\x08\xab\xe1\x56\xf8\x2e\x30\x97\x7f\xcb" \ + "\x4d\x8f\xf9\x42\xd7\x5d\xbe\xbe\xd2\xe1\x43\x95" \ + "\x3a\x93\xf6\xca\xad\x3d\x61\x11\xf4\x4b\x7d\x4f" \ + "\x82\x0f\xf9\xc0\x06\x9b\xb5\x1e\xcd\xed\x31\x8c" \ + "\x5c\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" \ + "\x82" +image3_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\x73\x49\x44\x41\x54\x38\x8d\xed\x92\xc1\x0e\x80" \ + "\x20\x08\x40\xb1\xef\x66\x1d\x1c\xff\x4d\x87\x6a" \ + "\xa8\x88\xa1\x76\x69\xf9\x36\x0f\x28\x3e\xd8\x00" \ + "\x60\xf1\x59\x42\x5f\x3a\x71\xf5\x36\x02\xe0\x8e" \ + "\x99\x2b\x09\x88\x01\xd0\x28\x54\x17\x6a\xe4\x7f" \ + "\x21\xce\x1f\xb5\xb0\x5d\x38\xed\xdc\x90\x60\xd0" \ + "\xf1\x13\x79\x63\x5b\x3b\xc9\x2b\xd5\x18\xe2\x39" \ + "\xa9\x43\xec\x1d\x5a\xb7\x78\x5c\xee\x10\x7b\xe4" \ + "\xb2\x15\xaf\x40\x91\xf8\x94\xde\x47\x18\x1e\xce" \ + "\xa5\x9e\xde\x9e\xc5\x9f\x38\x00\x62\xac\x28\xb1" \ + "\xe3\xd7\x01\xd9\x00\x00\x00\x00\x49\x45\x4e\x44" \ + "\xae\x42\x60\x82" +image4_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\x74\x49\x44\x41\x54\x38\x8d\xed\x92\xc1\x0a\xc0" \ + "\x20\x08\x40\x6d\xdf\x2d\x3b\x84\xff\xed\x0e\xa3" \ + "\x58\x6a\x26\xd1\x65\xe0\x83\x0e\xa5\x3e\x85\x04" \ + "\x48\x7e\x4b\x91\x0f\x54\x89\xf1\x9e\xa5\xa3\xca" \ + "\x0f\x8a\x89\x63\x65\xb3\x06\xc4\x2d\xd6\x13\xc6" \ + "\x49\xbd\xc2\x59\x83\x16\x13\x62\x19\xf0\xf9\x36" \ + "\xc0\xa2\xef\x00\xd7\x5a\x62\x61\x4d\x3a\xb2\x29" \ + "\x96\xf2\xa3\x62\xff\xa3\x37\xc5\xeb\xed\xe9\x62" \ + "\xaa\xd1\xa2\xe8\x4a\xaa\xa2\xf7\x50\xdd\x12\x74" \ + "\x8c\x0f\xd0\xab\x93\x24\x67\x78\x00\x59\x6e\x28" \ + "\xb1\x74\x3f\x46\x86\x00\x00\x00\x00\x49\x45\x4e" \ + "\x44\xae\x42\x60\x82" +image5_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\x82\x49\x44\x41\x54\x38\x8d\xcd\xd3\x41\x12\x80" \ + "\x20\x08\x05\x50\xe8\xe0\x2e\xbc\x38\xad\x32\x73" \ + "\x50\x3e\x48\x53\x7f\xe3\xe4\x8c\x4f\x24\x25\xfa" \ + "\x28\xe2\x9c\x6f\x39\x92\x0b\xf9\x27\x6c\xb6\x01" \ + "\x85\x35\x88\x77\x61\x13\x88\xc2\x57\x64\x18\xcd" \ + "\xa0\x15\xf5\x20\xb4\xe6\xb5\x5b\xe1\x09\xdc\x06" \ + "\x22\xb8\xe2\x2a\xcf\x31\x05\x6e\x18\xdf\xdf\xf8" \ + "\x06\x06\xaa\x55\x1c\xc6\x35\x64\xc4\xdc\xf8\x0c" \ + "\xd0\x20\x1d\x57\x7a\x5c\x85\xa8\x84\x5f\xdc\x02" \ + "\x5e\xa5\x30\x7a\xfc\xcd\x07\xe2\x3a\x1d\xf2\x83" \ + "\xec\x2b\x37\xd9\xad\x5f\xb4\xdf\xef\xd4\x9c\xfb" \ + "\xf7\x2f\xac\x98\xc8\xcc\x89\x00\x00\x00\x00\x49" \ + "\x45\x4e\x44\xae\x42\x60\x82" +image6_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\xbf\x49\x44\x41\x54\x38\x8d\xd5\x93\x41\x0a\x83" \ + "\x30\x10\x45\xdf\x48\x8e\xe5\x1d\xbc\x8c\x3b\xa9" \ + "\x8b\xf4\x6a\x9e\xab\xd3\x85\x35\x0d\x26\x63\x62" \ + "\x44\x4a\x3f\x0c\x42\x66\xfc\xf3\xf8\x24\xf0\x6f" \ + "\x12\x40\x2b\x66\xda\x8c\x55\xf3\xde\x22\x12\xcf" \ + "\x9d\x92\xcb\x98\xc0\xba\x2d\x7c\x45\x44\xcf\x9a" \ + "\x07\x63\x8b\xba\xd5\x3c\x44\x91\x23\x5e\xcf\x7c" \ + "\xc1\x62\x36\x97\xa9\x25\x40\xc1\x1f\xf4\xfd\xa7" \ + "\x52\x75\x01\x5d\x24\xa9\x38\x9e\x7d\x6f\x53\xdf" \ + "\x4f\xe4\xcc\xab\x32\x3e\xea\x0f\x03\xc0\xc4\xb2" \ + "\xa0\x71\x2c\xe6\xad\xd8\x9b\x59\xb7\x66\x1c\x3b" \ + "\xe0\x95\x98\x5f\x26\x16\x79\xee\x4e\xbc\xc2\x2c" \ + "\x97\x88\x55\x1f\xe6\xa2\xcb\xc4\x96\x9a\x89\x4b" \ + "\xcb\x6f\x23\xee\x36\x1a\xab\x62\xe2\x52\xc5\x72" \ + "\x94\xdf\xbf\xb6\x10\xbb\xf2\xc8\x97\xb8\xa4\x6c" \ + "\xc6\x67\x7e\xaa\x51\x95\x71\xfa\x08\x7e\xa8\x37" \ + "\x62\xda\x9a\xba\xcb\x20\x23\x5f\x00\x00\x00\x00" \ + "\x49\x45\x4e\x44\xae\x42\x60\x82" +image7_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x00" \ + "\xd5\x49\x44\x41\x54\x38\x8d\xc5\x95\x5d\x0a\x84" \ + "\x30\x0c\x84\x27\xe2\xa9\x0a\x9e\x6c\x8b\x0f\x4b" \ + "\x3d\xd9\x82\xd7\xca\x3e\x58\xd7\xfe\x4c\xd0\xba" \ + "\x5d\x76\x40\x02\x4d\xf2\x65\xda\x0a\x05\x7e\x24" \ + "\x39\xc9\xeb\x8d\x9e\xaa\x88\x41\xa0\xc9\xaa\xd8" \ + "\xc8\x2a\xb3\x2f\x9c\x42\x5b\xe1\xe3\x0e\x0d\xcf" \ + "\x00\xc0\x03\x08\xf0\xb3\xa7\xa0\x74\x10\xa9\xd7" \ + "\x14\x2e\x00\xb4\x2c\x5a\x5f\xab\x69\x6b\x97\x9b" \ + "\x1c\x83\x7f\xc0\xc3\x16\xb6\xe4\x16\x5b\x64\xf7" \ + "\x8d\x71\x63\x59\x91\x9b\xdc\x45\x70\xde\x47\xc0" \ + "\x47\x32\xdd\x5e\x5b\xcc\x35\xf0\xc9\x77\x62\xae" \ + "\x78\x79\x36\xdc\xcf\x75\x13\x57\x7e\x79\xf4\x8c" \ + "\x4b\x27\xaa\x0f\x13\x27\xb2\x40\xf5\x11\x7f\xcb" \ + "\xe3\x48\xaa\x33\xb6\xe0\x22\x4b\x05\x4d\x07\x46" \ + "\xb8\x02\x5e\x2e\x3b\x3e\x73\xcd\xe0\xdd\x1c\x97" \ + "\xf0\x2e\x8e\xd9\xd0\xaf\x1d\xb3\x81\x22\x4b\xdf" \ + "\x33\xee\xe6\x98\xa9\x34\xa0\xf6\x17\xb4\x55\x40" \ + "\xd0\x0b\xcf\x4c\xa0\x8f\xc0\xdf\xf4\x06\xe3\x25" \ + "\xc1\x98\x1b\xc4\x18\x76\x00\x00\x00\x00\x49\x45" \ + "\x4e\x44\xae\x42\x60\x82" +image8_data = \ + "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d" \ + "\x49\x48\x44\x52\x00\x00\x00\x16\x00\x00\x00\x16" \ + "\x08\x06\x00\x00\x00\xc4\xb4\x6c\x3b\x00\x00\x02" \ + "\x5d\x49\x44\x41\x54\x38\x8d\xd5\x93\xa1\x72\xdb" \ + "\x40\x10\x86\x3f\x67\x0a\x56\xec\xc4\x22\x78\xd0" \ + "\x65\x36\x93\xa0\xc2\x1c\x68\xd6\xc2\xe6\x0d\xf2" \ + "\x1a\x81\x81\x11\x34\x94\x99\xc2\x54\xa8\x32\x9b" \ + "\x55\xf0\xe0\x89\xdd\xb1\x5b\xa6\x02\xb7\x9d\x66" \ + "\x92\xd6\x99\xb6\xd3\x99\xfe\xe8\x6e\x67\xe7\xdb" \ + "\x7f\x77\xef\xe0\x7f\xd3\xe2\xc7\x4b\xd7\x75\xb3" \ + "\x73\x0e\xef\x3d\x51\x15\x00\x23\x82\xb5\x16\x6b" \ + "\x2d\x57\x57\x57\x8b\x17\x29\xbf\x02\xb7\x6d\x3b" \ + "\x0f\x87\x03\xb9\x2d\x58\xae\xd7\x60\x04\x00\xef" \ + "\x1c\xe3\xc7\x03\x06\xa8\xaa\x8a\xeb\xeb\xeb\x57" \ + "\xc1\x17\xdf\xa0\x6d\xdb\x52\x5d\xd7\x54\xef\xb6" \ + "\x00\xa8\x2a\x49\x13\x8a\x12\x35\x32\xec\x3a\xc4" \ + "\x2b\x9b\xcd\xe6\x55\xce\x2f\xfa\xbe\x9f\x87\xc3" \ + "\x40\xfd\xe1\x3d\xcb\x4d\x8d\xaa\xa2\x4e\x48\xee" \ + "\x12\xc6\x82\x38\x08\xc1\x07\x96\x9b\x1a\x8a\x9c" \ + "\xe3\xf1\xf8\xaa\x51\x5c\x38\xe7\xc8\xad\xa5\xaa" \ + "\x6b\x00\xc4\x5f\x12\x9c\x67\xd2\x23\x93\x8c\x88" \ + "\xe6\xc8\x60\xd1\x18\xb1\xd5\x92\xd1\x39\xba\xae" \ + "\x9b\xcf\x83\xa7\x89\x65\xb5\x46\x51\x34\x80\x1b" \ + "\x1d\x2e\x1f\x49\x45\xc0\xe3\x50\x09\x64\x08\xea" \ + "\x15\x44\x90\xc2\xe0\xbd\x3f\xef\x58\x53\xc2\xe4" \ + "\x86\xa0\x01\x9f\x4d\x84\xf5\x84\x18\x41\x83\x62" \ + "\xb0\x40\x8e\x8b\x23\xc9\x24\x50\x10\x93\x31\x4d" \ + "\xd3\x59\xf0\x1b\x80\x98\x14\x11\x20\x25\x14\x40" \ + "\x15\xf1\x96\x4c\x0b\xbc\x1b\x48\x4b\x07\xe4\x68" \ + "\x88\x80\xc0\x29\xeb\xd7\x8e\x41\x41\xf5\xb4\x34" \ + "\xfd\x76\x86\x4c\x05\x3f\x1e\x08\x4b\x0f\x85\x80" \ + "\x26\x54\x40\x63\x40\x44\xce\x83\x8b\xbc\xc0\x39" \ + "\x87\xa6\x13\x50\xa3\xa2\x28\x5e\x1d\x5a\x44\x14" \ + "\xd0\x70\x8a\xa5\x98\x08\x21\x62\xad\x3d\x0f\xb6" \ + "\xd6\xe2\x87\xcf\xa4\x98\x50\x8d\x27\x40\x50\x44" \ + "\x73\x70\x42\x8c\x91\xaf\x8d\x10\xfd\x44\x81\x60" \ + "\x8c\x39\x0b\x5e\x00\xdc\xdd\xdd\xcd\x8e\x80\xa9" \ + "\xde\x42\x02\x48\xe8\x04\x84\x08\x56\xf0\x3e\x02" \ + "\x90\x7d\x72\x94\x65\xc9\xba\x5a\xe3\x46\x87\x31" \ + "\xe6\xa7\x9f\xe5\x02\x60\xb5\x5a\x61\x02\xc4\xee" \ + "\x40\xa6\x89\x4c\x33\xf2\xcb\x0c\xb1\x06\x51\x28" \ + "\x14\xf8\xf8\x99\xb2\x2c\xb9\xb9\xb9\x59\xb8\xd1" \ + "\xf1\xf8\xf8\x48\xd3\x34\xb4\x6d\xfb\xe2\x9b\xfe" \ + "\x5e\xad\xef\xfb\xf9\x78\x3c\x32\x3a\x87\x18\x81" \ + "\xec\xb4\x20\x0d\x11\x51\xa8\xeb\x9a\xed\x76\xbb" \ + "\x00\x18\x86\x61\xee\xba\x8e\xfd\x7e\x8f\x31\x86" \ + "\xed\x76\xcb\x6a\xb5\x7a\xe2\xfe\x59\x1b\x5d\xd7" \ + "\xcd\xde\x7b\x62\x8c\x88\x08\x79\x9e\x63\xad\xa5" \ + "\xaa\xaa\x67\xb9\xbb\xdd\x6e\x6e\x9a\x06\xef\x3d" \ + "\x75\x5d\x3f\x29\xfe\xc7\xea\xfb\x7e\xbe\xbd\xbd" \ + "\x9d\xad\xb5\x73\x59\x96\xf3\xfd\xfd\xfd\xfc\xa2" \ + "\xe3\xdf\xd5\xc3\xc3\xc3\xdc\x34\x0d\xd3\x34\xb1" \ + "\xd9\x6c\xfe\x1e\x18\x4e\x63\xdc\xef\xf7\xa4\x94" \ + "\xfe\x26\xf6\x1f\xe9\x0b\xbc\x4c\x5e\x59\xd6\x14" \ + "\xca\xf4\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42" \ + "\x60\x82" + +class Eficas(QMainWindow): + def __init__(self,parent = None,name = None,fl = 0): + QMainWindow.__init__(self,parent,name,fl) + self.statusBar() + + self.image0 = QPixmap() + self.image0.loadFromData(image0_data,"PNG") + self.image1 = QPixmap() + self.image1.loadFromData(image1_data,"PNG") + self.image2 = QPixmap() + self.image2.loadFromData(image2_data,"PNG") + self.image3 = QPixmap() + self.image3.loadFromData(image3_data,"PNG") + self.image4 = QPixmap() + self.image4.loadFromData(image4_data,"PNG") + self.image5 = QPixmap() + self.image5.loadFromData(image5_data,"PNG") + self.image6 = QPixmap() + self.image6.loadFromData(image6_data,"PNG") + self.image7 = QPixmap() + self.image7.loadFromData(image7_data,"PNG") + self.image8 = QPixmap() + self.image8.loadFromData(image8_data,"PNG") + if not name: + self.setName("Eficas") + + self.setEnabled(1) + self.setMinimumSize(QSize(902,575)) + self.setBackgroundOrigin(QMainWindow.WidgetOrigin) + f = QFont(self.font()) + self.setFont(f) + + self.setCentralWidget(QWidget(self,"qt_central_widget")) + + self.line1 = QFrame(self.centralWidget(),"line1") + self.line1.setGeometry(QRect(-30,-10,930,20)) + self.line1.setFrameShape(QFrame.HLine) + self.line1.setFrameShadow(QFrame.Sunken) + self.line1.setFrameShape(QFrame.HLine) + + self.fileNewAction = QAction(self,"fileNewAction") + self.fileNewAction.setIconSet(QIconSet(self.image0)) + self.fileOpenAction = QAction(self,"fileOpenAction") + self.fileOpenAction.setIconSet(QIconSet(self.image1)) + self.fileSaveAction = QAction(self,"fileSaveAction") + self.fileSaveAction.setIconSet(QIconSet(self.image2)) + self.fileSaveAsAction = QAction(self,"fileSaveAsAction") + self.fileExitAction = QAction(self,"fileExitAction") + self.editUndoAction = QAction(self,"editUndoAction") + self.editUndoAction.setIconSet(QIconSet(self.image3)) + self.editRedoAction = QAction(self,"editRedoAction") + self.editRedoAction.setIconSet(QIconSet(self.image4)) + self.editCutAction = QAction(self,"editCutAction") + self.editCutAction.setIconSet(QIconSet(self.image5)) + self.editCopyAction = QAction(self,"editCopyAction") + self.editCopyAction.setIconSet(QIconSet(self.image6)) + self.editPasteAction = QAction(self,"editPasteAction") + self.editPasteAction.setIconSet(QIconSet(self.image7)) + self.editFindAction = QAction(self,"editFindAction") + self.editFindAction.setIconSet(QIconSet(self.image8)) + self.helpContentsAction = QAction(self,"helpContentsAction") + self.helpIndexAction = QAction(self,"helpIndexAction") + self.helpAboutAction = QAction(self,"helpAboutAction") + self.traductionnew_itemAction = QAction(self,"traductionnew_itemAction") + self.fileSaveCloseAction = QAction(self,"fileSaveCloseAction") + self.fileCloseAction = QAction(self,"fileCloseAction") + self.fileNewViewAction = QAction(self,"fileNewViewAction") + self.fileCloseAllAction = QAction(self,"fileCloseAllAction") + self.jdcRapportDeValidationAction = QAction(self,"jdcRapportDeValidationAction") + self.jdcFichierSourceAction = QAction(self,"jdcFichierSourceAction") + + + self.toolBar = QToolBar(QString(""),self,Qt.DockTop) + + self.toolBar.setFrameShape(QToolBar.MenuBarPanel) + self.toolBar.setHorizontallyStretchable(0) + self.fileNewAction.addTo(self.toolBar) + self.fileSaveAction.addTo(self.toolBar) + self.fileOpenAction.addTo(self.toolBar) + self.fileSaveAsAction.addTo(self.toolBar) + self.editCutAction.addTo(self.toolBar) + self.editPasteAction.addTo(self.toolBar) + self.editFindAction.addTo(self.toolBar) + self.fileExitAction.addTo(self.toolBar) + + + self.MenuBar = QMenuBar(self,"MenuBar") + + self.MenuBar.setMargin(2) + + self.Fichier = QPopupMenu(self) + self.fileNewAction.addTo(self.Fichier) + self.fileNewViewAction.addTo(self.Fichier) + self.fileOpenAction.addTo(self.Fichier) + self.fileSaveAction.addTo(self.Fichier) + self.fileSaveAsAction.addTo(self.Fichier) + self.fileCloseAction.addTo(self.Fichier) + self.fileCloseAllAction.addTo(self.Fichier) + self.Fichier.insertSeparator() + self.Fichier.insertSeparator() + self.fileExitAction.addTo(self.Fichier) + self.MenuBar.insertItem(QString(""),self.Fichier,2) + + self.Edition = QPopupMenu(self) + self.Edition.insertSeparator() + self.editCutAction.addTo(self.Edition) + self.editCopyAction.addTo(self.Edition) + self.editPasteAction.addTo(self.Edition) + self.Edition.insertSeparator() + self.editFindAction.addTo(self.Edition) + self.MenuBar.insertItem(QString(""),self.Edition,3) + + self.JdC = QPopupMenu(self) + self.jdcRapportDeValidationAction.addTo(self.JdC) + self.jdcFichierSourceAction.addTo(self.JdC) + self.MenuBar.insertItem(QString(""),self.JdC,4) + + self.Options = QPopupMenu(self) + self.MenuBar.insertItem(QString(""),self.Options,5) + + self.Aide = QPopupMenu(self) + self.MenuBar.insertItem(QString(""),self.Aide,6) + + self.Traduction = QPopupMenu(self) + self.traductionnew_itemAction.addTo(self.Traduction) + self.MenuBar.insertItem(QString(""),self.Traduction,7) + + self.Patrons = QPopupMenu(self) + self.MenuBar.insertItem(QString(""),self.Patrons,8) + + + self.languageChange() + + self.resize(QSize(902,575).expandedTo(self.minimumSizeHint())) + self.clearWState(Qt.WState_Polished) + + self.connect(self.fileNewAction,SIGNAL("activated()"),self.fileNew) + self.connect(self.fileOpenAction,SIGNAL("activated()"),self.fileOpen) + self.connect(self.fileSaveAction,SIGNAL("activated()"),self.fileSave) + self.connect(self.fileSaveAsAction,SIGNAL("activated()"),self.fileSaveAs) + self.connect(self.fileExitAction,SIGNAL("activated()"),self.fileExit) + self.connect(self.editUndoAction,SIGNAL("activated()"),self.editUndo) + self.connect(self.editRedoAction,SIGNAL("activated()"),self.editRedo) + self.connect(self.editCutAction,SIGNAL("activated()"),self.editCut) + self.connect(self.editPasteAction,SIGNAL("activated()"),self.editPaste) + self.connect(self.editFindAction,SIGNAL("activated()"),self.editFind) + self.connect(self.helpIndexAction,SIGNAL("activated()"),self.helpIndex) + self.connect(self.helpContentsAction,SIGNAL("activated()"),self.helpContents) + self.connect(self.helpAboutAction,SIGNAL("activated()"),self.helpAbout) + self.connect(self.fileCloseAction,SIGNAL("activated()"),self.fileClose) + self.connect(self.fileNewViewAction,SIGNAL("activated()"),self.fileNewView) + self.connect(self.fileCloseAllAction,SIGNAL("activated()"),self.fileCloseAll) + self.connect(self.editCopyAction,SIGNAL("activated()"),self.editCopy) + self.connect(self.jdcRapportDeValidationAction,SIGNAL("activated()"),self.jdcRapport) + self.connect(self.jdcFichierSourceAction,SIGNAL("activated()"),self.jdcFichierSource) + + + def languageChange(self): + self.setCaption(self.__tr("Eficas ")) + self.fileNewAction.setText(self.__tr("New")) + self.fileNewAction.setMenuText(self.__tr("&New")) + self.fileNewAction.setAccel(self.__tr("Ctrl+N")) + self.fileOpenAction.setText(self.__tr("Open")) + self.fileOpenAction.setMenuText(self.__tr("&Open...")) + self.fileOpenAction.setAccel(self.__tr("Ctrl+O")) + self.fileSaveAction.setText(self.__tr("Save")) + self.fileSaveAction.setMenuText(self.__tr("&Save")) + self.fileSaveAction.setAccel(self.__tr("Ctrl+S")) + self.fileSaveAsAction.setText(self.__tr("Save As")) + self.fileSaveAsAction.setMenuText(self.__tr("Save &As...")) + self.fileSaveAsAction.setAccel(QString.null) + self.fileExitAction.setText(self.__tr("Exit")) + self.fileExitAction.setMenuText(self.__tr("E&xit")) + self.fileExitAction.setAccel(QString.null) + self.editUndoAction.setText(self.__tr("Undo")) + self.editUndoAction.setMenuText(self.__tr("&Undo")) + self.editUndoAction.setAccel(self.__tr("Ctrl+Z")) + self.editRedoAction.setText(self.__tr("Redo")) + self.editRedoAction.setMenuText(self.__tr("&Redo")) + self.editRedoAction.setAccel(self.__tr("Ctrl+Y")) + self.editCutAction.setText(self.__tr("Cut")) + self.editCutAction.setMenuText(self.__tr("Cu&t")) + self.editCutAction.setAccel(self.__tr("Ctrl+X")) + self.editCopyAction.setText(self.__tr("Copy")) + self.editCopyAction.setMenuText(self.__tr("&Copy")) + self.editCopyAction.setAccel(self.__tr("Ctrl+C")) + self.editPasteAction.setText(self.__tr("Paste")) + self.editPasteAction.setMenuText(self.__tr("&Paste")) + self.editPasteAction.setAccel(self.__tr("Ctrl+V")) + self.editFindAction.setText(self.__tr("Find")) + self.editFindAction.setMenuText(self.__tr("&Find...")) + self.editFindAction.setAccel(self.__tr("Ctrl+F")) + self.helpContentsAction.setText(self.__tr("Contents")) + self.helpContentsAction.setMenuText(self.__tr("&Contents...")) + self.helpContentsAction.setAccel(QString.null) + self.helpIndexAction.setText(self.__tr("Index")) + self.helpIndexAction.setMenuText(self.__tr("&Index...")) + self.helpIndexAction.setAccel(QString.null) + self.helpAboutAction.setText(self.__tr("About")) + self.helpAboutAction.setMenuText(self.__tr("&About")) + self.helpAboutAction.setAccel(QString.null) + self.traductionnew_itemAction.setText(self.__tr("new item")) + self.traductionnew_itemAction.setMenuText(self.__tr("new item")) + self.fileSaveCloseAction.setText(self.__tr("Close")) + self.fileSaveCloseAction.setMenuText(self.__tr("Close")) + self.fileCloseAction.setText(self.__tr("Close")) + self.fileCloseAction.setMenuText(self.__tr("Close")) + self.fileCloseAction.setAccel(self.__tr("Ctrl+W")) + self.fileNewViewAction.setText(self.__tr("New view")) + self.fileCloseAllAction.setText(self.__tr("Close All")) + self.fileCloseAllAction.setMenuText(self.__tr("Close All")) + self.jdcRapportDeValidationAction.setText(self.__tr("Rapport de validation")) + self.jdcRapportDeValidationAction.setMenuText(self.__tr("Rapport de validation")) + self.jdcRapportDeValidationAction.setAccel(self.__tr("Ctrl+R")) + self.jdcFichierSourceAction.setText(self.__tr("Fichier source")) + self.jdcFichierSourceAction.setMenuText(self.__tr("Fichier source")) + self.jdcFichierSourceAction.setAccel(self.__tr("Ctrl+B")) + self.toolBar.setLabel(self.__tr("Tools")) + if self.MenuBar.findItem(2): + self.MenuBar.findItem(2).setText(self.__tr("&Fichier")) + if self.MenuBar.findItem(3): + self.MenuBar.findItem(3).setText(self.__tr("&Edition")) + if self.MenuBar.findItem(4): + self.MenuBar.findItem(4).setText(self.__tr("JdC")) + if self.MenuBar.findItem(5): + self.MenuBar.findItem(5).setText(self.__tr("Options")) + if self.MenuBar.findItem(6): + self.MenuBar.findItem(6).setText(self.__tr("&Aide")) + if self.MenuBar.findItem(7): + self.MenuBar.findItem(7).setText(self.__tr("Traduction")) + if self.MenuBar.findItem(8): + self.MenuBar.findItem(8).setText(self.__tr("Patrons")) + + + def fileNew(self): + print "Eficas.fileNew(): Not implemented yet" + + def fileOpen(self): + print "Eficas.fileOpen(): Not implemented yet" + + def fileSave(self): + print "Eficas.fileSave(): Not implemented yet" + + def fileSaveAs(self): + print "Eficas.fileSaveAs(): Not implemented yet" + + def filePrint(self): + print "Eficas.filePrint(): Not implemented yet" + + def fileExit(self): + print "Eficas.fileExit(): Not implemented yet" + + def editUndo(self): + print "Eficas.editUndo(): Not implemented yet" + + def editRedo(self): + print "Eficas.editRedo(): Not implemented yet" + + def jdcFichierSource(self): + print "Eficas.jdcFichierSource(): Not implemented yet" + + def fileNewView(self): + print "Eficas.fileNewView(): Not implemented yet" + + def editPaste(self): + print "Eficas.editPaste(): Not implemented yet" + + def editFind(self): + print "Eficas.editFind(): Not implemented yet" + + def helpIndex(self): + print "Eficas.helpIndex(): Not implemented yet" + + def helpContents(self): + print "Eficas.helpContents(): Not implemented yet" + + def helpAbout(self): + print "Eficas.helpAbout(): Not implemented yet" + + def fileClose(self): + print "Eficas.fileClose(): Not implemented yet" + + def fileCloseAll(self): + print "Eficas.fileCloseAll(): Not implemented yet" + + def jdcRapport(self): + print "Eficas.jdcRapport(): Not implemented yet" + + def editCut(self): + print "Eficas.editCut(): Not implemented yet" + + def editCopy(self): + print "Eficas.editCopy(): Not implemented yet" + + def __tr(self,s,c = None): + return qApp.translate("Eficas",s,c) diff --git a/InterfaceQT/panelsQT.py b/InterfaceQT/panelsQT.py new file mode 100644 index 00000000..cc2125fe --- /dev/null +++ b/InterfaceQT/panelsQT.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import string +import os + +import traceback + +from qt import * +from qtCommun import QTPanel +from desInactif import DInactif + + +SEPARATEUR = '-'*30 + + +class PanelInactif( QTPanel, DInactif ): + def __init__(self,node,parent=None ): + DInactif.__init__(self,parent) + QTPanel.__init__(self,node,parent) + + +class NoPanel( QWidget ): + def __init__(self,parent = None,name = None,fl = 0): + QWidget.__init__(self,parent,name,fl) + self.textLabel = QLabel(self) + self.textLabel.setText(QString("PANNEAU A IMPLEMENTER")) + self.textLabel.setGeometry(QRect(130,150,219,17)) + self.resize(QSize(600,480).expandedTo(self.minimumSizeHint())) + diff --git a/InterfaceQT/politiquesValidation.py b/InterfaceQT/politiquesValidation.py new file mode 100644 index 00000000..7509da01 --- /dev/null +++ b/InterfaceQT/politiquesValidation.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import types + +from qt import * + + +#------------------ +class Validation : +#------------------ + def __init__(self,node,parent) : + self.node=node + self.parent=parent + + def TesteUneValeur(self,valeurentree): + valeur,validite=self.node.item.eval_valeur(valeurentree) + if not validite : + commentaire = "impossible d'évaluer : %s " %`valeurentree` + return valeur,validite,commentaire + + testtype,commentaire = self.node.item.object.verif_type(valeur) + if not testtype : + return valeur,0,commentaire + + valide=self.node.item.valide_item(valeur) + if type(valide) == types.TupleType: + validite,commentaire=valide + else : + validite=valide + commentaire=" " + + if not validite : + commentaire = "impossible d'évaluer : %s " %`valeurentree` + return valeur, validite, commentaire + +# ---------------------------------------------------------------------------------------- +# Méthodes utilisées pour la manipulation des items en notation scientifique +# a mettre au point +# ---------------------------------------------------------------------------------------- + def SetValeurTexte(self,texteValeur) : + try : + if "R" in self.node.item.object.definition.type: + if texteValeur[0] != "'": + clef=eval(texteValeur) + if str(clef) != str(texteValeur) : + self.node.item.object.init_modif() + clefobj=self.node.item.object.GetNomConcept() + if not self.parent.dict_reels.has_key(clefobj): + self.parent.dict_reels[clefobj] = {} + self.parent.dict_reels[clefobj][clef]=texteValeur + self.parent.dict_reels[clefobj] + self.node.item.object.fin_modif() + except: + pass + + def GetValeurTexte(self,valeur) : + valeurTexte=valeur + if "R" in self.node.item.object.definition.type: + clefobj=self.node.item.object.GetNomConcept() + if self.parent.dict_reels.has_key(clefobj): + if self.parent.dict_reels[clefobj].has_key(valeur): + valeurTexte=self.parent.dict_reels[clefobj][valeur] + return valeurTexte + +#------------------------------------ +class PolitiqueUnique(Validation) : +#------------------------------------ + """ + classe servant pour les entrees ne demandant qu un mot clef + """ + def __init__(self,node,parent): + Validation.__init__(self,node,parent) + + def RecordValeur(self,valeurentree): + if self.parent.modified == 'n' : self.parent.init_modif() + ancienne_val = self.node.item.get_valeur() + valeur,validite,commentaire =self.TesteUneValeur(valeurentree) + if validite : + validite=self.node.item.set_valeur(valeur) + if self.node.item.isvalid(): + commentaire = "Valeur du mot-clé enregistrée" + self.SetValeurTexte(str(valeurentree)) + else: + cr = self.node.item.get_cr() + commentaire = "Valeur du mot-clé non autorisée "+cr.get_mess_fatal() + self.node.item.set_valeur(ancienne_val) + return validite, commentaire + + +#------------------------ +class PolitiquePlusieurs: +#------------------------ + """ + classe servant pour les entrees ne demandant qu un mot clef + """ + def __init__(self,node,parent) : + self.node=node + self.parent=parent + + + def AjoutValeurs(self,listevaleur,index,listecourante): + listeRetour=[] + commentaire="Nouvelle valeur acceptée" + commentaire2="" + valide=1 + for valeur in listevaleur : + # On teste le type de la valeur + valide=self.node.item.valide_item(valeur) + if not valide: + commentaire="Valeur "+str(valeur)+ "incorrecte : ajout à la liste refusé" + commentaire2=self.node.item.info_erreur_item() + return valide,commentaire,commentaire2,listeRetour + + # On valide la liste obtenue + encorevalide=self.node.item.valide_liste_partielle(valeur,listecourante) + if not encorevalide : + commentaire2=self.node.item.info_erreur_liste() + # On traite le cas ou la liste n est pas valide pour un pb de cardinalite + min,max = self.node.item.GetMinMax() + if len(listecourante) + 1 >= max : + commentaire="La liste a déjà atteint le nombre maximum d'éléments,ajout refusé" + return valide,commentaire,commentaire2,listeRetour + if len(listecourante) + 1 > min : + return valide,commentaire,commentaire2,listeRetour + + # On ajoute la valeur testee a la liste courante et a la liste acceptee + listecourante.insert(index,valeur) + index=index+1 + listeRetour.append(valeur) + + return valide,commentaire,commentaire2,listeRetour diff --git a/InterfaceQT/prefsQT.py b/InterfaceQT/prefsQT.py new file mode 100644 index 00000000..ef1aa899 --- /dev/null +++ b/InterfaceQT/prefsQT.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# ====================================================================== +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +lang='fr' + diff --git a/InterfaceQT/qtCommun.py b/InterfaceQT/qtCommun.py new file mode 100644 index 00000000..def3ca0f --- /dev/null +++ b/InterfaceQT/qtCommun.py @@ -0,0 +1,306 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os +import traceback + +from qt import * +from InterfaceQT import prefsQT + +# Import des panels + +# ---------- # +class QTPanel: +# ---------- # + """ + Classe contenant les méthodes Qt communes a tous les panneaux droits + Tous les panneaux Mon...Panel héritent de cette classe + Gére plus précisement : + - l affichage de la doc + - le bouton Suppression (BSupPressed) + - la mutualisation de l affichage des regles + """ + def __init__(self,node, parent = None): + self.editor = parent + self.node = node + + def BSupPressed(self): + self.editor.init_modif() + self.node.delete() + + def BOkPressed(self): + """ Impossible d utiliser les vrais labels avec designer ?? """ + label=self.TWChoix.tabLabel(self.TWChoix.currentPage()) + if label==QString("Nouvelle Commande"): + self.DefCmd() + if label==QString("Nommer Concept"): + self.LENomConceptReturnPressed() + if label==QString("Ajouter Mot-Clef"): + self.DefMC() + if label==QString("Définition Formule"): + self.BOkPressedFormule() + if label==QString("Valeur Parametre"): + self.BOkParamPressed() + if label==QString("Fichier Include"): + self.BOkIncPressed() + + def BParametresPressed(self): + liste=self.node.item.get_liste_param_possible() + from monListeParamPanel import MonListeParamPanel + MonListeParamPanel(liste=liste,parent=self).show() + + def AppelleBuildLBRegles(self): + listeRegles = self.node.item.get_regles() + listeNomsEtapes = self.node.item.get_mc_presents() + self.BuildLBRegles(listeRegles,listeNomsEtapes) + + + def BuildLBRegles(self,listeRegles,listeNomsEtapes): + if len(listeRegles) > 0: + for regle in listeRegles : + texteRegle=regle.gettext() + texteMauvais,test = regle.verif(listeNomsEtapes) + for ligne in texteRegle.split("\n") : + if ligne == "" : + self.LBRegles.insertItem(ligne) + continue + if ligne[0]=="\t" : + ligne=" "+ligne[1:] + if test : + self.LBRegles.insertItem(ligne) + else : + self.LBRegles.insertItem(itemColore(ligne)) + + +# ----------------------- # +class QTPanelTBW1(QTPanel): +# ----------------------- # + """ + Classe contenant les méthodes nécessaires a l onglet "Ajouter Mot-Clef" + hérite de QTPanel # Attention n appelle pas le __init__ + Gére plus précisement : + """ + def __init__(self,node, parent = None): + self.editor = parent + self.node = node + self.BuildLBMCPermis() + self.AppelleBuildLBRegles() + + def BuildLBMCPermis(self): + self.LBMCPermis.clear() + try : + QObject.disconnect(self.LBMCPermis,SIGNAL("doubleClicked(QListBoxItem*)"),self.DefMC) + except : + # normal pour la première fois qu on passe + # peut-etre inutile selon le connect ?? + pass + QObject.connect(self.LBMCPermis,SIGNAL("doubleClicked(QListBoxItem*)"),self.DefMC) + + jdc = self.node.item.get_jdc() + genea =self.node.item.get_genealogie() + liste_mc=self.node.item.get_liste_mc_ordonnee(genea,jdc.cata_ordonne_dico) + for aMc in liste_mc: + self.LBMCPermis.insertItem( aMc) + + + def DefMC(self): + """ On ajoute un mot-clé à la commande : subnode """ + name=str(self.LBMCPermis.selectedItem().text()) + self.editor.init_modif() + self.node.append_child(name) + +# ---------------------------- # +class QTPanelTBW2(QTPanel): +# ---------------------------- # + """ + Classe contenant les méthodes nécessaires a l onglet "Nouvelle Commande" + hérite de QTPanel # Attention n appelle pas le __init__ + Gére plus précisement : + """ + + def __init__(self,node, parent = None, racine = 0): + self.editor = parent + self.node = node + self.BuildLBNouvCommande() + if racine == 1 : self.AppelleBuildLBRegles() + + + def BuildLBNouvCommande(self): + self.LBNouvCommande.clear() + try : + QObject.disconnect(self.LBNouvCommande,SIGNAL("doubleClicked(QListBoxItem*)"),self.DefCmd) + except : + # normal pour la première fois qu on passe + # peut-etre inutile selon le connect ?? + pass + + jdc=self.node.item.object.get_jdc_root() + if self.RBalpha.isOn(): + listeCmd = jdc.get_liste_cmd() + for aCmd in listeCmd: + self.LBNouvCommande.insertItem( aCmd ) + else : + listeGroupes,dictGroupes=jdc.get_groups() + for grp in listeGroupes: + if grp == "CACHE":continue + listeCmd=dictGroupes[grp] + texte="GROUPE : "+grp + self.LBNouvCommande.insertItem( texte ) + self.LBNouvCommande.insertItem( " " ) + for aCmd in listeCmd: + self.LBNouvCommande.insertItem( aCmd) + self.LBNouvCommande.insertItem( " " ) + QObject.connect( self.LBNouvCommande, SIGNAL("doubleClicked(QListBoxItem*)"),self.DefCmd ) + + def DefCmd(self): + if self.LBNouvCommande.selectedItem()== 0 : return + name=str(self.LBNouvCommande.selectedItem().text()) + if name==QString(" "): + return + if name.find("GROUPE :")==0 : + return + self.editor.init_modif() + new_node = self.node.append_brother(name,'after') + + + def LEFiltreTextChanged(self): + MonItem=self.LBNouvCommande.findItem(self.LEFiltre.text().upper(),Qt.Contains) + if MonItem != None : + self.LBNouvCommande.setCurrentItem(MonItem) + self.LBNouvCommande.setSelected(MonItem,1) + + def LEfiltreReturnPressed(self): + self.DefCmd() + + def BNextPressed(self): + self.LBNouvCommande.setCurrentItem(self.LBNouvCommande.currentItem()+1) + self.LEFiltreTextChanged() + + def LBNouvCommandeClicked(self): + name=str(self.LBNouvCommande.currentText()) + + +# ---------------------------- # +class QTPanelTBW3(QTPanel): +# ---------------------------- # + + """ + Classe contenant les méthodes nécessaires a l onglet "Nommer Concept" + si non réentrant + hérite de QTPanel # Attention n appelle pas le __init__ + Gére plus précisement : + """ + + def __init__(self,node, parent = None): + self.editor = parent + self.node = node + type_sd = self.node.item.get_type_sd_prod() + nomConcept = self.node.item.GetText() + self.typeConcept.setText(type_sd) + self.LENomConcept.setText("") + self.LENomConcept.setText(nomConcept) + + + + def LENomConceptReturnPressed(self): + """ + Nomme le concept SD retourne par l'etape + """ + nom = str(self.LENomConcept.text()) + nom = string.strip(nom) + + if nom == '' : return # si pas de nom, on ressort sans rien faire + + self.editor.init_modif() + test,mess = self.node.item.nomme_sd(nom) + self.editor.affiche_infos(mess) + +# ----------------------- # +class ViewText(QDialog): +# ----------------------- # + """ + Classe permettant la visualisation de texte + """ + def __init__(self,parent = None,name = None,modal = 0,fl = 0): + QDialog.__init__(self,parent,name,modal,fl) + + l1 = QVBoxLayout(self,11,6,) + self.view = QTextEdit(self) + self.view.setReadOnly(True) + + l2 = QHBoxLayout(None,0,6) + Horizontal_Spacing2 = QSpacerItem(220,20,QSizePolicy.Expanding,QSizePolicy.Minimum) + bclose= QPushButton(self) + bclose.setText(self.trUtf8( "Fermer")) + bsave= QPushButton(self) + bsave.setText(self.trUtf8( "Sauver")) + l2.addItem(Horizontal_Spacing2) + l2.addWidget(bsave) + l2.addWidget(bclose) + + l1.addWidget(self.view) + l1.addLayout(l2) + + self.resize( QSize(600,507).expandedTo(self.minimumSizeHint()) ) + self.connect( bclose,SIGNAL("clicked()"), self, SLOT("close()") ) + self.connect( bsave,SIGNAL("clicked()"), self.saveFile ) + + def setText(self, txt ): + self.view.setText(txt) + + def saveFile(self): + #recuperation du nom du fichier + fn = QFileDialog.getSaveFileName(None, + self.trUtf8("All Files (*)"), self, None, + self.trUtf8("Save File"), '', 0) + if not fn.isNull(): + if QFileInfo(fn).exists(): + abort = QMessageBox.warning(self, + self.trUtf8("Save File"), + self.trUtf8("The file %1 already exists.") + .arg(fn), + self.trUtf8("&Overwrite"), + self.trUtf8("&Abort"), None, 1) + if abort: + return + fn = unicode(QDir.convertSeparators(fn)) + else: + return + + #ecriture du fichier + try: + f = open(fn, 'wb') + f.write(str(self.view.text())) + f.close() + return 1 + except IOError, why: + QMessageBox.critical(self, self.trUtf8('Save File'), + self.trUtf8('The file %1 could not be saved.
Reason: %2') + .arg(unicode(fn)).arg(str(why))) + return + + +#------------------------------- +class itemColore(QListBoxText): +#------------------------------- + def paint(self,p): + p.setPen(Qt.red) + QListBoxText.paint(self,p); diff --git a/InterfaceQT/qtEficas.py b/InterfaceQT/qtEficas.py new file mode 100644 index 00000000..5cb6ee38 --- /dev/null +++ b/InterfaceQT/qtEficas.py @@ -0,0 +1,208 @@ +# -*- coding: iso-8859-1 -*- + +import os, sys +REPINI=os.path.dirname(os.path.abspath(__file__)) +INSTALLDIR=os.path.join(REPINI,'..') +sys.path.append(INSTALLDIR) +sys.path.append(INSTALLDIR+"/Ui") + +from qt import * +from myMain_ui import Eficas +from viewManager import MyTabview + +from Editeur import configuration +from Aster import prefs +from InterfaceQT import utilIcons +utilIcons.initializeMimeSourceFactory() + +class Appli(Eficas): + """ + Class implementing the main user interface. + """ + def __init__(self): + """ + Constructor + + @param loc locale to be used by the UI (string) + @param splash reference to the splashscreen (UI.SplashScreen.SplashScreen) + """ + Eficas.__init__(self) + + self.top=self + self.CONFIGURATION = configuration.make_config(self,prefs.REPINI) + self.CONFIGStyle = configuration.make_config_style(self,prefs.REPINI) + + self.viewmanager = MyTabview(self, self) #MyTabview, MyWorkspace, Listspace + self.setCentralWidget(self.viewmanager) + + self.recentMenu = QPopupMenu(self.Fichier) + self.Fichier.insertItem(self.trUtf8('Open &Recent Files'), self.recentMenu) + self.connect(self.recentMenu,SIGNAL('aboutToShow()'),self.handleShowRecentMenu) + self.connect(self,PYSIGNAL('preferencesChanged'), + self.viewmanager.handlePreferencesChanged) + + self.connect(self.viewmanager,PYSIGNAL('lastEditorClosed'), + self.handleLastEditorClosed) + + self.connect(self.viewmanager,PYSIGNAL('editorOpened'), + self.handleEditorOpened) + + # Initialise the instance variables. + self.currentProg = None + self.isProg = 0 + self.utEditorOpen = 0 + self.utProjectOpen = 0 + + self.inDragDrop = 0 + self.setAcceptDrops(1) + self.ficPatrons={} + self.initPatrons() + self.ihm="QT" + #self.ouvreFichers() + + + def ouvreFichiers(self) : + # Ouverture des fichiers de commandes donnes sur la ligne de commande + cwd=os.getcwd() + self.dir=cwd + for study in session.d_env.studies: + os.chdir(cwd) + d=session.get_unit(study,self) + self.viewmanager.handleOpen(fn=study["comm"]) + + + def initPatrons(self) : + # Mise à jour du menu des fichiers recemment ouverts + from Editeur import listePatrons + self.listePatrons = listePatrons.listePatrons() + idx = 0 + for nomSsMenu in self.listePatrons.liste.keys(): + ssmenu = QPopupMenu(self.Patrons) + self.Patrons.insertItem(nomSsMenu, ssmenu) + for fichier in self.listePatrons.liste[nomSsMenu]: + id = ssmenu.insertItem(fichier, self.handleOpenPatrons) + self.ficPatrons[idx]=fichier + self.Patrons.setItemParameter(id,idx) + idx=idx+1 + + def handleShowRecentMenu(self): + """ + Private method to set up recent files menu. + """ + idx = 0 + self.recentMenu.clear() + + for rp in self.viewmanager.recent: + id = self.recentMenu.insertItem('&%d. %s' % (idx+1, unicode(rp)), + self.handleOpenRecent) + self.recentMenu.setItemParameter(id,idx) + + idx = idx + 1 + + self.recentMenu.insertSeparator() + self.recentMenu.insertItem(self.trUtf8('&Clear'), self.handleClearRecent) + + def handleOpenPatrons(self, idx): + fichier=REPINI+"/../Editeur/Patrons/"+self.ficPatrons[idx] + self.viewmanager.handleOpen(fn=fichier, patron = 1) + + + def handleOpenRecent(self, idx): + """ + Private method to open a file from the list of rencently opened files. + + @param idx index of the selected entry (int) + """ + self.viewmanager.handleOpen(unicode(self.viewmanager.recent[idx])) + + def handleClearRecent(self): + """ + Private method to clear the recent files menu. + """ + self.viewmanager.recent = QStringList() + + + def handleLastEditorClosed(self): + """ + Public slot to handle the lastEditorClosed signal. + """ + pass # CS_pbruno todo griser les parties k'il faut + + def handleEditorOpened(self, fn): + """ + Public slot to handle the editorOpened signal. + + @param fn filename of the opened editor (string) + """ + pass # CS_pbruno todo degriser les parties k'il faut + + + def fileNew(self): + self.viewmanager.newEditor() + + def fileOpen(self, prog=None): + self.viewmanager.handleOpen(prog) + + def fileNewView(self): + self.viewmanager.handleNewView() + + def fileSave(self): + self.viewmanager.saveCurrentEditor() + + def fileSaveAs(self): + self.viewmanager.saveAsCurrentEditor() + + def fileClose(self): + self.viewmanager.handleClose() + + def fileCloseAll(self): + self.viewmanager.handleCloseAll() + + def fileExit(self): + self.viewmanager.handleCloseAll() + qApp.closeAllWindows() + + def editCopy(self): + self.viewmanager.handleEditCopy() + + def editCut(self): + self.viewmanager.handleEditCut() + + def editPaste(self): + self.viewmanager.handleEditPaste() + + def jdcFichierSource(self): + self.viewmanager.handleViewJdcFichierSource() + + def jdcRapport(self): + self.viewmanager.handleViewJdcRapport() + + +if __name__=='__main__': + + # Modules Eficas + from Aster import prefs + if hasattr(prefs,'encoding'): + # Hack pour changer le codage par defaut des strings + import sys + reload(sys) + sys.setdefaultencoding(prefs.encoding) + del sys.setdefaultencoding + # Fin hack + + from Editeur import import_code + from Editeur import session + + # Analyse des arguments de la ligne de commande + options=session.parse(sys.argv) + code=options.code + + app = QApplication(sys.argv) + mw = Appli() + app.setMainWidget(mw) + app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + mw.ouvreFichiers() + mw.show() + + res = app.exec_loop() + sys.exit(res) diff --git a/InterfaceQT/qtSaisie.py b/InterfaceQT/qtSaisie.py new file mode 100644 index 00000000..aa112a45 --- /dev/null +++ b/InterfaceQT/qtSaisie.py @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +# Modules Python +import string,types,os +from qt import * + +# Import des panels + +class SaisieValeur: + """ + Classe contenant les méthodes communes aux panels + permettant de choisir des valeurs + """ + def __init__(self): + pass + + def InitListBoxASSD(self): + listeNomsSD = self.node.item.get_sd_avant_du_bon_type() + for aSD in listeNomsSD: + self.listBoxASSD.insertItem( aSD) + QObject.connect(self.listBoxASSD, SIGNAL("doubleClicked(QListBoxItem*)" ), self.ClicASSD ) + min,max = self.node.item.GetMinMax() + if (min == 1 and min == max and len(listeNomsSD)==1 ): + if ('R' not in self.node.item.get_type()) : + self.listBoxASSD.setCurrentItem(0) + self.ClicASSD() + + def BuildLBValeurs(self): + self.LBValeurs.clear() + listeValeurs=self.node.item.GetListeValeurs() + for valeur in listeValeurs: + self.LBValeurs.insertItem(str(valeur)) + if listeValeurs != None and listeValeurs != [] : + self.LBValeurs.setCurrentItem(len(listeValeurs) - 1) + + + def RemplitPanel(self,listeDejaLa=[]): + self.listBoxVal.clear() + lChoix=self.node.item.get_liste_possible(listeDejaLa) + for valeur in lChoix : + self.listBoxVal.insertItem( str(valeur) ) + + def ClicASSD(self): + valeurQstring=self.listBoxASSD.selectedItem().text() + commentaire = QString("Valeur selectionnée : ") + commentaire.append(valeurQstring) + self.Commentaire.setText(commentaire) + valeur=valeurQstring.latin1() + validite,commentaire=self.politique.RecordValeur(valeur) + self.Commentaire.setText(QString(commentaire)) + + def ClicValeur(self): + valeurQstring=self.listBoxVal.selectedItem().text() + valeur=valeurQstring.latin1() + validite,commentaire=self.politique.RecordValeur(valeur) + self.Commentaire.setText(QString(commentaire)) + + def BOkPressed(self): + if self.listBoxVal.selectedItem()==None : + commentaire = "Pas de valeur selectionnée" + self.Commentaire.setText(QString(commentaire)) + else : + self.ClicValeur() + + def BOk2Pressed(self): + if str(self.lineEditVal.text())== "" : + commentaire = "Pas de valeur entrée " + self.Commentaire.setText(QString(commentaire)) + else : + self.LEValeurPressed() + + def LEValeurPressed(self,valeur=None): + if valeur == None : + nouvelleValeur=str(self.lineEditVal.text()) + else : + self.lineEditVal.setText(QString(valeur.nom)) + nouvelleValeur=valeur + validite,commentaire=self.politique.RecordValeur(nouvelleValeur) + if commentaire != "" : + self.Commentaire.setText(QString(commentaire)) + + + def TraiteLEValeur(self,valeurTraitee=None) : + # lit la chaine entree dans le line edit + # et la tranforme en chaine de valeurs + # a traiter. renvoie eventuellement des complexes + listeValeurs=[] + if valeurTraitee == None : + valeurBrute=str(self.LEValeur.text()) + else : + valeurBrute=valeurTraitee + if valeurBrute == str("") : return 1, listeValeurs + try : + valeur=eval(valeurBrute,{}) + except : + valeur=valeurBrute + if type(valeur) in (types.ListType,types.TupleType) : + indice = 0 + while (indice < len(valeur)): + v=valeur[indice] + if self.node.item.wait_complex() : + if (v== 'RI' or v == 'MP'): + try : + t=tuple([v,valeur[indice+1],valeur[indice+2]]) + listeValeurs.append(t) + indice=indice+3 + except : + commentaire = "Veuillez entrer le complexe sous forme aster ou sous forme python" + self.editor.affiche_infos(commentaire) + return listeValeurs,0 + + + else : # ce n'est pas un tuple à la mode aster + + listeValeurs.append(v) + indice = indice + 1 + + else: # on n'attend pas un complexe + listeValeurs.append(v) + indice=indice+1 + elif type(valeur) == types.StringType: + listeValeurs=valeur.split(',') + else: + listeValeurs.append(valeur) + + return listeValeurs,1 + + +class SaisieSDCO : + def __init__(self): + pass + + def LESDCOReturnPressed(self): + """ + Lit le nom donné par l'utilisateur au concept de type CO qui doit être + la valeur du MCS courant et stocke cette valeur + """ + self.editor.init_modif() + anc_val = self.node.item.get_valeur() + if anc_val != None: + # il faut egalement propager la destruction de l'ancien concept + self.node.item.delete_valeur_co(valeur=anc_val) + # et on force le recalcul des concepts de sortie de l'etape + self.node.item.object.etape.get_type_produit(force=1) + # et le recalcul du contexte + self.node.item.object.etape.parent.reset_context() + nomConcept = str(self.LESDCO.text()) + if nomConcept == "" : return + + test,commentaire=self.node.item.set_valeur_co(nomConcept) + if test: + commentaire="Valeur du mot-clé enregistree" + self.node.update_node_valid() + else : + cr = self.node.item.get_cr() + commentaire = "Valeur du mot-clé non autorisée :"+cr.get_mess_fatal() + self.node.item.set_valeur_co(anc_val) + self.Commentaire.setText(QString(commentaire)) diff --git a/InterfaceQT/readercata.py b/InterfaceQT/readercata.py new file mode 100644 index 00000000..6ffb6590 --- /dev/null +++ b/InterfaceQT/readercata.py @@ -0,0 +1,393 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce module sert a lire un catalogue et a construire + un objet CataItem pour Eficas. + Il s'appuie sur la classe READERCATA +""" +# Modules Python +import time +import os,sys,py_compile +import traceback +import cPickle +import re + +# Modules Eficas +from Aster import prefs +from Noyau.N_CR import CR +from utils import init_rep_cata_dev + +from Editeur import analyse_catalogue +from Editeur import autre_analyse_cata +from Editeur import uiinfo +from monChoixCata import MonChoixCata + +from qt import * + +class READERCATA: + + def __init__(self,appli,parent): + self.appli=appli + self.parent=parent + self.code=self.appli.code + self.appli.format_fichier='python' + self.version_code=self.appli.version_code + self.version_cata=None + self.fic_cata=None + self.OpenCata() + self.cataitem=None + + def OpenCata(self): + """ + Ouvre le catalogue standard du code courant, cad le catalogue présent + dans le répertoire Cata + """ + message1 = "Compilation des fichiers Eficas \n\n Veuillez patienter ..." + self.configure_barre(4) + + liste_cata_possibles=[] + for catalogue in self.appli.CONFIGURATION.catalogues: + if catalogue[0] == self.code : + liste_cata_possibles.append(catalogue) + + if len(liste_cata_possibles)==0: + QMessageBox.critical( self.parent, "Import du catalogue","Pas de catalogue defini pour le code %s" % self.code) + self.appli.quit() + sys.exit(1) + + if self.version_code is not None: + # La version a ete fixee + for cata in liste_cata_possibles: + if self.version_code == cata[1]: + self.fic_cata = cata[2] + self.appli.format_fichier.set(cata[3]) + elif len(liste_cata_possibles)==1: + self.fic_cata = liste_cata_possibles[0][2] + self.code = self.appli.CONFIGURATION.catalogues[0][0] + self.version_code = liste_cata_possibles[0][1] + self.appli.format_fichier=liste_cata_possibles[0][3] + lab=QString("Eficas V1.12 pour ASTER avec le catalogue ") + lab+=self.version_code + qApp.mainWidget().setCaption(lab) + else: + # plusieurs catalogues sont disponibles : il faut demander a l'utilisateur + # lequel il veut utiliser ... + self.ask_choix_catalogue() + + if self.fic_cata == None : + print "Pas de catalogue pour code %s, version %s" %(self.code,self.version_code) + sys.exit(0) + + # Determinination du repertoire materiau + v_codeSansPoint=self.version_code + v_codeSansPoint=re.sub("\.","",v_codeSansPoint) + chaine="rep_mat_"+v_codeSansPoint + if hasattr(self.appli.CONFIGURATION,chaine): + a=getattr(self.appli.CONFIGURATION,chaine) + else : + try : + a=self.appli.CONFIGURATION.dRepMat[self.version_code] + except : + print self.code + if self.code == "ASTER" : + print "Probleme avec le repertoire materiau" + a='.' + self.appli.CONFIGURATION.rep_mat=a + + + # détermination de fic_cata_c et fic_cata_p + self.fic_cata_c = self.fic_cata + 'c' + self.fic_cata_p = os.path.splitext(self.fic_cata)[0]+'_pickled.py' + + # import du catalogue + self.cata = self.import_cata(self.fic_cata) + self.update_barre() + if not self.cata : + QMessageBox.critical( self.parent, "Import du catalogue","Impossible d'importer le catalogue %s" %self.fic_cata) + self.appli.quit() + sys.exit(1) + # + # analyse du catalogue (ordre des mots-clés) + # + # Retrouve_Ordre_Cata_Standard fait une analyse textuelle du catalogue + # remplacé par Retrouve_Ordre_Cata_Standard_autre qui utilise une numerotation + # des mots clés a la création + self.Retrouve_Ordre_Cata_Standard_autre() + self.update_barre() + + # + # analyse des données liées a  l'IHM : UIinfo + # + uiinfo.traite_UIinfo(self.cata) + self.update_barre() + + # + # traitement des clefs documentaires + # + self.traite_clefs_documentaires() + + # chargement et analyse des catalogues développeur (le cas échéant) + # + if self.appli.CONFIGURATION.isdeveloppeur == 'OUI' : + init_rep_cata_dev(self.fic_cata,self.appli.CONFIGURATION.path_cata_dev) + fic_cata_dev = os.path.join(self.appli.CONFIGURATION.path_cata_dev,'cata_developpeur.py') + if os.path.isfile(fic_cata_dev): + # il y a bien un catalogue développeur : il faut récupérer le module_object associé ... + test = self.compile_cata(fic_cata_dev,fic_cata_dev+'c') + if not test : + showinfo("Compilation catalogue développeur", + "Erreur dans la compilation du catalogue développeur") + self.cata = (self.cata,) + else: + self.cata_dev =self.import_cata(fic_cata_dev) + #self.Retrouve_Ordre_Cata_Developpeur() + self.Retrouve_Ordre_Cata_Developpeur_autre() + self.cata = (self.cata,self.cata_dev) + else: + self.cata = (self.cata,) + else: + self.cata = (self.cata,) + titreSuite=" avec le catalogue " + os.path.basename(self.fic_cata) + titre=self.appli.titre+titreSuite + if self.appli.top: + self.appli.top.title(titre) + self.appli.titre=titre + + def import_cata(self,cata): + """ + Réalise l'import du catalogue dont le chemin d'acca¨s est donné par cata + """ + nom_cata = os.path.splitext(os.path.basename(cata))[0] + rep_cata = os.path.dirname(cata) + sys.path[:0] = [rep_cata] + try : + o=__import__(nom_cata) + return o + except Exception,e: + traceback.print_exc() + return 0 + + def Retrouve_Ordre_Cata_Standard_autre(self): + """ + Construit une structure de données dans le catalogue qui permet + a  EFICAS de retrouver l'ordre des mots-clés dans le texte du catalogue. + Pour chaque entité du catlogue on crée une liste de nom ordre_mc qui + contient le nom des mots clés dans le bon ordre + """ + self.cata_ordonne_dico,self.appli.liste_simp_reel=autre_analyse_cata.analyse_catalogue(self.cata) + + def Retrouve_Ordre_Cata_Standard(self): + """ + Retrouve l'ordre des mots-clés dans le catalogue, cad : + - si ce dernier a été modifié, relance l'analyse du catalogue pour déterminer + l'ordre des mots-clés dans le catalogue + - s'il n'a pas été modifié, relie le fichier pickle + """ + time1 = os.path.getmtime(self.fic_cata) + try : + time2 = os.path.getmtime(self.fic_cata_p) + except: + time2 = 0 + if time2 > time1 : + # l'objet catalogue n'a pas été modifié depuis le dernier "pickle" + self.Get_Ordre_Cata() + else : + # le catalogue a été modifié depuis le dernier "pickle" : + # il faut retrouver l'ordre du catalogue et refaire pickle + self.Get_Ordre_Cata(mode='cata') + self.appli.affiche_infos("Catalogue standard chargé") + + def Retrouve_Ordre_Cata_Developpeur(self): + """ + Retrouve l'ordre des mots-clés dans le catalogue, cad : + - si ce dernier a été modifié, relance l'analyse du catalogue pour déterminer + l'ordre des mots-clés dans le catalogue + - s'il n'a pas été modifié, relie le fichier pickle + """ + if self.code != 'ASTER' : return + fic_cata = os.path.join(self.appli.CONFIGURATION.path_cata_dev,'cata_developpeur.py') + message="Chargement catalogue développeur présent dans :\n %s..." % self.appli.CONFIGURATION.path_cata_dev + cata_dev_ordonne = analyse_cata.analyse_catalogue(self,self.fic_cata) + self.cata_dev_ordonne_cr = cata_dev_ordonne.cr + cata_dev_ordonne_dico = cata_dev_ordonne.entites + self.cata_ordonne_dico.update(cata_dev_ordonne_dico) + self.appli.affiche_infos(" catalogue(s) développeur(s) chargé(s)" ) + + def Retrouve_Ordre_Cata_Developpeur_autre(self): + """ + Retrouve l'ordre des mots-clés dans le catalogue, cad : + - si ce dernier a été modifié, relance l'analyse du catalogue pour déterminer + l'ordre des mots-clés dans le catalogue + - s'il n'a pas été modifié, relie le fichier pickle + """ + if self.code != 'ASTER' : return + message="Chargement catalogue développeur présent dans :\n %s..." % self.appli.CONFIGURATION.path_cata_dev + cata_dev_ordonne_dico,self.appli.liste_simp_reel=autre_analyse_cata.analyse_catalogue(self.cata) + self.cata_ordonne_dico.update(cata_dev_ordonne_dico) + self.appli.affiche_infos(" catalogue(s) développeur(s) chargé(s)" ) + + def Get_Ordre_Cata(self,mode='pickle'): + """ + Retrouve l'ordre du catalogue : + - mode='pickle ': tente de relire le fichier pickle et sinon lance l'analyse du catalogue + - mode='cata' : force l'analyse du catalogue directement sans relire le pickle + """ + if mode == 'pickle' : + try: + f = open(self.fic_cata_p) + u = cPickle.Unpickler(f) + self.cata_ordonne_dico = u.load() + f.close() + except : + # on peut ne pas arriver a  relire le fichier pickle s'il a été altéré + # ou (le plus probable) s'il a été créé sous un autre OS + self.Get_Ordre_Cata(mode='cata') + elif mode == 'cata': + cata_ordonne = analyse_catalogue.analyse_catalogue(self,self.fic_cata) + self.cata_ordonne_cr = cata_ordonne.cr + self.cata_ordonne_dico = cata_ordonne.entites + f = open(self.fic_cata_p,'w+') + p = cPickle.Pickler(f) + p.dump(self.cata_ordonne_dico) + f.close() + else : + raise Exception("Appel a  un mode inconnu de Get_Ordre_Cata : %s" % mode) + return + + def ask_choix_catalogue(self): + """ + Ouvre une fenetre de sélection du catalogue dans le cas oa¹ plusieurs + ont été définis dans Accas/editeur.ini + """ + # construction du dictionnaire et de la liste des catalogues + self.dico_catalogues = {} + defaut = None + for catalogue in self.appli.CONFIGURATION.catalogues: + if catalogue[0] == self.code : + self.dico_catalogues[catalogue[1]] = catalogue + if len(catalogue) == 5 : + if catalogue[4]=='defaut' : defaut = catalogue[1] + liste_choix = self.dico_catalogues.keys() + liste_choix.sort() + + lab=QString("Eficas V1.12 pour ASTER avec le catalogue ") + + # teste si plusieurs catalogues ou non + if len(liste_choix) == 0: + QMessageBox.critical( self.parent, "", "Aucun catalogue déclaré pour %s" %self.code) + self.appli.quit() + sys.exit(1) + + # création d'une boite de dialogue modale + widgetChoix=MonChoixCata(liste_choix,self, self.parent, "", True ) + ret=widgetChoix.exec_loop() + + lab=QString("Eficas V1.12 pour ASTER avec le catalogue ") + if ret == QDialog.Accepted: + self.version_cata=str(self.version_cata) + self.fic_cata = self.dico_catalogues[self.version_cata][2] + self.version_code = self.version_cata + #self.appli.format_fichier.set( self.dico_catalogues[self.version_cata][3] ) + self.appli.format_fichier = self.dico_catalogues[self.version_cata][3] + lab+=self.version_cata + qApp.mainWidget().setCaption(lab) + else : + sys.exit(0) + + + def compile_cata(self,cata,catac): + """ + Teste si le catalogue a bien besoin d'etre recompilé et si oui, le compile et + affiche un message dans le splash . Retourne 1 si la compilation s'est bien déroulée, + 0 sinon. + """ + time1 = os.path.getmtime(cata) + try: + time2 = os.path.getmtime(catac) + except: + time2 = 0 + if time1 > time2: + try: + # le catalogue doit etre recompilé avant d'etre importé + if self.appli.test == 0 : + splash._splash.configure(text="Compilation du catalogue\nCela peut prendre plusieurs secondes ...") + py_compile.compile(cata) + except: + return 0 + return 1 + + +#-------------------------------------------------------------------------------- +# Méthodes concernant la barre de progression lors de l'analyse du catalogue +#-------------------------------------------------------------------------------- + + def configure_barre(self,nbcommandes): + """ Configure la barre de progression en lui passant comme parama¨tre le + nombre de commandes du catalogue qui lui sert a  déterminer la longueur de son incrément """ + try: + if self.appli.test == 0 : + splash._splash.configure(barre='oui',ratio = nbcommandes) + except: + pass + + def update_barre(self): + """ Update la position de la barre de progression : la fait progresser de son incrément """ + try: + if self.appli.test == 0 : + splash._splash.update_barre() + except: + pass + + def visuCRCATA(self): + """ + Méthode permettant l'affichage du rapport de validation + """ + cr = CR( debut = "Début rapport de validation du catalogue", + fin = "Fin rapport de validation du catalogue") + titre="rapport de validation du catalogue" + if hasattr(self,'cata_ordonne_cr') : + cr.add(self.cata_ordonne_cr) + if hasattr(self,'cata_dev_ordonne_cr') : + cr.add(self.cata_dev_ordonne_cr) + for cata in self.cata: + if hasattr(cata,'JdC'): + cr.add(cata.JdC.report()) + texte_cr = str(cr) + self.visu_texte_cr = Fenetre(self.appli,titre=titre,texte=texte_cr) + + + def traite_clefs_documentaires(self): + try: + self.fic_cata_clef=os.path.splitext(self.fic_cata_c)[0]+'_clefs_docu' + f=open(self.fic_cata_clef) + except: + #print "Pas de fichier associé contenant des clefs documentaires" + return + + dict_clef_docu={} + for l in f.readlines(): + clef=l.split(':')[0] + docu=l.split(':')[1] + docu=docu[0:-1] + dict_clef_docu[clef]=docu + for oper in self.cata.JdC.commandes: + if dict_clef_docu.has_key(oper.nom): + oper.docu=dict_clef_docu[oper.nom] diff --git a/InterfaceQT/typeNode.py b/InterfaceQT/typeNode.py new file mode 100644 index 00000000..9f111468 --- /dev/null +++ b/InterfaceQT/typeNode.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +from qt import * + +#---------------------------# +class PopUpMenuNodePartiel : +#---------------------------# + def createPopUpMenu(self): + #menu + self.menu = QPopupMenu(self.tree) + + #ss-menu Comment: + self.commentMenu = QPopupMenu( self.menu ) + self.menu.insertItem( qApp.translate('Browser','Comment'), self.commentMenu ) + self.commentMenu.insertItem( 'after', self.addCommentAfter ) + self.commentMenu.insertItem( 'before', self.addCommentBefore ) + + #ss-menu Parameters: + self.parametersMenu = QPopupMenu( self.menu ) + self.parametersMenu.insertItem( 'after', self.addParametersAfter ) + self.parametersMenu.insertItem( 'before', self.addParametersBefore ) + + #items du menu + self.menu.insertItem( qApp.translate('Browser','Delete'), self.delete ) + self.menu.insertItem( qApp.translate('Browser','Parameters'), self.parametersMenu ) + + + def addCommentAfter(self): + """ + """ + self.addComment() + + def addCommentBefore(self): + """ + """ + self.addComment(False) + + def addParametersAfter(self): + """ + """ + self.addParameters() + + def addParametersBefore(self): + """ + """ + self.addParameters(False) + + +#-----------------------------------------# +class PopUpMenuNode(PopUpMenuNodePartiel) : +#-----------------------------------------# + def createPopUpMenu(self): + PopUpMenuNodePartiel.createPopUpMenu(self) + + self.commentMenu.insertItem( 'it', self.commentIt ) diff --git a/InterfaceQT/utilIcons.py b/InterfaceQT/utilIcons.py new file mode 100644 index 00000000..d52fbc50 --- /dev/null +++ b/InterfaceQT/utilIcons.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +from qt import QPixmap +import os + +class PixmapCache: + """ + Class implementing a pixmap cache for icons. + """ + def __init__(self): + """ + Constructor + """ + self.pixmapCache = {} + + def getPixmap(self, key): + """ + Public method to retrieve a pixmap. + + @param key name of the wanted pixmap (string) + @return the requested pixmap (QPixmap) + """ + try: + return self.pixmapCache[key] + except KeyError: + self.pixmapCache[key] = QPixmap.fromMimeSource(key) + return self.pixmapCache[key] + +pixCache = PixmapCache() + +def getPixmap(key, cache = pixCache): + """ + Module function to retrieve a pixmap. + + @param key name of the wanted pixmap (string) + @return the requested pixmap (QPixmap) + """ + return cache.getPixmap(key) + + + +from qt import QMimeSourceFactory + +def initializeMimeSourceFactory(): + """ + Function to initialize the default mime source factory. + + """ + defaultFactory = QMimeSourceFactory.defaultFactory() + repini=os.path.dirname(os.path.abspath(__file__)) + defaultFactory.addFilePath(repini+"/../Editeur/icons") #CS_pbruno todo (config) + diff --git a/InterfaceQT/viewManager.py b/InterfaceQT/viewManager.py new file mode 100644 index 00000000..afa9cc82 --- /dev/null +++ b/InterfaceQT/viewManager.py @@ -0,0 +1,2527 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import os +from InterfaceQT import utilIcons +from qt import * + + +##fonctions utilitaires +def normabspath(path): + """ + Function returning a normalized, absolute path. + + @param path file path (string) + @return absolute, normalized path (string) + """ + return os.path.abspath(path) + + +def samepath(f1, f2): + """ + Function to compare two paths. + + @param f1 first path for the compare (string) + @param f2 second path for the compare (string) + @return flag indicating whether the two paths represent the + same path on disk. + """ + if f1 is None or f2 is None: + return 0 + + if normcasepath(f1) == normcasepath(f2): + return 1 + + return 0 + +def normcasepath(path): + """ + Function returning a path, that is normalized with respect to its case and references. + + @param path file path (string) + @return case normalized path (string) + """ + return os.path.normcase(os.path.normpath(path)) + + + + +class ViewManager: + """ + Base class inherited by all specific viewmanager classes. + + It defines the interface to be implemented by specific + viewmanager classes and all common methods. + + @signal lastEditorClosed emitted after the last editor window was closed + @signal editorOpened(string) emitted after an editor window was opened + @signal editorSaved(string) emitted after an editor window was saved + @signal checkActions(editor) emitted when some actions should be checked + for their status + @signal cursorChanged(editor) emitted after the cursor position of the active + window has changed + @signal breakpointToggled(editor) emitted when a breakpoint is toggled. + @signal bookmarkToggled(editor) emitted when a bookmark is toggled. + """ + def __init__(self, ui ): + """ + Constructor + + @param ui reference to the main user interface + @param dbs reference to the debug server object + """ + # initialize the instance variables + self.ui = ui + self.editors = [] + self.currentEditor = None + self.untitledCount = 0 + self.srHistory = {"search" : QStringList(), "replace" : QStringList()} + self.editorsCheckFocusIn = 1 + self.recent = QStringList() + + + # initialize the central store for api information (used by + # autocompletion and calltips) + self.apis = {} + self.initFileFilters() + + + def initFileFilters(self): + """ + Private method to initialize the lists of supported filename filters. + """ + self.fileFiltersString = self.trUtf8(\ + 'Python Files (*.py);;' + 'Aster Files (*.com*);;' + 'Pyrex Files (*.pyx);;' + 'Quixote Template Files (*.ptl);;' + 'IDL Files (*.idl);;' + 'C Files (*.h *.c);;' + 'C++ Files (*.h *.hpp *.hh *.cxx *.cpp *.cc);;' + 'C# Files (*.cs);;' + 'HTML Files (*.html *.htm *.asp *.shtml *.css);;' + 'PHP Files (*.php *.php3 *.php4 *.php5 *.phtml);;' + 'XML Files (*.xml *.xsl *.xslt *.dtd);;' + 'Java Files (*.java);;' + 'JavaScript Files (*.js);;' + 'SQL Files (*.sql);;' + 'Docbook Files (*.docbook);;' + 'Perl Files (*.pl *.pm *.ph);;' + 'Shell Files (*.sh);;' + 'Aster Files (*.com*);;' + 'All Files (*)') + + fileFilters = QStringList.split(';;', self.fileFiltersString) + + self.ext2Filter = {} + for fileFilter in fileFilters: + extensions = QStringList.split('*', fileFilter) + for extension in extensions[1:]: + extension = unicode(extension).strip().replace(')', '') + if extension: + self.ext2Filter[extension] = unicode(fileFilter) + + + + ##################################################################### + ## methods above need to be implemented by a subclass + ##################################################################### + + def canSplit(self): + """ + public method to signal if splitting of the view is available. + + @return flag indicating splitting of the view is available. + """ + return 0 + + def addSplit(self): + """ + Public method used to split the current view. + """ + pass + + def removeSplit(self): + """ + Public method used to remove the current split view. + + @return Flag indicating successful deletion + """ + return 0 + + def setSplitOrientation(self, orientation): + """ + Public method used to set the orientation of the split view. + + @param orientation orientation of the split + (QSplitter.Horizontal or QSplitter.Vertical) + """ + pass + + def eventFilter(self, object, event): + """ + Private method called to filter an event. + + @param object object, that generated the event (QObject) + @param event the event, that was generated by object (QEvent) + @return flag indicating if event was filtered out + """ + return 0 + + def focusInEvent(self, event): + """ + Public method called when the viewmanager receives focus. + + @param event the event object (QFocusEvent) + """ + self.editorActGrp.setEnabled(1) + + def focusOutEvent(self, event): + """ + Public method called when the viewmanager loses focus. + + @param event the event object (QFocusEvent) + """ + self.editorActGrp.setEnabled(0) + + + def initEditMenu(self): + """ + Public method to create the Edit menu + + @return the generated menu + """ + menu = QPopupMenu(self.ui) + menu.insertTearOffHandle() + self.undoAct.addTo(menu) + self.redoAct.addTo(menu) + self.revertAct.addTo(menu) + menu.insertSeparator() + self.cutAct.addTo(menu) + self.copyAct.addTo(menu) + self.pasteAct.addTo(menu) + self.deleteAct.addTo(menu) + menu.insertSeparator() + self.indentAct.addTo(menu) + self.unindentAct.addTo(menu) + menu.insertSeparator() + self.commentAct.addTo(menu) + self.uncommentAct.addTo(menu) + self.streamCommentAct.addTo(menu) + self.boxCommentAct.addTo(menu) + menu.insertSeparator() + self.autoCompleteAct.addTo(menu) + self.autoCompleteFromDocAct.addTo(menu) + self.autoCompleteFromAPIsAct.addTo(menu) + menu.insertSeparator() + self.searchAct.addTo(menu) + self.searchAgainAct.addTo(menu) + self.replaceAct.addTo(menu) + menu.insertSeparator() + self.searchFilesAct.addTo(menu) + menu.insertSeparator() + self.gotoAct.addTo(menu) + self.gotoBraceAct.addTo(menu) + menu.insertSeparator() + self.selectBraceAct.addTo(menu) + self.selectAllAct.addTo(menu) + self.deselectAllAct.addTo(menu) + menu.insertSeparator() + self.shortenEmptyAct.addTo(menu) + self.convertEOLAct.addTo(menu) + + return menu + + def initEditToolbar(self): + """ + Public method to create the Edit toolbar + + @return the generated toolbar + """ + tb = QToolBar(self.ui) + self.undoAct.addTo(tb) + self.redoAct.addTo(tb) + tb.addSeparator() + self.cutAct.addTo(tb) + self.copyAct.addTo(tb) + self.pasteAct.addTo(tb) + self.deleteAct.addTo(tb) + tb.addSeparator() + self.indentAct.addTo(tb) + self.unindentAct.addTo(tb) + tb.addSeparator() + self.commentAct.addTo(tb) + self.uncommentAct.addTo(tb) + + return tb + + ################################################################## + ## Initialize the search related actions, search menu and toolbar + ################################################################## + + def initSearchActions(self): + """ + Private method defining the user interface actions for the search commands. + """ + self.searchActGrp = QActionGroup(self) + + self.searchAct = QAction(self.trUtf8('Search'), + QIconSet(utilIcons.getPixmap("find.png")), + self.trUtf8('&Search...'), + QKeySequence(self.trUtf8("CTRL+F","Search|Search")), + self.searchActGrp) + self.searchAct.setStatusTip(self.trUtf8('Search for a text')) + self.searchAct.setWhatsThis(self.trUtf8( + """Search""" + """

Search for some text in the current editor. A""" + """ dialog is shown to enter the searchtext and options""" + """ for the search.

""" + )) + self.connect(self.searchAct,SIGNAL('activated()'),self.handleSearch) + self.searchActions.append(self.searchAct) + + self.searchAgainAct = QAction(self.trUtf8('Search again'), + QIconSet(utilIcons.getPixmap("findNext.png")), + self.trUtf8('Search &again'), + Qt.Key_F3,self.searchActGrp) + self.searchAgainAct.setStatusTip(self.trUtf8('Search again for text')) + self.searchAgainAct.setWhatsThis(self.trUtf8( + """Search again""" + """

Search again for some text in the current editor.""" + """ The previously entered searchtext and options are reused.

""" + )) + self.connect(self.searchAgainAct,SIGNAL('activated()'),self.searchDlg.handleFindNext) + self.searchActions.append(self.searchAgainAct) + + self.replaceAct = QAction(self.trUtf8('Replace'), + self.trUtf8('&Replace...'), + QKeySequence(self.trUtf8("CTRL+R","Search|Replace")), + self.searchActGrp) + self.replaceAct.setStatusTip(self.trUtf8('Replace some text')) + self.replaceAct.setWhatsThis(self.trUtf8( + """Replace""" + """

Search for some text in the current editor and replace it. A""" + """ dialog is shown to enter the searchtext, the replacement text""" + """ and options for the search and replace.

""" + )) + self.connect(self.replaceAct,SIGNAL('activated()'),self.handleReplace) + self.searchActions.append(self.replaceAct) + + self.gotoAct = QAction(self.trUtf8('Goto Line'), + QIconSet(utilIcons.getPixmap("goto.png")), + self.trUtf8('&Goto Line...'), + QKeySequence(self.trUtf8("CTRL+G","Search|Goto Line")), + self.searchActGrp) + self.gotoAct.setStatusTip(self.trUtf8('Goto Line')) + self.gotoAct.setWhatsThis(self.trUtf8( + """Goto Line""" + """

Go to a specific line of text in the current editor.""" + """ A dialog is shown to enter the linenumber.

""" + )) + self.connect(self.gotoAct,SIGNAL('activated()'),self.handleGoto) + self.searchActions.append(self.gotoAct) + + self.gotoBraceAct = QAction(self.trUtf8('Goto Brace'), + QIconSet(utilIcons.getPixmap("gotoBrace.png")), + self.trUtf8('Goto &Brace'), + QKeySequence(self.trUtf8("CTRL+L","Search|Goto Brace")), + self.searchActGrp) + self.gotoBraceAct.setStatusTip(self.trUtf8('Goto Brace')) + self.gotoBraceAct.setWhatsThis(self.trUtf8( + """Goto Brace""" + """

Go to the matching brace in the current editor.

""" + )) + self.connect(self.gotoBraceAct,SIGNAL('activated()'),self.handleGotoBrace) + self.searchActions.append(self.gotoBraceAct) + + self.searchActGrp.setEnabled(0) + + self.searchFilesAct = QAction(self.trUtf8('Search in Files'), + QIconSet(utilIcons.getPixmap("projectFind.png")), + self.trUtf8('Search in &Files...'), + QKeySequence(self.trUtf8("SHIFT+CTRL+F","Search|Search Files")), + self) + self.searchFilesAct.setStatusTip(self.trUtf8('Search for a text in files')) + self.searchFilesAct.setWhatsThis(self.trUtf8( + """Search in Files""" + """

Search for some text in the files of a directory tree""" + """ or the project. A dialog is shown to enter the searchtext""" + """ and options for the search and to display the result.

""" + )) + self.connect(self.searchFilesAct,SIGNAL('activated()'),self.handleSearchFiles) + self.searchActions.append(self.searchFilesAct) + + + ################################################################## + ## Initialize the view related actions, view menu and toolbar + ################################################################## + + def initViewActions(self): + """ + Protected method defining the user interface actions for the view commands. + """ + self.viewActGrp = QActionGroup(self) + self.viewFoldActGrp = QActionGroup(self) + + self.zoomInAct = QAction(self.trUtf8('Zoom in'), + QIconSet(utilIcons.getPixmap("zoomIn.png")), + self.trUtf8('Zoom &in'), + Qt.CTRL+Qt.Key_Plus, self.viewActGrp) + self.zoomInAct.setStatusTip(self.trUtf8('Zoom in on the text')) + self.zoomInAct.setWhatsThis(self.trUtf8( + """Zoom in""" + """

Zoom in on the text. This makes the text bigger.

""" + )) + self.connect(self.zoomInAct,SIGNAL('activated()'),self.handleZoomIn) + self.viewActions.append(self.zoomInAct) + + self.zoomOutAct = QAction(self.trUtf8('Zoom out'), + QIconSet(utilIcons.getPixmap("zoomOut.png")), + self.trUtf8('Zoom &out'), + Qt.CTRL+Qt.Key_Minus, self.viewActGrp) + self.zoomOutAct.setStatusTip(self.trUtf8('Zoom out on the text')) + self.zoomOutAct.setWhatsThis(self.trUtf8( + """Zoom out""" + """

Zoom out on the text. This makes the text smaller.

""" + )) + self.connect(self.zoomOutAct,SIGNAL('activated()'),self.handleZoomOut) + self.viewActions.append(self.zoomOutAct) + + self.zoomToAct = QAction(self.trUtf8('Zoom'), + QIconSet(utilIcons.getPixmap("zoomTo.png")), + self.trUtf8('&Zoom'), + 0, self.viewActGrp) + self.zoomToAct.setStatusTip(self.trUtf8('Zoom the text')) + self.zoomToAct.setWhatsThis(self.trUtf8( + """Zoom""" + """

Zoom the text. This opens a dialog where the""" + """ desired size can be entered.

""" + )) + self.connect(self.zoomToAct,SIGNAL('activated()'),self.handleZoom) + self.viewActions.append(self.zoomToAct) + + self.toggleAllAct = QAction(self.trUtf8('Toggle all folds'), + self.trUtf8('Toggle &all folds'), + 0, self.viewFoldActGrp) + self.toggleAllAct.setStatusTip(self.trUtf8('Toggle all folds')) + self.toggleAllAct.setWhatsThis(self.trUtf8( + """Toggle all folds""" + """

Toggle all folds of the current editor.

""" + )) + self.connect(self.toggleAllAct,SIGNAL('activated()'),self.handleToggleAll) + self.viewActions.append(self.toggleAllAct) + + self.toggleCurrentAct = QAction(self.trUtf8('Toggle current fold'), + self.trUtf8('Toggle ¤t fold'), + 0, self.viewFoldActGrp) + self.toggleCurrentAct.setStatusTip(self.trUtf8('Toggle current fold')) + self.toggleCurrentAct.setWhatsThis(self.trUtf8( + """Toggle current fold""" + """

Toggle the folds of the current line of the current editor.

""" + )) + self.connect(self.toggleCurrentAct,SIGNAL('activated()'),self.handleToggleCurrent) + self.viewActions.append(self.toggleCurrentAct) + + self.unhighlightAct = QAction(self.trUtf8('Remove all highlights'), + QIconSet(utilIcons.getPixmap("unhighlight.png")), + self.trUtf8('Remove all highlights'), + 0, self) + self.unhighlightAct.setStatusTip(self.trUtf8('Remove all highlights')) + self.unhighlightAct.setWhatsThis(self.trUtf8( + """Remove all highlights""" + """

Remove the highlights of all editors.

""" + )) + self.connect(self.unhighlightAct,SIGNAL('activated()'),self.unhighlight) + self.viewActions.append(self.unhighlightAct) + + self.splitViewAct = QAction(self.trUtf8('Split view'), + QIconSet(utilIcons.getPixmap("splitVertical.png")), + self.trUtf8('&Split view'), + 0, self) + self.splitViewAct.setStatusTip(self.trUtf8('Add a split to the view')) + self.splitViewAct.setWhatsThis(self.trUtf8( + """Split view""" + """

Add a split to the view.

""" + )) + self.connect(self.splitViewAct,SIGNAL('activated()'),self.handleSplitView) + self.viewActions.append(self.splitViewAct) + + self.splitOrientationAct = QAction(self.trUtf8('Arrange horizontally'), + self.trUtf8('Arrange &horizontally'), + 0, self, None, 1) + self.splitOrientationAct.setStatusTip(self.trUtf8('Arrange the splitted views horizontally')) + self.splitOrientationAct.setWhatsThis(self.trUtf8( + """Arrange horizontally""" + """

Arrange the splitted views horizontally.

""" + )) + self.splitOrientationAct.setOn(0) + self.connect(self.splitOrientationAct,SIGNAL('activated()'),self.handleSplitOrientation) + self.viewActions.append(self.splitOrientationAct) + + self.splitRemoveAct = QAction(self.trUtf8('Remove split'), + QIconSet(utilIcons.getPixmap("remsplitVertical.png")), + self.trUtf8('&Remove split'), + 0, self) + self.splitRemoveAct.setStatusTip(self.trUtf8('Remove the current split')) + self.splitRemoveAct.setWhatsThis(self.trUtf8( + """Remove split""" + """

Remove the current split.

""" + )) + self.connect(self.splitRemoveAct,SIGNAL('activated()'),self.removeSplit) + self.viewActions.append(self.splitRemoveAct) + + self.viewActGrp.setEnabled(0) + self.viewFoldActGrp.setEnabled(0) + self.unhighlightAct.setEnabled(0) + self.splitViewAct.setEnabled(0) + self.splitOrientationAct.setEnabled(0) + self.splitRemoveAct.setEnabled(0) + + def initViewMenu(self): + """ + Public method to create the View menu + + @return the generated menu + """ + menu = QPopupMenu(self.ui) + menu.insertTearOffHandle() + self.viewActGrp.addTo(menu) + menu.insertSeparator() + self.viewFoldActGrp.addTo(menu) + menu.insertSeparator() + self.unhighlightAct.addTo(menu) + if self.canSplit(): + menu.insertSeparator() + self.splitViewAct.addTo(menu) + self.splitOrientationAct.addTo(menu) + self.splitRemoveAct.addTo(menu) + return menu + + def initViewToolbar(self): + """ + Public method to create the View toolbar + + @return the generated toolbar + """ + tb = QToolBar(self.ui) + self.viewActGrp.addTo(tb) + tb.addSeparator() + self.unhighlightAct.addTo(tb) + if self.canSplit(): + tb.addSeparator() + self.splitViewAct.addTo(tb) + self.splitRemoveAct.addTo(tb) + + return tb + + ################################################################## + ## Initialize the macro related actions and macro menu + ################################################################## + + def initMacroActions(self): + """ + Private method defining the user interface actions for the macro commands. + """ + self.macroActGrp = QActionGroup(self) + + self.macroStartRecAct = QAction(self.trUtf8('Start Macro Recording'), + self.trUtf8('S&tart Macro Recording'), + 0, self.macroActGrp) + self.macroStartRecAct.setStatusTip(self.trUtf8('Start Macro Recording')) + self.macroStartRecAct.setWhatsThis(self.trUtf8( + """Start Macro Recording""" + """

Start recording editor commands into a new macro.

""" + )) + self.connect(self.macroStartRecAct,SIGNAL('activated()'),self.handleMacroStartRecording) + self.macroActions.append(self.macroStartRecAct) + + self.macroStopRecAct = QAction(self.trUtf8('Stop Macro Recording'), + self.trUtf8('Sto&p Macro Recording'), + 0, self.macroActGrp) + self.macroStopRecAct.setStatusTip(self.trUtf8('Stop Macro Recording')) + self.macroStopRecAct.setWhatsThis(self.trUtf8( + """Stop Macro Recording""" + """

Stop recording editor commands into a new macro.

""" + )) + self.connect(self.macroStopRecAct,SIGNAL('activated()'),self.handleMacroStopRecording) + self.macroActions.append(self.macroStopRecAct) + + self.macroRunAct = QAction(self.trUtf8('Run Macro'), + self.trUtf8('&Run Macro'), + 0, self.macroActGrp) + self.macroRunAct.setStatusTip(self.trUtf8('Run Macro')) + self.macroRunAct.setWhatsThis(self.trUtf8( + """Run Macro""" + """

Run a previously recorded editor macro.

""" + )) + self.connect(self.macroRunAct,SIGNAL('activated()'),self.handleMacroRun) + self.macroActions.append(self.macroRunAct) + + self.macroDeleteAct = QAction(self.trUtf8('Delete Macro'), + self.trUtf8('&Delete Macro'), + 0, self.macroActGrp) + self.macroDeleteAct.setStatusTip(self.trUtf8('Delete Macro')) + self.macroDeleteAct.setWhatsThis(self.trUtf8( + """Delete Macro""" + """

Delete a previously recorded editor macro.

""" + )) + self.connect(self.macroDeleteAct,SIGNAL('activated()'),self.handleMacroDelete) + self.macroActions.append(self.macroDeleteAct) + + self.macroLoadAct = QAction(self.trUtf8('Load Macro'), + self.trUtf8('&Load Macro'), + 0, self.macroActGrp) + self.macroLoadAct.setStatusTip(self.trUtf8('Load Macro')) + self.macroLoadAct.setWhatsThis(self.trUtf8( + """Load Macro""" + """

Load an editor macro from a file.

""" + )) + self.connect(self.macroLoadAct,SIGNAL('activated()'),self.handleMacroLoad) + self.macroActions.append(self.macroLoadAct) + + self.macroSaveAct = QAction(self.trUtf8('Save Macro'), + self.trUtf8('&Save Macro'), + 0, self.macroActGrp) + self.macroSaveAct.setStatusTip(self.trUtf8('Save Macro')) + self.macroSaveAct.setWhatsThis(self.trUtf8( + """Save Macro""" + """

Save a previously recorded editor macro to a file.

""" + )) + self.connect(self.macroSaveAct,SIGNAL('activated()'),self.handleMacroSave) + self.macroActions.append(self.macroSaveAct) + + self.macroActGrp.setEnabled(0) + + def initMacroMenu(self): + """ + Public method to create the Macro menu + + @return the generated menu + """ + menu = QPopupMenu(self.ui) + menu.insertTearOffHandle() + self.macroActGrp.addTo(menu) + return menu + + + def checkDirty(self, editor): + """ + Private method to check dirty status and open a message window. + + @param editor editor window to check + @return flag indicating successful reset of the dirty flag (boolean) + """ + if editor.modified: + fn = editor.getFileName() + if fn is None: + fn = self.trUtf8('Noname') + res = QMessageBox.warning(self.parent(), + self.trUtf8("File Modified"), + self.trUtf8("The file %1 has unsaved changes.") + .arg(fn), + self.trUtf8("&Save"), self.trUtf8("&Discard changes"), + self.trUtf8("&Abort"), 0, 2) + if res == 0: + (ok, newName) = editor.saveFile() + if ok: + self.setEditorName(editor, newName) + return ok + elif res == 2: + return 0 + return 1 + + def checkAllDirty(self): + """ + Public method to check the dirty status of all editors. + + @return flag indicating successful reset of all dirty flags (boolean) + """ + for editor in self.editors: + if not self.checkDirty(editor): + return 0 + + return 1 + + def closeEditor(self, editor): + """ + Private method to close an editor window. + + @param editor editor window to be closed + @return flag indicating success (boolean) + """ + # save file if necessary + if not self.checkDirty(editor): + return 0 + + # remove the window + self.removeView(editor) + self.editors.remove(editor) + if not len(self.editors): + self.handleLastEditorClosed() + self.emit(PYSIGNAL('lastEditorClosed'), ()) #CS_pbruno connecter signal avec l'appli + return 1 + + def handleClose(self): + """ + Public method to close the current window. + + @return flag indicating success (boolean) + """ + aw = self.activeWindow() + if aw is None: + return 0 + + res = self.closeEditor(aw) + if res and aw == self.currentEditor: + self.currentEditor = None + + return res + + def handleNewView(self): + """ + Public method to close the current window. + + @return flag indicating success (boolean) + """ + aw = self.activeWindow() + if aw is None: + return 0 + + aw.handleNewView() + + + def handleCloseAll(self): + """ + Private method to close all editor windows via file menu. + """ + savedEditors = self.editors[:] + for editor in savedEditors: + self.closeEditor(editor) + + def handleCloseWindow(self, fn): + """ + Public method to close an arbitrary source editor. + + @param fn filename of editor to be closed + @return flag indicating success (boolean) + """ + for editor in self.editors: + if samepath(fn, editor.getFileName()): + break + else: + return 1 + + res = self.closeEditor(editor) + if res and editor == self.currentEditor: + self.currentEditor = None + + return res + + def handleExit(self): + """ + Public method to handle the debugged program terminating. + """ + if self.currentEditor is not None: + self.currentEditor.highlight() + self.currentEditor = None + + self.setSbFile() + + def handlePythonFile(self,pyfn,lineno=None): + """ + Public method to handle the user selecting a file for display. + + @param pyfn name of file to be opened + @param lineno line number to place the cursor at + """ + try: + self.displayPythonFile(pyfn,lineno) + except IOError: + pass + + + def displayJDC(self,jdc): + """ + Public slot to display a file in an editor. + + @param fn name of file to be opened + @param lineno line number to place the cursor at + """ + newWin, editor = self.getEditor(None, jdc) + + if newWin: + self.handleModificationStatusChanged(editor.modified, editor) + self.checkActions(editor) + + # insert filename into list of recently opened files + self.addToRecentList(editor.getFileName()) + + + + def newEditorView(self, fn, caller): + """ + Public method to create a new editor displaying the given document. + + @param fn filename of this view + @param caller reference to the editor calling this method + """ + from editor import JDCEditor + editor = JDCEditor(fn, None, self, editor=caller) + self.editors.append(editor) + self.connect(editor, PYSIGNAL('modificationStatusChanged'), + self.handleModificationStatusChanged) + self.connect(editor, PYSIGNAL('cursorChanged'), self.handleCursorChanged) + self.connect(editor, PYSIGNAL('editorSaved'), self.handleEditorSaved) + self.connect(editor, PYSIGNAL('breakpointToggled'), self.handleBreakpointToggled) + self.connect(editor, PYSIGNAL('bookmarkToggled'), self.handleBookmarkToggled) + self.connect(editor, PYSIGNAL('syntaxerrorToggled'), self.handleSyntaxErrorToggled) + self.connect(editor, PYSIGNAL('autoCompletionAPIsAvailable'), + self.handleEditoracAPIsAvailable) + self.handleEditorOpened() + self.emit(PYSIGNAL('editorOpened'), (fn,)) + + self.connect(caller, PYSIGNAL('editorRenamed'), editor.handleRenamed) + self.connect(editor, PYSIGNAL('editorRenamed'), caller.handleRenamed) + + self.addView(editor, fn) + self.handleModificationStatusChanged(editor.modified, editor) + self.checkActions(editor) + + def addToRecentList(self, fn): + """ + Public slot to add a filename to the list of recently opened files. + + @param fn name of the file to be added + """ + self.recent.remove(fn) + self.recent.prepend(fn) + if len(self.recent) > 9: + self.recent = self.recent[:9] + + def toggleWindow(self,w): + """ + Private method to toggle a workspace window. + + @param w editor window to be toggled + """ + if w.isHidden(): + w.show() + else: + w.hide() + + def setFileLine(self,fn,line,error=0,syntaxError=0): + """ + Public method to update the user interface when the current program or line changes. + + @param fn filename of editor to update (string) + @param line line number to highlight (int) + @param error flag indicating an error highlight (boolean) + @param syntaxError flag indicating a syntax error + """ + self.setSbFile(fn,line) + + try: + newWin, self.currentEditor = self.getEditor(fn) + except IOError: + return + + # Change the highlighted line. + self.currentEditor.highlight(line,error,syntaxError) + + self.currentEditor.highlightVisible() + self.checkActions(self.currentEditor, 0) + + def setSbFile(self,fn=None,line=None,pos=None): + """ + Private method to set the file info in the status bar. + + @param fn filename to display (string) + @param line line number to display (int) + @param pos character position to display (int) + """ + if fn is None: + fn = '' + writ = ' ' + else: + if QFileInfo(fn).isWritable(): + writ = ' rw' + else: + writ = ' ro' + + self.sbWritable.setText(writ) + self.sbFile.setText(self.trUtf8('File: %1').arg(fn,-50)) + + if line is None: + line = '' + + self.sbLine.setText(self.trUtf8('Line: %1').arg(line,5)) + + if pos is None: + pos = '' + + self.sbPos.setText(self.trUtf8('Pos: %1').arg(pos, 5)) + + def unhighlight(self, current=0): + """ + Public method to switch off all highlights. + + @param current flag indicating only the current editor should be unhighlighted + (boolean) + """ + if current: + if self.currentEditor is not None: + self.currentEditor.highlight() + else: + for editor in self.editors: + editor.highlight() + + def getOpenFilenames(self): + """ + Public method returning a list of the filenames of all editors. + + @return list of all opened filenames (list of strings) + """ + filenames = [] + for editor in self.editors: + fn = editor.getFileName() + if fn is not None: + filenames.append(fn) + + return filenames + + def getEditor(self, fn, jdc = None): + """ + Private method to return the editor displaying the given file. + + If there is no editor with the given file, a new editor window is + created. + + @param fn filename to look for + @param isPythonFile flag indicating that this is a Python file + even if it doesn't have the .py extension (boolean) + @return tuple of two values giving a flag indicating a new window creation and + a reference to the editor displaying this file + """ + newWin = 0 + for editor in self.editors: + if samepath(fn, editor.getFileName()): + break + else: + from editor import JDCEditor + editor = JDCEditor(fn, jdc, self) + + if editor.jdc: # le fichier est bien un jdc + self.editors.append(editor) + self.connect(editor, PYSIGNAL('modificationStatusChanged'), + self.handleModificationStatusChanged) + self.connect(editor, PYSIGNAL('cursorChanged'), self.handleCursorChanged) + self.connect(editor, PYSIGNAL('editorSaved'), self.handleEditorSaved) + self.connect(editor, PYSIGNAL('breakpointToggled'), self.handleBreakpointToggled) + self.connect(editor, PYSIGNAL('bookmarkToggled'), self.handleBookmarkToggled) + self.connect(editor, PYSIGNAL('syntaxerrorToggled'), self.handleSyntaxErrorToggled) + self.connect(editor, PYSIGNAL('autoCompletionAPIsAvailable'), + self.handleEditoracAPIsAvailable) + self.handleEditorOpened() + self.emit(PYSIGNAL('editorOpened'), (fn,)) + newWin = 1 + else: + editor.closeIt() + + if newWin: + self.addView(editor, fn) + elif editor.jdc: + self.showView(editor, fn) + + return (newWin, editor) + + + def getOpenEditor(self, fn): + """ + Public method to return the editor displaying the given file. + + @param fn filename to look for + @return a reference to the editor displaying this file or None, if + no editor was found + """ + for editor in self.editors: + if samepath(fn, editor.getFileName()): + return editor + + return None + + def getActiveName(self): + """ + Public method to retrieve the filename of the active window. + + @return filename of active window (string) + """ + aw = self.activeWindow() + if aw: + return aw.getFileName() + else: + return None + + def saveEditor(self, fn): + """ + Public method to save a named editor file. + + @param fn filename of editor to be saved (string) + @return flag indicating success (boolean) + """ + for editor in self.editors: + if samepath(fn, editor.getFileName()): + break + else: + return 1 + + if not editor.modified: + return 1 + else: + ok, dummy = editor.saveFile() + return ok + + def saveCurrentEditor(self): + """ + Public slot to save the contents of the current editor. + """ + aw = self.activeWindow() + if aw: + ok, newName = aw.saveFile() + if ok: + self.setEditorName(aw, newName) + else: + return + + def saveAsCurrentEditor(self): + """ + Public slot to save the contents of the current editor to a new file. + """ + aw = self.activeWindow() + if aw: + ok, newName = aw.saveFileAs() + if ok: + self.setEditorName(aw, newName) + else: + return + + def saveAllEditors(self): + """ + Public slot to save the contents of all editors. + """ + for editor in self.editors: + ok, newName = editor.saveFile() + if ok: + self.setEditorName(editor, newName) + + # restart autosave timer + if self.autosaveInterval > 0: + self.autosaveTimer.start(self.autosaveInterval * 60000, 1) + + def saveCurrentEditorToProject(self): + """ + Public slot to save the contents of the current editor to the current project. + """ + pro = self.ui.getProject() + path = pro.ppath + aw = self.activeWindow() + if aw: + ok, newName = aw.saveFileAs(path) + if ok: + self.setEditorName(aw, newName) + pro.appendFile(newName) + else: + return + + def newEditor(self): + """ + Public slot to generate a new empty editor. + """ + from editor import JDCEditor + editor = JDCEditor(None,None,self) + + self.editors.append(editor) + self.connect(editor, PYSIGNAL('modificationStatusChanged'), + self.handleModificationStatusChanged) + self.connect(editor, PYSIGNAL('cursorChanged'), self.handleCursorChanged) + self.connect(editor, PYSIGNAL('editorSaved'), self.handleEditorSaved) + self.connect(editor, PYSIGNAL('breakpointToggled'), self.handleBreakpointToggled) + self.connect(editor, PYSIGNAL('bookmarkToggled'), self.handleBookmarkToggled) + self.connect(editor, PYSIGNAL('syntaxerrorToggled'), self.handleSyntaxErrorToggled) + self.connect(editor, PYSIGNAL('autoCompletionAPIsAvailable'), + self.handleEditoracAPIsAvailable) + self.addView(editor, None) + self.handleEditorOpened() + self.checkActions(editor) + self.emit(PYSIGNAL('editorOpened'), (None,)) + + def printCurrentEditor(self): + """ + Public slot to print the contents of the current editor. + """ + aw = self.activeWindow() + if aw: + aw.printFile() + else: + return + + def printCurrentEditorSel(self): + """ + Public slot to print the selection of the current editor. + """ + aw = self.activeWindow() + if aw: + aw.printSelection() + else: + return + +## def handleShowRecentMenu(self): +## """ +## Private method to set up recent files menu. +## """ +## idx = 0 +## self.recentMenu.clear() +## +## for rp in self.recent: +## id = self.recentMenu.insertItem('&%d. %s' % (idx+1, unicode(rp)), +## self.handleOpenRecent) +## self.recentMenu.setItemParameter(id,idx) +## +## idx = idx + 1 +## +## self.recentMenu.insertSeparator() +## self.recentMenu.insertItem(self.trUtf8('&Clear'), self.handleClearRecent) +## +## def handleOpenRecent(self, idx): +## """ +## Private method to open a file from the list of rencently opened files. +## +## @param idx index of the selected entry (int) +## """ +## self.handlePythonFile(unicode(self.recent[idx])) +## +## def handleClearRecent(self): +## """ +## Private method to clear the recent files menu. +## """ +## self.recent = QStringList() + + + def handleViewJdcFichierSource(self): + self.activeWindow().viewJdcSource() + + def handleViewJdcRapport(self): + self.activeWindow().viewJdcRapport() + + def handleNewProject(self): + """ + Public slot to handle the NewProject signal. + """ + self.saveToProjectAct.setEnabled(1) + + def handleProjectOpened(self): + """ + Public slot to handle the projectOpened signal. + """ + self.saveToProjectAct.setEnabled(1) + + def handleProjectClosed(self): + """ + Public slot to handle the projectClosed signal. + """ + self.saveToProjectAct.setEnabled(0) + + def handleProjectFileRenamed(self, oldfn, newfn): + """ + Public slot to handle the projectFileRenamed signal. + + @param oldfn old filename of the file (string) + @param newfn new filename of the file (string) + """ + editor = self.getOpenEditor(oldfn) + if editor: + editor.fileRenamed(newfn) + + def enableEditorsCheckFocusIn(self, enabled): + """ + Public method to set a flag enabling the editors to perform focus in checks. + + @param enabled flag indicating focus in checks should be performed (boolean) + """ + self.editorsCheckFocusIn = enabled + + def editorsCheckFocusInEnabled(self): + """ + Public method returning the flag indicating editors should perform focus in checks. + + @return flag indicating focus in checks should be performed (boolean) + """ + return self.editorsCheckFocusIn + + def handleFindFileName(self): + """ + Private method to handle the search for file action. + """ + self.ui.findFileNameDialog.show() + self.ui.findFileNameDialog.raiseW() + self.ui.findFileNameDialog.setActiveWindow() + + ################################################################## + ## Below are the action methods for the edit menu + ################################################################## + + def handleEditUndo(self): + """ + Private method to handle the undo action. + """ + self.activeWindow().undo() + + def handleEditRedo(self): + """ + Private method to handle the redo action. + """ + self.activeWindow().redo() + + def handleEditRevert(self): + """ + Private method to handle the revert action. + """ + self.activeWindow().revertToUnmodified() + + def handleEditCut(self): + """ + Private method to handle the cut action. + """ + self.activeWindow().cut() + + def handleEditCopy(self): + """ + Private method to handle the copy action. + """ + self.activeWindow().copy() + + def handleEditPaste(self): + """ + Private method to handle the paste action. + """ + self.activeWindow().paste() + + def handleEditDelete(self): + """ + Private method to handle the delete action. + """ + self.activeWindow().clear() + + def handleEditIndent(self): + """ + Private method to handle the indent action. + """ + self.activeWindow().indentLineOrSelection() + + def handleEditUnindent(self): + """ + Private method to handle the unindent action. + """ + self.activeWindow().unindentLineOrSelection() + + def handleEditComment(self): + """ + Private method to handle the comment action. + """ + self.activeWindow().commentLineOrSelection() + + def handleEditUncomment(self): + """ + Private method to handle the uncomment action. + """ + self.activeWindow().uncommentLineOrSelection() + + def handleEditStreamComment(self): + """ + Private method to handle the stream comment action. + """ + self.activeWindow().streamCommentLineOrSelection() + + def handleEditBoxComment(self): + """ + Private method to handle the box comment action. + """ + self.activeWindow().boxCommentLineOrSelection() + + def handleEditSelectBrace(self): + """ + Private method to handle the select to brace action. + """ + self.activeWindow().selectToMatchingBrace() + + def handleEditSelectAll(self): + """ + Private method to handle the select all action. + """ + self.activeWindow().selectAll(1) + + def handleEditDeselectAll(self): + """ + Private method to handle the select all action. + """ + self.activeWindow().selectAll(0) + + def handleConvertEOL(self): + """ + Private method to handle the convert line end characters action. + """ + aw = self.activeWindow() + aw.convertEols(aw.eolMode()) + + def handleShortenEmptyLines(self): + """ + Private method to handle the shorten empty lines action. + """ + self.activeWindow().handleShortenEmptyLines() + + def handleEditAutoComplete(self): + """ + Private method to handle the autocomplete action. + """ + aw = self.activeWindow() + aw.autoComplete() + + def handleEditAutoCompleteFromDoc(self): + """ + Private method to handle the autocomplete from document action. + """ + aw = self.activeWindow() + aw.autoCompleteFromDocument() + + def handleEditAutoCompleteFromAPIs(self): + """ + Private method to handle the autocomplete from APIs action. + """ + aw = self.activeWindow() + aw.autoCompleteFromAPIs() + + def handleEditoracAPIsAvailable(self, available): + """ + Private method to handle the availability of API autocompletion signal. + """ + self.autoCompleteFromAPIsAct.setEnabled(available) + + ################################################################## + ## Below are the action and utility methods for the search menu + ################################################################## + + def getWord(self, text, index): + """ + Private method to get the word at a position. + + @param text text to look at (string or QString) + @param index position to look at (int) + @return the word at that position + """ + re = QRegExp('[^\w_]') + start = text.findRev(re, index) + 1 + end = text.find(re, index) + if end > start: + word = text.mid(start, end-start) + else: + word = QString('') + return word + + def textForFind(self): + """ + Private method to determine the selection or the current word for the next find operation. + + @return selection or current word (QString) + """ + aw = self.activeWindow() + if aw is None: + return '' + + if aw.hasSelectedText(): + text = aw.selectedText() + if text.contains('\r') or text.contains('\n'): + # the selection contains at least a newline, it is + # unlikely to be the expression to search for + return '' + + return text + + # no selected text, determine the word at the current position + line, index = aw.getCursorPosition() + return self.getWord(aw.text(line), index) + + def getSRHistory(self, key): + """ + Private method to get the search or replace history list. + + @param key list to return (must be 'search' or 'replace') + @return the requested history list (QStringList) + """ + return self.srHistory[key] + + def handleSearch(self): + """ + Private method to handle the search action. + """ + self.searchDlg.showFind(self.textForFind()) + + def handleReplace(self): + """ + Private method to handle the replace action. + """ + self.replaceDlg.showReplace(self.textForFind()) + + def handleGoto(self): + """ + Private method to handle the goto action. + """ + aw = self.activeWindow() + dlg = GotoDialog(self.ui, None, 1) + dlg.selectAll() + if dlg.exec_loop() == QDialog.Accepted: + aw.gotoLine(min(dlg.getLinenumber(), aw.lines())) + + def handleGotoBrace(self): + """ + Private method to handle the goto brace action. + """ + self.activeWindow().moveToMatchingBrace() + + def handleSearchFiles(self): + """ + Private method to handle the search in files action. + """ + self.ui.findFilesDialog.show(self.textForFind()) + self.ui.findFilesDialog.raiseW() + self.ui.findFilesDialog.setActiveWindow() + + ################################################################## + ## Below are the action methods for the view menu + ################################################################## + + def handleZoomIn(self): + """ + Private method to handle the zoom in action. + """ + self.activeWindow().zoomIn() + + def handleZoomOut(self): + """ + Private method to handle the zoom out action. + """ + self.activeWindow().zoomOut() + + def handleZoom(self): + """ + Private method to handle the zoom action. + """ + aw = self.activeWindow() + dlg = ZoomDialog(aw.getZoom(), self.ui, None, 1) + if dlg.exec_loop() == QDialog.Accepted: + aw.zoomTo(dlg.getZoomSize()) + + def handleToggleAll(self): + """ + Private method to handle the toggle all folds action. + """ + self.activeWindow().foldAll() + + def handleToggleCurrent(self): + """ + Private method to handle the toggle current fold action. + """ + aw = self.activeWindow() + line, index = aw.getCursorPosition() + aw.foldLine(line) + + def handleSplitView(self): + """ + Private method to handle the split view action. + """ + self.addSplit() + + def handleSplitOrientation(self): + """ + Private method to handle the split orientation action. + """ + if self.splitOrientationAct.isOn(): + self.setSplitOrientation(QSplitter.Horizontal) + self.splitViewAct.setIconSet(\ + QIconSet(utilIcons.getPixmap("splitHorizontal.png"))) + self.splitRemoveAct.setIconSet(\ + QIconSet(utilIcons.getPixmap("remsplitHorizontal.png"))) + else: + self.setSplitOrientation(QSplitter.Vertical) + self.splitViewAct.setIconSet(\ + QIconSet(utilIcons.getPixmap("splitVertical.png"))) + self.splitRemoveAct.setIconSet(\ + QIconSet(utilIcons.getPixmap("remsplitVertical.png"))) + + ################################################################## + ## Below are the action methods for the macro menu + ################################################################## + + def handleMacroStartRecording(self): + """ + Private method to handle the start macro recording action. + """ + self.activeWindow().handleStartMacroRecording() + + def handleMacroStopRecording(self): + """ + Private method to handle the stop macro recording action. + """ + self.activeWindow().handleStopMacroRecording() + + def handleMacroRun(self): + """ + Private method to handle the run macro action. + """ + self.activeWindow().handleRunMacro() + + def handleMacroDelete(self): + """ + Private method to handle the delete macro action. + """ + self.activeWindow().handleDeleteMacro() + + def handleMacroLoad(self): + """ + Private method to handle the load macro action. + """ + self.activeWindow().handleLoadMacro() + + def handleMacroSave(self): + """ + Private method to handle the save macro action. + """ + self.activeWindow().handleSaveMacro() + + ################################################################## + ## Below are the action methods for the bookmarks menu + ################################################################## + + def handleToggleBookmark(self): + """ + Private method to handle the toggle bookmark action. + """ + self.activeWindow().handleToggleBookmark() + + def handleNextBookmark(self): + """ + Private method to handle the next bookmark action. + """ + self.activeWindow().handleNextBookmark() + + def handlePreviousBookmark(self): + """ + Private method to handle the previous bookmark action. + """ + self.activeWindow().handlePreviousBookmark() + + def handleClearAllBookmarks(self): + """ + Private method to handle the clear all bookmarks action. + """ + for editor in self.editors: + editor.handleClearBookmarks() + + self.bookmarkNextAct.setEnabled(0) + self.bookmarkPreviousAct.setEnabled(0) + self.bookmarkClearAct.setEnabled(0) + + def handleShowBookmarksMenu(self): + """ + Private method to handle the show bookmarks menu signal. + """ + self.bookmarks = {} + self.bookmarksMenu.clear() + + filenames = self.getOpenFilenames() + filenames.sort() + for filename in filenames: + editor = self.getOpenEditor(filename) + for bookmark in editor.getBookmarks(): + if len(filename) > 50: + dots = "..." + else: + dots = "" + id = self.bookmarksMenu.insertItem(\ + "%s%s : %d" % (dots, filename[-50:], bookmark)) + self.bookmarks[id] = (filename, bookmark) + + def handleBookmarkSelected(self, id): + """ + Private method to handle the bookmark selected signal. + + @param id index of the selected menu entry + This acts as an index into the list of bookmarks + that was created, when the bookmarks menu was built. + """ + self.displayPythonFile(self.bookmarks[id][0], self.bookmarks[id][1]) + + def handleBookmarkToggled(self, editor): + """ + Private slot to handle the bookmarkToggled signal. + + It checks some bookmark actions and reemits the signal. + + @param editor editor that sent the signal + """ + if editor.hasBookmarks(): + self.bookmarkNextAct.setEnabled(1) + self.bookmarkPreviousAct.setEnabled(1) + self.bookmarkClearAct.setEnabled(1) + else: + self.bookmarkNextAct.setEnabled(0) + self.bookmarkPreviousAct.setEnabled(0) + self.bookmarkClearAct.setEnabled(0) + self.emit(PYSIGNAL('bookmarkToggled'), (editor,)) + + def handleGotoSyntaxError(self): + """ + Private method to handle the goto syntax error action. + """ + self.activeWindow().handleGotoSyntaxError() + + def handleClearAllSyntaxErrors(self): + """ + Private method to handle the clear all syntax errors action. + """ + for editor in self.editors: + editor.handleClearSyntaxError() + + def handleSyntaxErrorToggled(self, editor): + """ + Private slot to handle the syntaxerrorToggled signal. + + It checks some syntax error actions and reemits the signal. + + @param editor editor that sent the signal + """ + if editor.hasSyntaxErrors(): + self.syntaxErrorGotoAct.setEnabled(1) + self.syntaxErrorClearAct.setEnabled(1) + else: + self.syntaxErrorGotoAct.setEnabled(0) + self.syntaxErrorClearAct.setEnabled(0) + self.emit(PYSIGNAL('syntaxerrorToggled'), (editor,)) + + ################################################################## + ## Below are general utility methods + ################################################################## + + def handleResetUI(self): + """ + Public slot to handle the resetUI signal. + """ + editor = self.activeWindow() + if editor is None: + self.setSbFile() + else: + line, pos = editor.getCursorPosition() + self.setSbFile(editor.getFileName(), line+1, pos) + + def closeViewManager(self): + """ + Public method to shutdown the viewmanager. + + If it cannot close all editor windows, it aborts the shutdown process. + + @return flag indicating success (boolean) + """ + self.handleCloseAll() + if len(self.editors): + return 0 + else: + return 1 + + def handleLastEditorClosed(self): + """ + Private slot to handle the lastEditorClosed signal. + """ + self.SauveRecents() + + + def handleEditorOpened(self): + """ + Private slot to handle the editorOpened signal. + """ + self.closeActGrp.setEnabled(1) + self.saveActGrp.setEnabled(1) + self.printAct.setEnabled(1) + self.printSelAct.setEnabled(1) + self.editActGrp.setEnabled(1) + self.searchActGrp.setEnabled(1) + self.viewActGrp.setEnabled(1) + self.viewFoldActGrp.setEnabled(1) + self.unhighlightAct.setEnabled(1) + self.splitViewAct.setEnabled(1) + self.splitOrientationAct.setEnabled(1) + self.macroActGrp.setEnabled(1) + self.bookmarkActGrp.setEnabled(1) + + # activate the autosave timer + if not self.autosaveTimer.isActive() and \ + self.autosaveInterval > 0: + self.autosaveTimer.start(self.autosaveInterval * 60000, 1) + + + def checkActions(self, editor, setSb=1): + """ + Private slot to check some actions for their enable/disable status and set the statusbar info. + + @param editor editor window + @param setSb flag indicating an update of the status bar is wanted (boolean) + """ + if editor is not None: + self.saveAct.setEnabled(editor.modified) + self.revertAct.setEnabled(editor.modified) + + lex = editor.getLexer() + if lex is not None: + self.commentAct.setEnabled(lex.canBlockComment()) + self.uncommentAct.setEnabled(lex.canBlockComment()) + self.streamCommentAct.setEnabled(lex.canStreamComment()) + self.boxCommentAct.setEnabled(lex.canBoxComment()) + else: + self.commentAct.setEnabled(0) + self.uncommentAct.setEnabled(0) + self.streamCommentAct.setEnabled(0) + self.boxCommentAct.setEnabled(0) + + if editor.hasBookmarks(): + self.bookmarkNextAct.setEnabled(1) + self.bookmarkPreviousAct.setEnabled(1) + self.bookmarkClearAct.setEnabled(1) + else: + self.bookmarkNextAct.setEnabled(0) + self.bookmarkPreviousAct.setEnabled(0) + self.bookmarkClearAct.setEnabled(0) + + if editor.hasSyntaxErrors(): + self.syntaxErrorGotoAct.setEnabled(1) + self.syntaxErrorClearAct.setEnabled(1) + else: + self.syntaxErrorGotoAct.setEnabled(0) + self.syntaxErrorClearAct.setEnabled(0) + + if editor.canAutoCompleteFromAPIs(): + self.autoCompleteFromAPIsAct.setEnabled(1) + else: + self.autoCompleteFromAPIsAct.setEnabled(0) + + if setSb: + line, pos = editor.getCursorPosition() + self.setSbFile(editor.getFileName(), line+1, pos) + + self.emit(PYSIGNAL('checkActions'), (editor,)) + + def handlePreferencesChanged(self): + """ + Public slot to handle the preferencesChanged signal. + + This method performs the following actions + + """ + # reload api information + for language, api in self.apis.items(): + if api is not None: + apifiles = Preferences.getEditorAPI(language) + if len(apifiles): + api.clear() + for apifile in apifiles: + api.load(apifile) + else: + self.apis[language] = None + + # reload editor settings + for editor in self.editors: + editor.readSettings() + + # reload the autosave timer setting + self.autosaveInterval = Preferences.getEditor("AutosaveInterval") + if len(self.editors): + if self.autosaveTimer.isActive() and \ + self.autosaveInterval == 0: + self.autosaveTimer.stop() + elif not self.autosaveTimer.isActive() and \ + self.autosaveInterval > 0: + self.autosaveTimer.start(self.autosaveInterval * 60000, 1) + + def handleEditorSaved(self, fn): + """ + Public slot to handle the editorSaved signal. + + It simply reemits the signal. + + @param fn filename of the saved editor + """ + self.emit(PYSIGNAL('editorSaved'), (fn,)) + + def handleCursorChanged(self, fn, line, pos): + """ + Private slot to handle the cursorChanged signal. + + It emits the signal cursorChanged with parameter editor. + + @param fn filename (string) + @param line line number of the cursor (int) + @param pos position in line of the cursor (int) + """ + self.setSbFile(fn, line, pos) + self.emit(PYSIGNAL('cursorChanged'), (self.getOpenEditor(fn),)) + + def handleBreakpointToggled(self, editor): + """ + Private slot to handle the breakpointToggled signal. + + It simply reemits the signal. + + @param editor editor that sent the signal + """ + self.emit(PYSIGNAL('breakpointToggled'), (editor,)) + + + def getProject(self): + """ + Public method to get a reference to the Project object. + + @return Reference to the Project object (Project.Project) + """ + return self.ui.getProject() + + def getActions(self, type): + """ + Public method to get a list of all actions. + + @param type string denoting the action set to get. + It must be one of "edit", "file", "search", + "view" or "window" + @return list of all actions (list of QAction) + """ + try: + exec 'actionList = self.%sActions[:]' % type + except: + actionList = [] + + return actionList + + def editorCommand(self, cmd): + """ + Private method to send an editor command to the active window. + + @param cmd the scintilla command to be sent + """ + aw = self.activeWindow() + if aw: + aw.SendScintilla(cmd) + + ################################################################## + ## Below are protected utility methods + ################################################################## + + def _getOpenStartDir(self): + """ + Protected method to return the starting directory for a file open dialog. + + The appropriate starting directory is calculated + using the following search order, until a match is found:
+ 1: Directory of currently active editor
+ 2: Directory of currently active Project
+ 3: CWD + + @return String name of directory to start or None + """ + # if we have an active source, return its path + if self.activeWindow() is not None and \ + self.activeWindow().getFileName(): + return os.path.dirname(self.activeWindow().getFileName()) + + # ok, try if there is an active project and return its path + elif self.getProject().isOpen(): + return self.getProject().ppath + + else: + # None will cause open dialog to start with cwd + return None + + + def _getOpenFileFilter(self): + """ + Protected method to return the active filename filter for a file open dialog. + + The appropriate filename filter is determined by file extension of + the currently active editor. + + @return name of the filename filter (QString) or None + """ + if self.activeWindow() is not None and \ + self.activeWindow().getFileName(): + ext = os.path.splitext(self.activeWindow().getFileName())[1] + try: + return QString(self.ext2Filter[ext]) + except KeyError: + return None + + else: + return None + + + + +""" +Module implementing a tabbed viewmanager class. +""" + + + +class TabWidget(QTabWidget): + """ + Class implementing a custimized TabWidget. + """ + def __init__(self, parent): + """ + Constructor + + @param parent parent widget (QWidget) + """ + QTabWidget.__init__(self, parent) + + self.editors = [] + self.curIndex = 0 + + self.connect(self, SIGNAL("currentChanged(QWidget *)"), self.handleCurrentChanged) + + def handleCurrentChanged(self): + """ + Private slot called by the currentChanged signal. + """ + self.curIndex = self.currentPageIndex() + + def addTab(self, editor, title): + """ + Overwritten method to add a new tab. + + @param editor the editor object to be added (QScintilla.Editor.Editor) + @param title title for the new tab (string, QString or QTab) + """ + QTabWidget.addTab(self, editor, title) + + if not editor in self.editors: + self.editors.append(editor) + self.connect(editor, PYSIGNAL('captionChanged'), + self.handleCaptionChange) + + def showPage(self, editor): + """ + Overridden method to show a tab. + + @param editor the editor object to be shown (QScintilla.Editor.Editor) + """ + QTabWidget.showPage(self, editor) + self.curIndex = self.indexOf(editor) + + def nextTab(self): + """ + Public slot used to show the next tab. + """ + if self.count(): + self.curIndex += 1 + if self.curIndex == self.count(): + self.curIndex = 0 + + QTabWidget.showPage(self, self.page(self.curIndex)) + + def prevTab(self): + """ + Public slot used to show the previous tab. + """ + if self.count(): + self.curIndex -= 1 + if self.curIndex == -1: + self.curIndex = self.count() - 1 + + QTabWidget.showPage(self, self.page(self.curIndex)) + + def handleCaptionChange(self, cap, editor): + """ + Private method to handle Caption change signals from the editor. + + Updates the listview text to reflect the new caption information. + + @param cap Caption for the editor + @param editor Editor to update the caption for + """ + fn = editor.getFileName() + if fn: + txt = os.path.basename(fn) + if editor.isReadOnly(): + txt = '%s (ro)' % txt + self.changeTab(editor, txt) + + def removePage(self, object): + """ + Overwritten method to remove a page. + + @param object object to be removed (QObject) + """ + QTabWidget.removePage(self, object) + + self.disconnect( object, PYSIGNAL('captionChanged'), + self.handleCaptionChange ) + self.editors.remove(object) + + def hasEditor(self, editor): + """ + Public method to check for an editor. + + @param editor editor object to check for + @return flag indicating, whether the editor to be checked belongs + to the list of editors managed by this tab widget. + """ + return editor in self.editors + + def hasEditors(self): + """ + Public method to test, if any editor is managed. + + @return flag indicating editors are managed + """ + return len(self.editors) and 1 or 0 + +class Tabview(QSplitter, ViewManager): + """ + Class implementing a tabbed viewmanager class embedded in a splitter. + + @signal lastEditorClosed emitted after the last editor window was closed + @signal editorOpened emitted after an editor window was opened + @signal editorSaved emitted after an editor window was saved + """ + def __init__(self,parent, ui): + """ + Constructor + + @param parent parent widget (QWidget) + @param ui reference to the main user interface + @param dbs reference to the debug server object + """ + self.tabWidgets = [] + + QSplitter.__init__(self,parent) + ViewManager.__init__(self, ui) + tw = TabWidget(self) + self.tabWidgets.append(tw) + self.currentTabWidget = tw + self.connect(tw, SIGNAL('currentChanged(QWidget*)'), + self.handleCurrentChanged) + tw.installEventFilter(self) + tw.tabBar().installEventFilter(self) + self.setOrientation(QSplitter.Vertical) + + def initViewActions(self): + """ + Protected method defining the user interface actions for the view commands. + """ + ViewManager.initViewActions(self) + + self.nextTabAct = QAction(self.trUtf8('Show next tab'), + self.trUtf8('Show next tab'), + QKeySequence(self.trUtf8('Ctrl+Alt+Tab')), self) + self.connect(self.nextTabAct, SIGNAL('activated()'), self.nextTab) + self.viewActions.append(self.nextTabAct) + + self.prevTabAct = QAction(self.trUtf8('Show previous tab'), + self.trUtf8('Show previous tab'), + QKeySequence(self.trUtf8('Shift+Ctrl+Alt+Tab')), self) + self.connect(self.prevTabAct, SIGNAL('activated()'), self.prevTab) + self.viewActions.append(self.prevTabAct) + + def nextTab(self): + """ + Private slot used to show the next tab of the current tabwidget. + """ + self.currentTabWidget.nextTab() + + def prevTab(self): + """ + Private slot used to show the previous tab of the current tabwidget. + """ + self.currentTabWidget.prevTab() + + def canCascade(self): + """ + Public method to signal if cascading of managed windows is available. + + @return flag indicating cascading of windows is available + """ + return 0 + + def canTile(self): + """ + Public method to signal if tiling of managed windows is available. + + @return flag indicating tiling of windows is available + """ + return 0 + + def canSplit(self): + """ + public method to signal if splitting of the view is available. + + @return flag indicating splitting of the view is available. + """ + return 1 + + def tile(self): + """ + Public method to tile the managed windows. + """ + pass + + def cascade(self): + """ + Public method to cascade the managed windows. + """ + pass + + def removeAllViews(self): + """ + Private method to remove all views (i.e. windows) + """ + for win in self.editors: + self.removeView(win) + + def removeView(self, win): + """ + Private method to remove a view (i.e. window) + + @param win editor window to be removed + """ + for tw in self.tabWidgets: + if tw.hasEditor(win): + tw.removePage(win) + break + win.closeIt() + + # if this was the last editor in this view, switch to the next, that + # still has open editors + for i in range(self.tabWidgets.index(tw), -1, -1) + \ + range(self.tabWidgets.index(tw) + 1, len(self.tabWidgets)): + if self.tabWidgets[i].hasEditors(): + self.currentTabWidget = self.tabWidgets[i] + self.activeWindow().setFocus() + break + + def addView(self, win, fn=None): + """ + Private method to add a view (i.e. window) + + @param win editor window to be added + @param fn filename of this editor + """ + win.show() + if fn is None: + self.untitledCount += 1 + self.currentTabWidget.addTab(win, self.trUtf8("Untitled %1").arg(self.untitledCount)) + else: + txt = os.path.basename(fn) + if not QFileInfo(fn).isWritable(): + txt = '%s (ro)' % txt + self.currentTabWidget.addTab(win, txt) + self.currentTabWidget.setTabToolTip(win, os.path.dirname(fn)) + self.currentTabWidget.showPage(win) + win.setFocus() + + def showView(self, win, fn=None): + """ + Private method to show a view (i.e. window) + + @param win editor window to be shown + @param fn filename of this editor + """ + win.show() + for tw in self.tabWidgets: + if tw.hasEditor(win): + tw.showPage(win) + self.currentTabWidget = tw + break + win.setFocus() + + def activeWindow(self): + """ + Private method to return the active (i.e. current) window. + + @return reference to the active editor + """ + return self.currentTabWidget.currentPage() + + def handleShowWindowMenu(self, windowMenu): + """ + Private method to set up the viewmanager part of the Window menu. + + @param windowMenu reference to the window menu + """ + pass + + def initWindowActions(self): + """ + Define the user interface actions for window handling. + """ + pass + + def setEditorName(self, editor, newName): + """ + Change the displayed name of the editor. + + @param editor editor window to be changed + @param newName new name to be shown (string or QString) + """ + self.currentTabWidget.changeTab(editor, + os.path.basename(unicode(newName))) + self.currentTabWidget.setTabToolTip(editor, + os.path.dirname(unicode(newName))) + + def handleModificationStatusChanged(self, m, editor): + """ + Private slot to handle the modificationStatusChanged signal. + + @param m flag indicating the modification status (boolean) + @param editor editor window changed + """ + for tw in self.tabWidgets: + if tw.hasEditor(editor): + break + if m: + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("fileModified.png"))) + elif editor.hasSyntaxErrors(): + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("syntaxError.png"))) + else: + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("empty.png"))) + self.checkActions(editor) + + def handleSyntaxErrorToggled(self, editor): + """ + Private slot to handle the syntaxerrorToggled signal. + + @param editor editor that sent the signal + """ + for tw in self.tabWidgets: + if tw.hasEditor(editor): + break + if editor.hasSyntaxErrors(): + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("syntaxError.png"))) + else: + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("empty.png"))) + + ViewManager.handleSyntaxErrorToggled(self, editor) + + def addSplit(self): + """ + Public method used to split the current view. + """ + tw = TabWidget(self) + tw.show() + self.tabWidgets.append(tw) + self.currentTabWidget = self.tabWidgets[-1] + self.connect(tw, SIGNAL('currentChanged(QWidget*)'), + self.handleCurrentChanged) + tw.installEventFilter(self) + tw.tabBar().installEventFilter(self) + self.setSizes([int(100/len(self.tabWidgets))] * len(self.tabWidgets)) + self.splitRemoveAct.setEnabled(1) + + def removeSplit(self): + """ + Public method used to remove the current split view. + + @return flag indicating successfull removal + """ + if len(self.tabWidgets) > 1: + tw = self.currentTabWidget + res = 1 + savedEditors = tw.editors[:] + for editor in savedEditors: + res &= self.closeEditor(editor) + if res: + i = self.tabWidgets.index(tw) + if i == len(self.tabWidgets)-1: + i -= 1 + self.tabWidgets.remove(tw) + tw.close(1) + self.currentTabWidget = self.tabWidgets[i] + if len(self.tabWidgets) == 1: + self.splitRemoveAct.setEnabled(0) + return 1 + + return 0 + + def setSplitOrientation(self, orientation): + """ + Public method used to set the orientation of the split view. + + @param orientation orientation of the split + (QSplitter.Horizontal or QSplitter.Vertical) + """ + self.setOrientation(orientation) + + def handleCurrentChanged(self, editor): + """ + Private slot to handle the currentChanged signal. + + @param editor selected editor window + """ + self.checkActions(editor) + editor.setFocus() + + def eventFilter(self, watched, event): + """ + Method called to filter the event queue. + + @param watched the QObject being watched + @param event the event that occurred + @return always 0 + """ + if event.type() == QEvent.MouseButtonPress and \ + not event.button() == Qt.RightButton: + if isinstance(watched, QTabWidget): + self.currentTabWidget = watched + elif isinstance(watched, QTabBar): + self.currentTabWidget = watched.parent() + elif isinstance(watched, QScintilla.Editor.Editor): + for tw in self.tabWidgets: + if tw.hasEditor(watched): + self.currentTabWidget = tw + break + + aw = self.activeWindow() + if aw is not None: + self.checkActions(aw) + aw.setFocus() + + return 0 + + +class MyTabview(Tabview): + """ + Base class inherited by all specific viewmanager classes. + + It defines the interface to be implemented by specific + viewmanager classes and all common methods. + + @signal lastEditorClosed emitted after the last editor window was closed + @signal editorOpened(string) emitted after an editor window was opened + @signal editorSaved(string) emitted after an editor window was saved + @signal checkActions(editor) emitted when some actions should be checked + for their status + @signal cursorChanged(editor) emitted after the cursor position of the active + window has changed + @signal breakpointToggled(editor) emitted when a breakpoint is toggled. + @signal bookmarkToggled(editor) emitted when a bookmark is toggled. + """ + def __init__(self, parent, ui): + Tabview.__init__(self, parent, ui) + self.appli=parent + self.initRecent() + + def initRecent(self) : + rep=self.appli.CONFIGURATION.rep_user + monFichier=rep+"/listefichiers" + index=0 + try : + f=open(monFichier) + while ( index < 9) : + ligne=f.readline() + if ligne != "" : + l=(ligne.split("\n"))[0] + self.recent.append(l) + index=index+1 + except : pass + + try : f.close() + except : pass + + def SauveRecents(self) : + rep=self.appli.CONFIGURATION.rep_user + monFichier=rep+"/listefichiers" + try : + f=open(monFichier,'w') + if len(self.recent) == 0 : return + index=0 + while ( index < len(self.recent)): + ligne=str(self.recent[index])+"\n" + f.write(ligne) + index=index+1 + except : + pass + try : + f.close() + except : + pass + + + def checkActions(self, editor, setSb=1): + """ + Private slot to check some actions for their enable/disable status and set the statusbar info. + + @param editor editor window + @param setSb flag indicating an update of the status bar is wanted (boolean) + """ + self.emit(PYSIGNAL('checkActions'), (editor,)) + + + def addToRecentList(self, fn): + """ + Public slot to add a filename to the list of recently opened files. + + @param fn name of the file to be added + """ + self.recent.remove(fn) + self.recent.prepend(fn) + if len(self.recent) > 9: + self.recent = self.recent[:9] + + def handleOpen(self,fn=None,patron=0): + """ + Public slot to open a Python JDC file. + + @param prog name of file to be opened (string or QString) + patron booleen pour indiquer si le fichier doit etre + ajoute a la liste des fichiers ouverts recemment + """ + # Get the file name if one wasn't specified. + if fn is None: + + fn = QFileDialog.getOpenFileName(self._getOpenStartDir(), + self.trUtf8('JDC Files (*.comm);;''All Files (*)'), self.ui, None, None, None) + + if fn.isNull(): + return + + fn = normabspath(unicode(fn)) + + newWin, editor = self.getEditor(fn) + + if newWin: + self.handleModificationStatusChanged(editor.modified, editor) + self.checkActions(editor) + + # insert filename into list of recently opened files + if patron == 0 : self.addToRecentList(fn) + + + ################################################################## + ## Below are protected utility methods + ################################################################# + + def _getOpenStartDir(self): + """ + Protected method to return the starting directory for a file open dialog. + + The appropriate starting directory is calculated + using the following search order, until a match is found:
+ 1: Directory of currently active editor
+ 2: Directory of currently active Project
+ 3: CWD + + @return String name of directory to start or None + """ + # if we have an active source, return its path + if self.activeWindow() is not None and \ + self.activeWindow().getFileName(): + return os.path.dirname(self.activeWindow().getFileName()) + + + else: + # None will cause open dialog to start with cwd + return None + + + def handleEditorOpened(self): + """ + Private slot to handle the editorOpened signal. + """ + pass + + def handleModificationStatusChanged(self, m, editor): + """ + Private slot to handle the modificationStatusChanged signal. + + @param m flag indicating the modification status (boolean) + @param editor editor window changed + """ + for tw in self.tabWidgets: + if tw.hasEditor(editor): + break + if m: + #tw.setTabIconSet(editor, + # QIconSet(utilIcons.getPixmap("fileModified.png"))) + pass + elif editor.hasSyntaxErrors(): + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("syntaxError.png"))) + else: + tw.setTabIconSet(editor, + QIconSet(utilIcons.getPixmap("empty.png"))) + self.checkActions(editor) + + + + +if __name__=='__main__': + import sys + from Aster import prefs + if hasattr(prefs,'encoding'): + # Hack pour changer le codage par defaut des strings + import sys + reload(sys) + sys.setdefaultencoding(prefs.encoding) + del sys.setdefaultencoding + # Fin hack + + #CS_pbruno note: fait implicitement des trucs ces imports (grr) + #import styles + from Editeur import import_code + from Editeur import session + + # Analyse des arguments de la ligne de commande + options=session.parse(sys.argv) + code=options.code + app = QApplication(sys.argv) + + mw = MyTabview(None,None) + app.setMainWidget(mw) + app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) + mw.show() + mw.getEditor('azAster.comm') + mw.getEditor('azAster2.comm') + res = app.exec_loop() + sys.exit(res) diff --git a/InterfaceQT/visualisation.py b/InterfaceQT/visualisation.py new file mode 100644 index 00000000..675bc29b --- /dev/null +++ b/InterfaceQT/visualisation.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'visualisation.ui' +# +# Created: mer fév 21 10:55:14 2007 +# by: The PyQt User Interface Compiler (pyuic) 3.13 +# +# WARNING! All changes made in this file will be lost! + + +from qt import * + + +class visual(QWidget): + def __init__(self,parent = None,name = None,fl = 0): + QWidget.__init__(self,parent,name,fl) + + if not name: + self.setName("visual") + + f = QFont(self.font()) + f.setPointSize(14) + self.setFont(f) + + + self.frame5 = QFrame(self,"frame5") + self.frame5.setGeometry(QRect(10,520,801,41)) + self.frame5.setFrameShape(QFrame.StyledPanel) + self.frame5.setFrameShadow(QFrame.Raised) + + self.pushBOK = QPushButton(self.frame5,"pushBOK") + self.pushBOK.setGeometry(QRect(120,8,121,25)) + + self.pushBSave = QPushButton(self.frame5,"pushBSave") + self.pushBSave.setGeometry(QRect(470,8,120,25)) + + self.textBrowser1 = QTextBrowser(self,"textBrowser1") + self.textBrowser1.setGeometry(QRect(10,10,810,500)) + + self.languageChange() + + self.resize(QSize(830,582).expandedTo(self.minimumSizeHint())) + self.clearWState(Qt.WState_Polished) + + self.connect(self.pushBOK,SIGNAL("clicked()"),self.close) + self.connect(self.pushBSave,SIGNAL("clicked()"),self.Save) + + + def languageChange(self): + self.setCaption(self.__tr("Visualisation du rapport de validation du jeu de commandes courant")) + self.pushBOK.setText(self.__tr("Fermer")) + self.pushBSave.setText(self.__tr("Sauver")) + + + def Save(self): + print "visual.Save(): Not implemented yet" + + def __tr(self,s,c = None): + return qApp.translate("visual",s,c)