From: Pascale Noyret Date: Tue, 9 Sep 2008 16:03:19 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V1_14QT4v1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10f16b035b355379381bca8f8b0364b5320866f5;p=tools%2Feficas.git *** empty log message *** --- diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 559caaa2..1f6893db 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -36,21 +36,20 @@ class JDCTree( QTreeWidget ): self.editor = QWParent self.appliEficas = self.editor.appliEficas - #self.setRootIsDecorated(1) self.setColumnCount(2) mesLabels=QStringList() - mesLabels << self.trUtf8('Commande') << self.trUtf8('Concept/Valeur') + mesLabels << self.trUtf8('Commande ') << self.trUtf8('Concept/Valeur ') self.setHeaderLabels(mesLabels) self.setMinimumSize(QSize(400,500)) #self.connect(self,SIGNAL('contextMenuRequested(QListWidgetItem *, const QPoint &, int)'), # self.handleContextMenu) - #self.connect(self, SIGNAL("onItem ( QListWidgetItem * ) "), self.handleOnItem) self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem) self.racine=self.item.itemNode(self,self.item) self.expandItem(self.racine) - self.node_selected = self.racine + self.node_selected=self.racine + self.racine.affichePanneau() # def handleContextMenu(self,itm,coord,col): # """ @@ -116,42 +115,34 @@ class JDCNode(QTreeWidgetItem): mesColonnes << name << value QTreeWidgetItem.__init__(self,treeParent,mesColonnes) - monIcone = QIcon("icons/" +item.GetIconName() + ".gif") + monIcone = QIcon("/home/noyret/Install_Eficas/EficasV1/InterfaceQT4/icons/" +self.item.GetIconName() + ".gif") self.setIcon(0,monIcone) + self.children = [] self.build_children() - self.connect() def build_children(self): """ Construit la liste des enfants de self """ + self.setExpanded(0) + for item in self.children : + self.removeChild(item) self.children = [] sublist = self.item._GetSubList() for item in sublist : nouvelItem=item.itemNode(self,item) self.children.append(nouvelItem) + self.setExpanded(1) def affichePanneau(self) : - panel=self.getPanel() + if self.item.isactif(): + panel=self.getPanel() + else: + from monInactifPanel import PanelInactif + panel = PanelInactif(self,self.editor) panel.show() + self.select() -# if after is None: -# QListWidgetItem. _init__(self,QWParent) -# self.setText(0, name ) -# self.setText(1, value ) -# else: -# QListWidgetItem.__init__(self,QWParent, after) -# self.setText(0, name ) -# self.setText(1, value) -# -# p = utilIcons.getPixmap(item.GetIconName() + ".gif") -# self.setPixmap(0,p) -# self.setExpandable(item.IsExpandable()) -# -# self.init() -# self.createPopUpMenu() -# -# # def paintCell(self, p, cg, column, width, alignment): # """ # Overwritten class to set a different text color, if bold is true. @@ -173,59 +164,11 @@ class JDCNode(QTreeWidgetItem): # _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 = [] - #QListWidgetItem.setOpen(self,o) - print self.tree.__class__ - self.tree.setCurrentItem(self) -# -# #---------------------------------------------------------- -# # 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.QWParent is self.tree: -# self.racine=self -# else: -# self.racine = self.QWParent.racine -# - def connect(self): - self.item.connect("add",self.onAdd,()) - self.item.connect("supp",self.onSupp,()) - self.item.connect("valid",self.onValid,()) +# def connect(self): +# self.item.connect("add",self.onAdd,()) +# self.item.connect("supp",self.onSupp,()) +# self.item.connect("valid",self.onValid,()) # # def commentIt(self): @@ -287,30 +230,31 @@ class JDCNode(QTreeWidgetItem): 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 + self.tree.node_selected.setSelected(0) + self.setSelected( True ) + self.tree.node_selected= self + + #------------------------------------------------------------------ + # 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 + """ ### print "*********** append_brother ", self.item.GetLabelText() -# index = self.QWParent.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.QWParent.append_child(name,pos=index) -# + index = self.treeParent.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.treeParent.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. @@ -318,7 +262,7 @@ class JDCNode(QTreeWidgetItem): ou en position intermediaire. Si pos vaut None, on le place a la position du catalogue. """ -### print "************** append_child ",self.item.GetLabelText() + print "************** append_child ",self.item.GetLabelText() if pos == 'first': index = 0 elif pos == 'last': @@ -334,33 +278,36 @@ class JDCNode(QTreeWidgetItem): 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 + self.build_children() child=self.children[index] - child.select() + child.affichePanneau() 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.QWParent.init_modif() -# index = self.QWParent.children.index(self) - 1 -# if index < 0 : index =0 -# -# QWParent=self.QWParent -# ret=QWParent.item.suppitem(self.item) -# if ret == 0:return -# -# brothers=QWParent.children -# if brothers: -# toselect=brothers[index] -# else: -# toselect=QWParent -# toselect.select() + 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.treeParent.children.index(self) - 1 + if index < 0 : index =0 + + ret=self.treeParent.item.suppitem(self.item) + if ret == 0:return + + self.treeParent.build_children() + print index + brothers=self.treeParent.children + if brothers: + toselect=brothers[index] + self.treeParent.setSelected(0) + else: + toselect=self.treeParent + toselect.select() + toselect.affichePanneau() + # # #------------------------------------------------------------------ def onValid(self): @@ -385,8 +332,8 @@ class JDCNode(QTreeWidgetItem): """Cette methode remet a jour la validite du noeud (icone) Elle appelle isvalid """ - #print 'NODE update_node_valid', self.item.GetLabelText() - monIcone = QIcon("icons/" +self.item.GetIconName() + ".gif") + print 'NODE update_node_valid', self.item.GetLabelText() + monIcone = QIcon("/home/noyret/Install_Eficas/EficasV1/InterfaceQT4/icons/" +self.item.GetIconName() + ".gif") self.setIcon(0,monIcone) def update_node_label(self): @@ -401,11 +348,8 @@ class JDCNode(QTreeWidgetItem): 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_nodes(self): + self.select() # def update_texte(self): """ Met a jour les noms des SD et valeurs des mots-cles """ diff --git a/InterfaceQT4/monInactifPanel.py b/InterfaceQT4/monInactifPanel.py new file mode 100644 index 00000000..ff0eb88a --- /dev/null +++ b/InterfaceQT4/monInactifPanel.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + + +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +from qtCommun import QTPanel +from desInactif import Ui_DInactif + + +SEPARATEUR = '-'*30 + + +class PanelInactif( QTPanel, Ui_DInactif,QDialog ): + def __init__(self,node,parent ): + QDialog.__init__(self,parent) + QTPanel.__init__(self,node,parent) + Ui_DInactif.__init__(self,parent) + if hasattr(parent,"leLayout"): + parent.leLayout.removeWidget(parent.leLayout.widgetActive) + parent.leLayout.widgetActive.close() + parent.leLayout.addWidget(self) + parent.leLayout.widgetActive=self + else: + parent.partieDroite=QWidget() + parent.leLayout=QGridLayout(parent.partieDroite) + parent.leLayout.addWidget(self) + parent.addWidget(parent.partieDroite) + parent.leLayout.widgetActive=self + self.setupUi(self) + + self.connect(self.bSup,SIGNAL("clicked()"),self.BSupPressed) + + def BSupPressed(self): + QTPanel.BSupPressed(self) + diff --git a/InterfaceQT4/monParamPanel.py b/InterfaceQT4/monParamPanel.py index 2b4e0b13..4d385f4e 100644 --- a/InterfaceQT4/monParamPanel.py +++ b/InterfaceQT4/monParamPanel.py @@ -52,9 +52,6 @@ class DParam(Ui_DParam,QDialog): 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,fl) @@ -93,6 +90,8 @@ class MonParamPanel(DParam,QTPanelTBW2,QTPanel): self.Commentaire.setText(QString(commentaire)) self.editor.affiche_infos(commentaire) return + if not val : + return self.node.item.set_nom(nom) self.node.item.set_valeur(val) self.node.update_texte() @@ -124,8 +123,13 @@ class MonParamPanel(DParam,QTPanelTBW2,QTPanel): except : pass if boul: commentaire="Valeur correcte" - self.Commentaire.setText(QString(commentaire)) valString=str(self.lineEditVal.text()) + self.Commentaire.setText(QString(commentaire)) + if (valString.find(' ') > -1) or (valString.find(',') > -1) : + commentaire="Valeur incorrecte" + self.Commentaire.setText(QString(commentaire)) + return None + self.Commentaire.setText(QString(commentaire)) return valString def LENomPressed(self): diff --git a/InterfaceQT4/monPlusieursIntoPanel.py b/InterfaceQT4/monPlusieursIntoPanel.py index 014295aa..ced52dc0 100644 --- a/InterfaceQT4/monPlusieursIntoPanel.py +++ b/InterfaceQT4/monPlusieursIntoPanel.py @@ -35,6 +35,7 @@ class DPlusInto(Ui_DPlusInto,QDialog): QDialog.__init__(self,parent) if hasattr(parent,"leLayout"): parent.leLayout.removeWidget(parent.leLayout.widgetActive) + parent.leLayout.widgetActive.close() parent.leLayout.addWidget(self) parent.leLayout.widgetActive=self else: diff --git a/InterfaceQT4/monRacinePanel.py b/InterfaceQT4/monRacinePanel.py index 99c6de4f..ae3871e3 100644 --- a/InterfaceQT4/monRacinePanel.py +++ b/InterfaceQT4/monRacinePanel.py @@ -59,6 +59,7 @@ class MonRacinePanel(DRac,QTPanelTBW2): self.connecterSignaux() QTPanel.__init__(self,node,parent) QTPanelTBW2.__init__(self,node,parent,racine=1) + self.a=0 def connecterSignaux(self): self.connect(self.LBNouvCommande,SIGNAL("doubleClicked(QListBoxItem*)"),self.LBNouvCommandeClicked) diff --git a/InterfaceQT4/qtCommun.py b/InterfaceQT4/qtCommun.py index e904810c..5a9ed167 100644 --- a/InterfaceQT4/qtCommun.py +++ b/InterfaceQT4/qtCommun.py @@ -87,7 +87,8 @@ class QTPanel: if label==QString("Nommer Concept"): self.LENomConceptReturnPressed() if label==QString("Ajouter Mot-Clef"): - self.DefMC() + if self.LBMCPermis.currentItem() == None : return + self.DefMC(self.LBMCPermis.currentItem()) if label==QString("Définition Formule"): self.BOkPressedFormule() if label==QString("Valeur Parametre"): @@ -107,21 +108,24 @@ class QTPanel: def BuildLBRegles(self,listeRegles,listeNomsEtapes): + self.LBRegles.clear() 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(0,ligne) + self.LBRegles.addItem(ligne) continue if ligne[0]=="\t" : ligne=" "+ligne[1:] if test : - self.LBRegles.insertItem(0,ligne) + self.LBRegles.addItem(ligne) else : - self.LBRegles.insertItem(0,ligne) - #self.LBRegles.insertItem(itemColore(ligne)) + + monItem=QListWidgetItem(ligne) + monItem.setForeground(Qt.red) + self.LBRegles.addItem(monItem) # ----------------------- # @@ -140,7 +144,7 @@ class QTPanelTBW1(QTPanel): def BuildLBMCPermis(self): self.LBMCPermis.clear() - QObject.connect(self.LBMCPermis,SIGNAL("itemDoubleClicked(QListWidegetItem*)"),self.DefMC) + QObject.connect(self.LBMCPermis,SIGNAL("itemDoubleClicked(QListWidgetItem*)"),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) @@ -148,10 +152,9 @@ class QTPanelTBW1(QTPanel): self.LBMCPermis.addItem( aMc) - def DefMC(self): + def DefMC(self,item): """ On ajoute un mot-clé à la commande : subnode """ - if self.LBMCPermis.selectedItem() == None : return - name=str(self.LBMCPermis.selectedItem().text()) + name=str(item.text()) self.editor.init_modif() self.node.append_child(name) @@ -191,11 +194,10 @@ class QTPanelTBW2(QTPanel): for aCmd in listeCmd: self.LBNouvCommande.addItem( aCmd) self.LBNouvCommande.addItem( " " ) - QObject.connect( self.LBNouvCommande, SIGNAL("itemClicked(QListWidgetItem*)"),self.DefCmd ) + #QObject.connect( self.LBNouvCommande, SIGNAL("itemClicked(QListWidgetItem*)"),self.DefCmd ) QObject.connect( self.LBNouvCommande, SIGNAL("itemDoubleClicked(QListWidgetItem*)"),self.DefCmd ) def DefCmd(self): - print "iiiiiii" if (self.editor.focusWidget())!=self.LBNouvCommande : return if self.LBNouvCommande.currentItem()== 0 : return @@ -321,10 +323,3 @@ class ViewText(Ui_dView,QDialog): .arg(unicode(fn)).arg(str(why))) return - -#------------------------------- -#class itemColore(QListBoxText): -#------------------------------- -# def paint(self,p): -# p.setPen(Qt.red) -# QListBoxText.paint(self,p);