#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()
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
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()
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
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
else :
self.plie = False
self.appartientAUnNoeudPlie = False
- #print "self.plie", self.plie
- #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie
#print self.treeParent
ajoutAuParentduNoeud=0
#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
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
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.
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
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
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)
#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()