X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Fbrowser.py;h=7594e78a1725bdade8a88f8c5a5990a815324edc;hb=68af27699b3d841d7d3b21223cbf4e27e4ddd45c;hp=2938b9670f13c8ae5b15a29e52afdb06eeee8765;hpb=b2ab08fd7617bc1919416221b7032890e7fcc78a;p=tools%2Feficas.git diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 2938b967..7594e78a 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -67,15 +67,19 @@ 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 #pdb.set_trace() def contextMenuEvent(self,event) : - print "contextMenuEvent" + #print "contextMenuEvent" coord=event.globalPos() item= self.currentItem() self.handleContextMenu(item,coord) @@ -88,7 +92,7 @@ class JDCTree( QTreeWidget ): @param coord the position of the mouse pointer (QPoint) Attention : existeMenu permet de savoir si un menu est associe a cet item """ - print "handleContextMenu" + #print "handleContextMenu" if item == None : return if item.existeMenu == 0 : return if item.menu == None: @@ -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 @@ -252,7 +255,7 @@ class JDCNode(QTreeWidgetItem): listeExpanded=[] for item in self.childrenComplete : - print dir(item) + #print dir(item) #if item.isExpanded(): # if self.childrenComplete.index(item) < posInsertion : # listeExpanded.append(self.childrenComplete.index(item)) @@ -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 @@ -382,11 +388,10 @@ class JDCNode(QTreeWidgetItem): 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 ) + if after: pos = 'after' + else: pos = 'before' + child=self.append_brother( PARAMETERS, pos ) + return child def select( self ): @@ -394,7 +399,7 @@ class JDCNode(QTreeWidgetItem): Rend le noeud courant (self) selectionne et deselectionne tous les autres """ - print "je suis sur select" + #print "je suis sur select" for item in self.tree.selectedItems() : item.setSelected(0) self.setSelected( True ) @@ -413,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 @@ -421,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. @@ -429,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 @@ -444,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 @@ -472,7 +518,7 @@ class JDCNode(QTreeWidgetItem): else : child.setDeplie() except : child=self.children[index] - print "dans le except" + #print "dans le except" self.tree.inhibeExpand=False return child @@ -546,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) @@ -707,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() @@ -719,20 +767,20 @@ class JDCNode(QTreeWidgetItem): def setPlie(self): #print "je mets inhibeExpand a true dans setPlie" #print "je suis dans plieTout", self.item.get_nom() + import compojdc + if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node): + return self.tree.inhibeExpand=True self.tree.collapseItem(self) self.setPlieChildren() + self.tree.inhibeExpand=False + #print "je mets inhibeExpand a false dans setPlie" # on ne plie pas au niveau 1 - #if not(isinstance(self.treeParent,compojdc.Node)) : - # self.plie=True - #else : # self.plie=False # for item in self.children : # item.appartientAUnNoeudPlie=False - #self.tree.inhibeExpand=False - #print "je mets inhibeExpand a false dans setPlie" def setPlieChildren(self): self.plie=True