X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Fbrowser.py;h=7594e78a1725bdade8a88f8c5a5990a815324edc;hb=90ca3e4e92b342779c258ae1ef83fa4ade205f65;hp=5b61c09add09a9770570bae98d17ce43a1c117e8;hpb=796ae9061bdbb9bbaffe59639526dd550b2839fb;p=tools%2Feficas.git diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 5b61c09a..7594e78a 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -67,8 +67,12 @@ class JDCTree( QTreeWidget ): self.inhibeExpand=False #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees if self.racine.children !=[] : + + if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche() else : self.racine.children[0].deplieToutEtReaffiche() + + self.racine.children[0].fenetre.donnePremier() else : self.racine.affichePanneau() #PNPNPN @@ -131,7 +135,7 @@ class JDCTree( QTreeWidget ): def handleOnItem(self,item,int): #if (len(self.selectedIndexes())!=2): return - #print "je passe dans handleOnItem" + #print "je passe dans handleOnItem pour ", self.item.nom self.inhibeExpand == True self.itemCourrant=item itemParent=item @@ -139,11 +143,10 @@ class JDCTree( QTreeWidget ): while not (hasattr (itemParent,'getPanel2')) : if itemParent.plie==True : itemParent.setDeplie() itemParent=itemParent.treeParent - #print itemParent + #print itemParent.item.nom #print itemParent.fenetre #print self.editor.afficheCommandesPliees if itemParent.fenetre != self.editor.fenetreCentraleAffichee : - #print self.editor.afficheCommandesPliees if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche() else : itemParent.affichePanneau() if itemParent!=item and item.fenetre != None: item.fenetre.rendVisible() @@ -170,6 +173,7 @@ PARAMETERS = "PARAMETRE" class JDCNode(QTreeWidgetItem): def __init__( self, treeParent, item): #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self + #print "creation d'un noeud : ", item.nom self.a=0 self.item = item self.vraiParent = treeParent @@ -186,6 +190,7 @@ class JDCNode(QTreeWidgetItem): elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0])) else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :") value = self.appliEficas.trUtf8(str( item.GetText() ) ) + mesColonnes=QStringList() if self.editor.enteteQTree=='complet': mesColonnes << name << value @@ -197,8 +202,6 @@ class JDCNode(QTreeWidgetItem): else : self.plie = False self.appartientAUnNoeudPlie = False - #print "self.plie", self.plie - #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie #print self.treeParent ajoutAuParentduNoeud=0 @@ -293,11 +296,14 @@ class JDCNode(QTreeWidgetItem): #print "dans affichePanneau appel getPanel2", self.item.GetLabelText() if self.item.isactif(): itemParent=self + #print self + #print self.getPanel2 while not (hasattr (itemParent,'getPanel2')) : itemParent=itemParent.treeParent if itemParent!=self : itemParent.affichePanneau() return + #print self.getPanel2 self.fenetre=self.getPanel2() else: from monInactifPanel import PanelInactif @@ -412,6 +418,10 @@ class JDCNode(QTreeWidgetItem): Methode externe """ self.editor.init_modif() + + from InterfaceQT4 import compojdc + if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0 + index = self.treeParent.children.index(self) if pos == 'before': index = index elif pos == 'after': index = index +1 @@ -420,6 +430,35 @@ class JDCNode(QTreeWidgetItem): return 0 return self.treeParent.append_child(name,pos=index,plier=plier) + def verifiePosition(self,name,pos,aLaRacine=False): + if name not in self.editor.Classement_Commandes_Ds_Arbre : return True + indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name) + + etapes=self.item.get_jdc().etapes + if etapes == [] : return True + + if aLaRacine == False :indexOu=etapes.index(self.item.object) + else : indexOu=0 + + if pos=="after" : indexOu = indexOu+1 + for e in etapes[:indexOu] : + nom=e.nom + if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue + indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom) + if indexEtape > indexName : + comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom + QMessageBox.information( None,tr('insertion impossible'),comment, ) + return False + for e in etapes[indexOu:] : + nom=e.nom + if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue + indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom) + if indexEtape < indexName : + comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom + QMessageBox.information( None,tr('insertion impossible'),comment, ) + return False + return True + def append_child(self,name,pos=None,plier=False): """ Methode pour ajouter un objet fils a l'objet associe au noeud self. @@ -428,6 +467,8 @@ class JDCNode(QTreeWidgetItem): Si pos vaut None, on le place a la position du catalogue. """ #print "************** append_child ",self.item.GetLabelText(), plier + + self.editor.init_modif() if pos == 'first': index = 0 @@ -443,6 +484,12 @@ class JDCNode(QTreeWidgetItem): index = self.item.get_index_child(name.nom) else: index = self.item.get_index_child(name) + + # si on essaye d inserer a la racine + if (isinstance(self.treeParent,JDCTree) and index==0) : + verifiePosition=self.verifiePosition(name,'first',aLaRacine=True) + if not verifiePosition : return 0 + self.tree.inhibeExpand=True obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add' if obj is None:obj=0 @@ -545,9 +592,8 @@ class JDCNode(QTreeWidgetItem): def onValid(self): #print "onValid pour ", self.item.nom - if hasattr(self,'fenetre') and self.fenetre: - self.fenetre.setValide() - if self.item.nom == "VARIABLE" and self.item.isvalid(): + if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide() + if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid(): self.item.jdc.recalcule_etat_correlation() if hasattr(self.item,'forceRecalcul'): self.forceRecalculChildren(self.item.forceRecalcul) @@ -706,6 +752,9 @@ class JDCNode(QTreeWidgetItem): #print "je suis dans plieToutEtReaffiche", self.item.get_nom() self.editor.deplier = False for item in self.children : + # il ne faut pas plier les blocs + from InterfaceQT4 import compobloc + if (isinstance(item,compobloc.Node)) : continue item.setPlie() self.affichePanneau()