1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from PyQt4.QtGui import *
23 from PyQt4.QtCore import *
26 from Extensions.i18n import tr
29 from Editeur import Objecttreeitem
32 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
34 def getPanelGroupe(self,parentQt,commande):
35 maDefinition=self.item.get_definition()
36 monObjet=self.item.object
39 if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1
41 if hasattr(self,'plie') :print self.item.nom, self.plie
42 if hasattr(self,'plie') and self.plie==True :
43 from monWidgetFactPlie import MonWidgetFactPlie
44 widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
46 from monWidgetFact import MonWidgetFact
47 widget=MonWidgetFact(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande)
51 def createPopUpMenu(self):
52 typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self)
55 class FACTTreeItem(Objecttreeitem.ObjectTreeItem):
58 def IsExpandable(self):
64 def GetLabelText(self):
65 """ Retourne 3 valeurs :
66 - le texte à afficher dans le noeud representant l'item
67 - la fonte dans laquelle afficher ce texte
70 # None --> fonte et couleur par defaut
71 return self.object.getlabeltext(),None,None
74 return self.object.isvalid()
79 def GetIconName(self):
80 if self.object.isvalid():
81 return "ast-green-los"
82 elif self.object.isoblig():
88 keys=self.object.mc_dict.keys()
93 Reactualise la liste des items fils stockes dans self.sublist
95 liste=self.object.mc_liste
96 sublist=[None]*len(liste)
97 # suppression des items lies aux objets disparus
98 for item in self.sublist:
99 old_obj=item.getObject()
101 pos=liste.index(old_obj)
104 pass # objets supprimes ignores
105 # ajout des items lies aux nouveaux objets
108 if sublist[pos] is None:
109 # nouvel objet : on cree un nouvel item
110 def setfunction(value, object=obj):
112 item = self.make_objecttreeitem(self.appli, obj.nom + " : ", obj, setfunction)
119 def additem(self,name,pos):
120 objet = self.object.addentite(name,pos)
123 def suppitem(self,item) :
125 Cette methode a pour fonction de supprimer l'item passee en argument
126 des fils de l'item FACT qui est son pere
127 - item = item du MOCLE a supprimer du MOCLE pere
128 - item.getObject() = MCSIMP ou MCBLOC
130 itemobject=item.getObject()
131 if itemobject.isoblig() :
132 #self.editor.affiche_infos(tr('Impossible de supprimer un mot-cle obligatoire '),Qt.red)
133 return (0, tr('Impossible de supprimer un mot-cle obligatoire '))
135 if self.object.suppentite(itemobject):
136 message = tr("Mot-cle %s supprime")+ unicode(itemobject.nom)
137 #self.editor.affiche_commentaire(message)
140 #self.editor.affiche_infos(tr('Pb interne : impossible de supprimer ce mot-cle'),Qt.red)
141 return (0,tr('Pb interne : impossible de supprimer ce mot-cle'))
145 treeitem = FACTTreeItem